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. CDlg on active (MFC)

CDlg on active (MFC)

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
14 Posts 5 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.
  • W waxie

    Nope. Not on initial load. I was looking for an event handler every time the dialog is activated, or everytime the dialog goes active (may it be by clicking, or by some key strokes).

    R Offline
    R Offline
    Roger Stoltz
    wrote on last edited by
    #4

    waxie wrote:

    I was looking for an event handler every time the dialog is activated

    Ok. then it's the overridable OnActivate(). It will get called when the window is activated or deactivated. Don't forget to put it in the message map as well. If you add it with ClassWizard this will be done automagically for you. ;)


    "It's supposed to be hard, otherwise anybody could do it!" - selfquote
    "High speed never compensates for wrong direction!" - unknown

    1 Reply Last reply
    0
    • W waxie

      Hi guys, I would like to ask, what is the event handler for dialog activation? I've tried OnActive but it doesn't seem to work. I just want a handler every time a dialog is activated. I'd really appreciate any help or input. Thanks! :rose: Christina

      D Offline
      D Offline
      Doc Lobster
      wrote on last edited by
      #5

      These are just guesses but maybe it helps: Check WM_NCACTIVATE and also the Frame Window of the dialog (i hope CDialog has one) CChildFrame::OnNcActivate(...) worked for me with CView based class in a MDI environment.

      W 1 Reply Last reply
      0
      • W waxie

        Hi guys, I would like to ask, what is the event handler for dialog activation? I've tried OnActive but it doesn't seem to work. I just want a handler every time a dialog is activated. I'd really appreciate any help or input. Thanks! :rose: Christina

        S Offline
        S Offline
        SandipG
        wrote on last edited by
        #6

        May be you are looking for OnShowWindow(BOOL ) or something like this will be called everytime the window is sabout to be shown or hidden.

        W 1 Reply Last reply
        0
        • S SandipG

          May be you are looking for OnShowWindow(BOOL ) or something like this will be called everytime the window is sabout to be shown or hidden.

          W Offline
          W Offline
          waxie
          wrote on last edited by
          #7

          OnShowWindow still doesnt work. :( Thanks for the reply though. :)

          1 Reply Last reply
          0
          • D Doc Lobster

            These are just guesses but maybe it helps: Check WM_NCACTIVATE and also the Frame Window of the dialog (i hope CDialog has one) CChildFrame::OnNcActivate(...) worked for me with CView based class in a MDI environment.

            W Offline
            W Offline
            waxie
            wrote on last edited by
            #8

            I also tried the above suggestions already, still no good. Thanks for the replies though. :) I really appreciate them.

            1 Reply Last reply
            0
            • W waxie

              Nope. Not on initial load. I was looking for an event handler every time the dialog is activated, or everytime the dialog goes active (may it be by clicking, or by some key strokes).

              R Offline
              R Offline
              Roger Stoltz
              wrote on last edited by
              #9

              For clarification reasons, here's how to do it manually: Add the message handler declaration for OnActivate() in you header file:

              afx_msg void OnActivate( UINT nState, CWnd* pwndOther, BOOL bMinimized );

              In your .cpp file, add the message handler to the message map...

              ON\_WM\_ACTIVATE()
              

              END_MESSAGE_MAP()

              ...and add the message handler implementation...

              void <YourDialogClass>::OnActivate( UINT nState, CWnd* pwndOther, BOOL bMinimized )
              {
              TRACE( "OnActivate called.\n" );
              }


              "It's supposed to be hard, otherwise anybody could do it!" - selfquote
              "High speed never compensates for wrong direction!" - unknown

              W 1 Reply Last reply
              0
              • R Roger Stoltz

                For clarification reasons, here's how to do it manually: Add the message handler declaration for OnActivate() in you header file:

                afx_msg void OnActivate( UINT nState, CWnd* pwndOther, BOOL bMinimized );

                In your .cpp file, add the message handler to the message map...

                ON\_WM\_ACTIVATE()
                

                END_MESSAGE_MAP()

                ...and add the message handler implementation...

                void <YourDialogClass>::OnActivate( UINT nState, CWnd* pwndOther, BOOL bMinimized )
                {
                TRACE( "OnActivate called.\n" );
                }


                "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                "High speed never compensates for wrong direction!" - unknown

                W Offline
                W Offline
                waxie
                wrote on last edited by
                #10

                Just to be sure,what I did is I went to the dialog resource and looked for the message handlers in its properties and added a message handler for WM_ACTIVATE. Still no good though. The dialog (my dialog) is one of the tabs of a parent dialog. Would it matter?

                S R 2 Replies Last reply
                0
                • W waxie

                  Just to be sure,what I did is I went to the dialog resource and looked for the message handlers in its properties and added a message handler for WM_ACTIVATE. Still no good though. The dialog (my dialog) is one of the tabs of a parent dialog. Would it matter?

                  S Offline
                  S Offline
                  sps itsec46
                  wrote on last edited by
                  #11

                  Is your dialog a property page? If yes then try CPropertyPage::OnSetActive().

                  cheers, mykel OMM: "Let us be thankful we have commerce. Buy more. Buy more now. Buy. And be happy."

                  W 1 Reply Last reply
                  0
                  • S sps itsec46

                    Is your dialog a property page? If yes then try CPropertyPage::OnSetActive().

                    cheers, mykel OMM: "Let us be thankful we have commerce. Buy more. Buy more now. Buy. And be happy."

                    W Offline
                    W Offline
                    waxie
                    wrote on last edited by
                    #12

                    Nope, it's not a property page. It's a tab page in a tabcontrol.:)

                    S 1 Reply Last reply
                    0
                    • W waxie

                      Nope, it's not a property page. It's a tab page in a tabcontrol.:)

                      S Offline
                      S Offline
                      sps itsec46
                      wrote on last edited by
                      #13

                      'ait... according to MSDN i recommend the following:

                      TCN_SELCHANGE Notification
                      Notifies a tab control's parent window that the currently selected tab has changed.
                      This message is sent in the form of a WM_NOTIFY message.

                      check MSDN for further details, e.g. the handle to the tab control is passed with the notification. then i guess you can call CTabCtrl::GetCurSel() to get the currently selected tab.

                      cheers, mykel OMM: "Let us be thankful we have commerce. Buy more. Buy more now. Buy. And be happy."

                      1 Reply Last reply
                      0
                      • W waxie

                        Just to be sure,what I did is I went to the dialog resource and looked for the message handlers in its properties and added a message handler for WM_ACTIVATE. Still no good though. The dialog (my dialog) is one of the tabs of a parent dialog. Would it matter?

                        R Offline
                        R Offline
                        Roger Stoltz
                        wrote on last edited by
                        #14

                        waxie wrote:

                        The dialog (my dialog) is one of the tabs of a parent dialog. Would it matter?

                        It depends on what you're trying to do. My guess is that you want to know when the user selects another tab in the control. If I guessed correctly and you're using CTabCtrl you have to write a message handler for the WM_NOTIFY message sent from the tab control with the TCN_SELCHANGE control code. Use ClassWizard to add a message handler for this. Afterwards you message map should have an entry looking something like this:

                        ON_NOTIFY( TCN_SELCHANGE, IDC_TAB, OnTabChanged )

                        ...and a message handler looking similar to this:

                        void <YourDialogClass>::OnTabSelchange( NMHDR* pNMHDR, LRESULT* pResult )

                        Have a look att the MSDN sample FIRE[^] to see how it's done.


                        "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                        "High speed never compensates for wrong direction!" - unknown

                        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