Jump to content


Photo

Problem with LoadFromRegistry


  • Please log in to reply
7 replies to this topic

#1 Jordan

Jordan
  • Members
  • 14 posts

Posted 14 July 2009 - 08:14 PM

Under some circumstances the LoadFromRegistry does not properly order the columns after a SaveToRegistry. The problem appears to be related to the order in which the column information is processed by NxColumns.ChangePosition.

To demonstrate this problem, create an NxGrid with four columns, with headers "First", "Second", "Third", and "Fourth". Fill in some rows with arbitrary data. Use the mouse to drag column "Fourth" to the first position. Then use the mouse to drag column "Third" to the second position so that the column headers now read "Fourth", "Third", "First", "Second". Perform a SaveToRegistry. Close the program, and restart it. Create the original NxGrid again, and perform a LoadFromRegistry. The columns will now show as "Fourth", "First", "Third", "Second".

I have attached code that demonstrates this problem. It is easy to reproduce.

I believe that the fix to this problem involves processing the saved registry information in a different order - rather than reading the original columns and setting each one to its new position, read the column order information from the registry, and then set the new column positions in increasing order of the New positions rather than the Old positions.

Attached Files



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 14 July 2009 - 08:47 PM

Hello Jordan,

You are correct. I will need some kind of "silent" method for reading column positions without arranging them with each loaded column.

Another solution may be loading column positions inside TList and set them when all columns are loaded.

I will need 1-2 days to solve this. Thank you for reporting.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Jordan

Jordan
  • Members
  • 14 posts

Posted 14 July 2009 - 09:28 PM

Thanks very much for your responsiveness.

If there's anything I can do to help, or more information I can provide, please let me know.

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 14 July 2009 - 10:08 PM

Hello Jordan,

Thank you, I will try to fix this problem.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 14 July 2009 - 11:15 PM

Hello Jordan,

Problem seems to be more tricky than I expect sad.gif

If you have any idea how to solve this, you are welcome smile.gif In meanwhile I will look for solution.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#6 Jordan

Jordan
  • Members
  • 14 posts

Posted 15 July 2009 - 01:11 AM

I think I would read all the column position items into a temporary tList, and then sort that list by the destination position. After it's sorted, do the ChangePosition on the column that is to be moved. At the risk of some loss of generality, you could take advantage of the fact that you have set a reasonable maximum number of columns (1000, I think), so you could easily use the 32 bit pointer of the tList to hold both destination and source by using SHL 16. Each pointer in the tList would have the destination column number in the high-order 16 bits, and the original column number in the low order 16 bits. There would be room for 2^16 columns that way, and you would only need the one auxiliary tList data structure.

Of course, this all assumes that by processing the columns in destination order, the problem will be fixed. I think it will, but I haven't tried to prove it. It seems to me that some of the columns that were properly positioned were subsequently moved when other columns needed to be placed in front of them. If that's the case, then doing the columns in destination order ought to fix the problem.

I don't know if it matters whether you set the column positions first, and then set the other parameters of the columns, once it has been moved. That would be my approach, just to avoid other potential complications.

#7 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 16 July 2009 - 10:37 PM

Hello Jordan,

I think that I have solve it. I will test it a little bit more and then send you a fix.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#8 Jordan

Jordan
  • Members
  • 14 posts

Posted 17 July 2009 - 04:32 PM

QUOTE (Boki (Berg) @ Jul 16 2009, 05:37 PM) <{POST_SNAPBACK}>
Hello Jordan,

I think that I have solve it. I will test it a little bit more and then send you a fix.

Best regards


Excellent! I am looking forward to the solution.

Thank you!!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users