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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Capturing WM_ACTIVATE in CPropertyPage

Capturing WM_ACTIVATE in CPropertyPage

Scheduled Pinned Locked Moved C / C++ / MFC
questionmcphardwarehelp
17 Posts 4 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.
  • D Offline
    D Offline
    dennisV
    wrote on last edited by
    #1

    Hello, I have a CPropertySheet with a few property pages embedded in a form view. I would like to capture the WM_ACTIVATE message to see when I should write/read data from/to property pages. The problems is the the form view is eating up that message. I can only monitor WM_CHILDACTIVATE and OnKillActive(), but that doesn't cover all cases. I want to save data whenever a user clicks away from the property sheet. How can I do that? Any help greatly appreciated! MCP, MCSD

    RaviBeeR M 2 Replies Last reply
    0
    • D dennisV

      Hello, I have a CPropertySheet with a few property pages embedded in a form view. I would like to capture the WM_ACTIVATE message to see when I should write/read data from/to property pages. The problems is the the form view is eating up that message. I can only monitor WM_CHILDACTIVATE and OnKillActive(), but that doesn't cover all cases. I want to save data whenever a user clicks away from the property sheet. How can I do that? Any help greatly appreciated! MCP, MCSD

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      Override OnSetActive() when you want to (re)set the property page's controls. Override OnKillActive() and OnOK() (and optionally OnApply()) to capture the settings from the property page. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

      D 1 Reply Last reply
      0
      • D dennisV

        Hello, I have a CPropertySheet with a few property pages embedded in a form view. I would like to capture the WM_ACTIVATE message to see when I should write/read data from/to property pages. The problems is the the form view is eating up that message. I can only monitor WM_CHILDACTIVATE and OnKillActive(), but that doesn't cover all cases. I want to save data whenever a user clicks away from the property sheet. How can I do that? Any help greatly appreciated! MCP, MCSD

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        WM_ACTIVATE isn't the right message for a page. There are notifications made for just this purpose, PSN_SETACTIVE and PSN_KILLACTIVE. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber CP SearchBar v2.0.2 released

        D 1 Reply Last reply
        0
        • RaviBeeR RaviBee

          Override OnSetActive() when you want to (re)set the property page's controls. Override OnKillActive() and OnOK() (and optionally OnApply()) to capture the settings from the property page. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

          D Offline
          D Offline
          dennisV
          wrote on last edited by
          #4

          Well, I did that, but it doesn't cover all cases I want - for example, when a user simply clicks away from my property page to another control on the form view, I want to save data he had in the pp. MCP, MCSD

          RaviBeeR 1 Reply Last reply
          0
          • M Michael Dunn

            WM_ACTIVATE isn't the right message for a page. There are notifications made for just this purpose, PSN_SETACTIVE and PSN_KILLACTIVE. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber CP SearchBar v2.0.2 released

            D Offline
            D Offline
            dennisV
            wrote on last edited by
            #5

            But aren't these two messages what the OnSetActive() and OnKillActive() MFC functions do? You see, I need the control to generate something when the user clicks away from it, not just changes to another property page. MCP, MCSD

            J 1 Reply Last reply
            0
            • D dennisV

              Well, I did that, but it doesn't cover all cases I want - for example, when a user simply clicks away from my property page to another control on the form view, I want to save data he had in the pp. MCP, MCSD

              RaviBeeR Offline
              RaviBeeR Offline
              RaviBee
              wrote on last edited by
              #6

              Ah, so your property sheet is a modeless one, and is a child of your form view. You could set a timer that does what OnKillFocus() would do, each time the property sheet loses (i.e. no longer has) focus. I admit the solution reeks of cheddar, but it would work. But I think there may be something fundamentally wrong with your UI design if you need to do this. What might be more appropriate is updating your data every time the user tweaks a control within the property page(s). That way (a) you won't have to query the state of the controls and (b) your data will always be in synch with the GUI. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

              D 1 Reply Last reply
              0
              • RaviBeeR RaviBee

                Ah, so your property sheet is a modeless one, and is a child of your form view. You could set a timer that does what OnKillFocus() would do, each time the property sheet loses (i.e. no longer has) focus. I admit the solution reeks of cheddar, but it would work. But I think there may be something fundamentally wrong with your UI design if you need to do this. What might be more appropriate is updating your data every time the user tweaks a control within the property page(s). That way (a) you won't have to query the state of the controls and (b) your data will always be in synch with the GUI. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

                D Offline
                D Offline
                dennisV
                wrote on last edited by
                #7

                Well, the form view has the property sheets and a grid control, so when a user clicks on something in the grid, data gets updated in the property sheets, but it has to be saved when changed in the property sheets and displayed in the grid. So, that's the problem I have - to find out when the user clicked away from the property page, so that I could update the grid BEFORE the click gets there and resets the data. I don't know if it's wrong UI design, but I couldn't think of any other way to accomplish this? But I was thinking about updating the data after each control change, but I wanted to stay away from that path for as long as possible, since I have 6 property pages with around 50 controls, so that would be a lot of handler functions :omg: MCP, MCSD

                1 Reply Last reply
                0
                • D dennisV

                  But aren't these two messages what the OnSetActive() and OnKillActive() MFC functions do? You see, I need the control to generate something when the user clicks away from it, not just changes to another property page. MCP, MCSD

                  J Offline
                  J Offline
                  jhwurmbach
                  wrote on last edited by
                  #8

                  Does handling WM_SETFOCUS / WM_KILLFOCUS help you? (For me, it does not, because the controls get no WM_KILLFOCUS when the user clicks a Toolbar-button - probably the button does not accept the focus)


                  Who is 'General Failure'? And why is he reading my harddisk?!?

                  D 1 Reply Last reply
                  0
                  • J jhwurmbach

                    Does handling WM_SETFOCUS / WM_KILLFOCUS help you? (For me, it does not, because the controls get no WM_KILLFOCUS when the user clicks a Toolbar-button - probably the button does not accept the focus)


                    Who is 'General Failure'? And why is he reading my harddisk?!?

                    D Offline
                    D Offline
                    dennisV
                    wrote on last edited by
                    #9

                    No, these messages are not sent to propery pages. MCP, MCSD

                    J 1 Reply Last reply
                    0
                    • D dennisV

                      No, these messages are not sent to propery pages. MCP, MCSD

                      J Offline
                      J Offline
                      jhwurmbach
                      wrote on last edited by
                      #10

                      dennisV wrote: No, these messages are not sent to propery pages. I know, you would have to do that yourself, using handlers in the sheet that re-send the message to the pages. (You could as well have the sheet send a private message (WM_APP+xx or a registred WM)


                      Who is 'General Failure'? And why is he reading my harddisk?!?

                      D 1 Reply Last reply
                      0
                      • J jhwurmbach

                        dennisV wrote: No, these messages are not sent to propery pages. I know, you would have to do that yourself, using handlers in the sheet that re-send the message to the pages. (You could as well have the sheet send a private message (WM_APP+xx or a registred WM)


                        Who is 'General Failure'? And why is he reading my harddisk?!?

                        D Offline
                        D Offline
                        dennisV
                        wrote on last edited by
                        #11

                        Well, I've tried capturing WM_KILLFOCUS and it doesn't reach the CPropertySheet :confused: That's the original problem I have - normal messages are eaten up by the CMainFrame and never reach anywhere. That's why WM_ACTIVATE doesn't work as well... MCP, MCSD

                        J 1 Reply Last reply
                        0
                        • D dennisV

                          Well, I've tried capturing WM_KILLFOCUS and it doesn't reach the CPropertySheet :confused: That's the original problem I have - normal messages are eaten up by the CMainFrame and never reach anywhere. That's why WM_ACTIVATE doesn't work as well... MCP, MCSD

                          J Offline
                          J Offline
                          jhwurmbach
                          wrote on last edited by
                          #12

                          WM_KILLFOCUS does indeed reach a PropSheet. I do handle it there. If CFormView really eats it, re-send it in your CFormView derived class.


                          Who is 'General Failure'? And why is he reading my harddisk?!?

                          D 1 Reply Last reply
                          0
                          • J jhwurmbach

                            WM_KILLFOCUS does indeed reach a PropSheet. I do handle it there. If CFormView really eats it, re-send it in your CFormView derived class.


                            Who is 'General Failure'? And why is he reading my harddisk?!?

                            D Offline
                            D Offline
                            dennisV
                            wrote on last edited by
                            #13

                            Well, WM_KILLFOCUS is caught in the CFormView, but I have no way of knowing (or at least I don't know of a way) to determine which window lost the focus, so I don't know to which window to send it. I have a property sheet and a grid control on my CFormView, and I need to determine when the property sheet looses focus, but OnKillFocus() provides a pointer to the new window, not the window that lost focus. Or is there a way to find out which window lost focus? Thanks for your help! MCP, MCSD

                            J 1 Reply Last reply
                            0
                            • D dennisV

                              Well, WM_KILLFOCUS is caught in the CFormView, but I have no way of knowing (or at least I don't know of a way) to determine which window lost the focus, so I don't know to which window to send it. I have a property sheet and a grid control on my CFormView, and I need to determine when the property sheet looses focus, but OnKillFocus() provides a pointer to the new window, not the window that lost focus. Or is there a way to find out which window lost focus? Thanks for your help! MCP, MCSD

                              J Offline
                              J Offline
                              jhwurmbach
                              wrote on last edited by
                              #14

                              Well, now I am out of luck. You *could* try to call CWnd::GetFocus() to determine which control currently has the focus. But I do not know if this works. Sorry, without CFormView your sheet can catch WM_KILLFOCUS, and that is what I do. My only problem is that clicking a toolbar-button does not remove the keyboard focus from the control on my property page.


                              Who is 'General Failure'? And why is he reading my harddisk?!?

                              D 1 Reply Last reply
                              0
                              • J jhwurmbach

                                Well, now I am out of luck. You *could* try to call CWnd::GetFocus() to determine which control currently has the focus. But I do not know if this works. Sorry, without CFormView your sheet can catch WM_KILLFOCUS, and that is what I do. My only problem is that clicking a toolbar-button does not remove the keyboard focus from the control on my property page.


                                Who is 'General Failure'? And why is he reading my harddisk?!?

                                D Offline
                                D Offline
                                dennisV
                                wrote on last edited by
                                #15

                                Yes, without the CFormView things worked for me too. That's why I got stuck when I implemented the CFormView. Perhaps it's an MFC bug or something... I think I'll go complain to MS, although that probably won't help me ;) MCP, MCSD

                                J 1 Reply Last reply
                                0
                                • D dennisV

                                  Yes, without the CFormView things worked for me too. That's why I got stuck when I implemented the CFormView. Perhaps it's an MFC bug or something... I think I'll go complain to MS, although that probably won't help me ;) MCP, MCSD

                                  J Offline
                                  J Offline
                                  jhwurmbach
                                  wrote on last edited by
                                  #16

                                  dennisV wrote: I think I'll go complain to MS, although that probably won't help me They will thell you its the intended behaviour (its intention is to save programming time to fix the bug ;-) ). Then they will tell you how nice .NET is...


                                  Who is 'General Failure'? And why is he reading my harddisk?!?

                                  D 1 Reply Last reply
                                  0
                                  • J jhwurmbach

                                    dennisV wrote: I think I'll go complain to MS, although that probably won't help me They will thell you its the intended behaviour (its intention is to save programming time to fix the bug ;-) ). Then they will tell you how nice .NET is...


                                    Who is 'General Failure'? And why is he reading my harddisk?!?

                                    D Offline
                                    D Offline
                                    dennisV
                                    wrote on last edited by
                                    #17

                                    jhwurmbach wrote: They will thell you its the intended behaviour Right:-D Oh well, I guess I'll do it the old-fashioned way, until I can find a solution - I'll just add an event handler for every change in every control and save data then. At least it won't be lost then. Thanks again for your help! MCP, MCSD

                                    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