Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GUI/Data Design question

GUI/Data Design question

Scheduled Pinned Locked Moved C / C++ / MFC
c++designdata-structureshelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JennyP
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • J 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

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      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

      J 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        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

        J Offline
        J Offline
        JennyP
        wrote on last edited by
        #3

        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

        J 1 Reply Last reply
        0
        • J 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

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          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 and SetData 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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups