GUI/Data Design question
-
Hello, I've a document class with an array of records each containing about 15 fields. Currently, I send messages to my GUI to update a record (listview) if that record's fields have been changed (intercepted at documents 'setrecordfield()' function). The problem is that the user can change as many as 5 fields in one GUI operation. This causes my current design to send 5 messages to the GUI to refresh the display--this can become very slow with an increasing number of records/changes (plus, some of my display text items require relatively long functions to compute for each update). I've put some thought in to this but haven't come up with an eloquent design that would only update the GUI when it 'should' (i.e., after the document has stopped changing but not too long after so that the user witnesses delay). I could litter my code with conditional update calls, but that seems like a lot of 'ifs' and would require that I keep changing these places throughout development. I'm not a professional MFC developer, so any hints or approches would be appreciated. Thanks! JennyP
-
Hello, I've a document class with an array of records each containing about 15 fields. Currently, I send messages to my GUI to update a record (listview) if that record's fields have been changed (intercepted at documents 'setrecordfield()' function). The problem is that the user can change as many as 5 fields in one GUI operation. This causes my current design to send 5 messages to the GUI to refresh the display--this can become very slow with an increasing number of records/changes (plus, some of my display text items require relatively long functions to compute for each update). I've put some thought in to this but haven't come up with an eloquent design that would only update the GUI when it 'should' (i.e., after the document has stopped changing but not too long after so that the user witnesses delay). I could litter my code with conditional update calls, but that seems like a lot of 'ifs' and would require that I keep changing these places throughout development. I'm not a professional MFC developer, so any hints or approches would be appreciated. Thanks! JennyP
Maybe you can take advantage of
LockWindowUpdate
just like this:CYourView:SomeCommandHandler()
{
AfxGetMainWnd()->LockWindowUpdate();
// doc ops potentially generating multiple refresh messages.
AfxGetMainWnd()->UnlockWindowUpdate();
}Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
Maybe you can take advantage of
LockWindowUpdate
just like this:CYourView:SomeCommandHandler()
{
AfxGetMainWnd()->LockWindowUpdate();
// doc ops potentially generating multiple refresh messages.
AfxGetMainWnd()->UnlockWindowUpdate();
}Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Thanks for the response. In my case, its not the graphical device painting that takes time, it's the GUI class calculations that I employ each time the data changes. Unfortunately, the data will change 5 times "at once" causing these calculations to be run 5 times when all I need is one calculation to be done on the last data-change (only after the "last" data change). Thanks! JennyP
-
Thanks for the response. In my case, its not the graphical device painting that takes time, it's the GUI class calculations that I employ each time the data changes. Unfortunately, the data will change 5 times "at once" causing these calculations to be run 5 times when all I need is one calculation to be done on the last data-change (only after the "last" data change). Thanks! JennyP
Well, you can develop a similar custom-made mechanism that tells the "GUI class" not to initiate calculations when in the middle of a sequence of record changes. Don't know how hard this would be to accomplish in your particular case. Another altenative is to have
GetData
andSetData
methods for your doc class that allows you to perform the changes on a local copy of the data. When done, these changes can be plugged again into the document class, thus triggering the GUI updating. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo