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. Missing Button Click Message

Missing Button Click Message

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studioquestionlearning
10 Posts 3 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.
  • B Offline
    B Offline
    BarryPearlman
    wrote on last edited by
    #1

    The objective is to create a class that contains the methods to create and gather messages from a series of message dialogs by means of a series of buttons on a dialog created with the resource editor. The app is being written with VS 2010 and the classes, events etc. utilizing the supplied Wizards. This is an SDI app with p_MFCls-> pointing to the MainFrameEx* object and p->MsgCls being the child of p_MFCls-> and a CWnd* object. p_Dlg-> is a pointer to the actual dialog box and is a CDialog* object parented by the p_MsgCls object. FWIW: Windows 8.1 I have the following code (partial): In p_MFCls: //.h

    CJBK_Msg* p_MsgCls;

    //.cpp

    p_MsgCls = new CJBK_Msg;
    ASSERT(p_MsgCls->Create(NULL, NULL, 0, CRect(0, 0, 0, 0), this, IDCls_Msg));

    In p_MsgCls, when the appropriate message is received, we have:

    //.h
    CDialog* p_DlgBox;

    //.cpp

    p_DlgBox = new CDialog;
    ASSERT(p_DlgBox->Create(p_strMsgBox->nDlgBoxResID, this));

    For the button(s), I used the Event Handler Wizard but whether I tell it to send the event to p_MFCls or p_MsgCls, it never gets there when I click the button control. Can anyone spot something that I have missed? Thanks and Happy Holidays to all, Barry

    L F 2 Replies Last reply
    0
    • B BarryPearlman

      The objective is to create a class that contains the methods to create and gather messages from a series of message dialogs by means of a series of buttons on a dialog created with the resource editor. The app is being written with VS 2010 and the classes, events etc. utilizing the supplied Wizards. This is an SDI app with p_MFCls-> pointing to the MainFrameEx* object and p->MsgCls being the child of p_MFCls-> and a CWnd* object. p_Dlg-> is a pointer to the actual dialog box and is a CDialog* object parented by the p_MsgCls object. FWIW: Windows 8.1 I have the following code (partial): In p_MFCls: //.h

      CJBK_Msg* p_MsgCls;

      //.cpp

      p_MsgCls = new CJBK_Msg;
      ASSERT(p_MsgCls->Create(NULL, NULL, 0, CRect(0, 0, 0, 0), this, IDCls_Msg));

      In p_MsgCls, when the appropriate message is received, we have:

      //.h
      CDialog* p_DlgBox;

      //.cpp

      p_DlgBox = new CDialog;
      ASSERT(p_DlgBox->Create(p_strMsgBox->nDlgBoxResID, this));

      For the button(s), I used the Event Handler Wizard but whether I tell it to send the event to p_MFCls or p_MsgCls, it never gets there when I click the button control. Can anyone spot something that I have missed? Thanks and Happy Holidays to all, Barry

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      BarryPearlman wrote:

      Can anyone spot something that I have missed?

      Where is the actual event handling code? What you have shown above does not tell us anything about where these events are supposed to be captured.

      Veni, vidi, abiit domum

      B 1 Reply Last reply
      0
      • B BarryPearlman

        The objective is to create a class that contains the methods to create and gather messages from a series of message dialogs by means of a series of buttons on a dialog created with the resource editor. The app is being written with VS 2010 and the classes, events etc. utilizing the supplied Wizards. This is an SDI app with p_MFCls-> pointing to the MainFrameEx* object and p->MsgCls being the child of p_MFCls-> and a CWnd* object. p_Dlg-> is a pointer to the actual dialog box and is a CDialog* object parented by the p_MsgCls object. FWIW: Windows 8.1 I have the following code (partial): In p_MFCls: //.h

        CJBK_Msg* p_MsgCls;

        //.cpp

        p_MsgCls = new CJBK_Msg;
        ASSERT(p_MsgCls->Create(NULL, NULL, 0, CRect(0, 0, 0, 0), this, IDCls_Msg));

        In p_MsgCls, when the appropriate message is received, we have:

        //.h
        CDialog* p_DlgBox;

        //.cpp

        p_DlgBox = new CDialog;
        ASSERT(p_DlgBox->Create(p_strMsgBox->nDlgBoxResID, this));

        For the button(s), I used the Event Handler Wizard but whether I tell it to send the event to p_MFCls or p_MsgCls, it never gets there when I click the button control. Can anyone spot something that I have missed? Thanks and Happy Holidays to all, Barry

        F Offline
        F Offline
        Freak30
        wrote on last edited by
        #3

        You have wrapped the Create() functions in ASSERT() macros, which at least in Visual Studio 6.0 means they are executed only in debug mode. Assuming this behavior has not changed in VS 2010, you should use VERIFY() instead.

        The good thing about pessimism is, that you are always either right or pleasently surprised.

        B 1 Reply Last reply
        0
        • L Lost User

          BarryPearlman wrote:

          Can anyone spot something that I have missed?

          Where is the actual event handling code? What you have shown above does not tell us anything about where these events are supposed to be captured.

          Veni, vidi, abiit domum

          B Offline
          B Offline
          BarryPearlman
          wrote on last edited by
          #4

          Sorry about that! Ideally the button click event should be handled first in p_MsgCls since p_MsgCls-> is intended to handle all of the messages for the entire application. Second choice is CMainFrameEx. Using the Event Handler Wizard for p_MsgCls I get: //.h DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClicked_MB_Btn2(); //.cpp

          BEGIN_MESSAGE_MAP(CJBK_Msg, CWnd)

                      ..........................
          

          ON_BN_CLICKED(ID_MB_Btn_2, &CJBK_Msg::OnBnClicked_MB_Btn2)
          END_MESSAGE_MAP()

          void CJBK_Msg::OnBnClicked_MB_Btn2()
          {
          // TODO: Add your control notification handler code here
          }

          I am working under the assumption that if the Event Handler Wizard (in general) presents me with a choice, it is a valid one and will work. Thanks, Barry

          L 1 Reply Last reply
          0
          • B BarryPearlman

            Sorry about that! Ideally the button click event should be handled first in p_MsgCls since p_MsgCls-> is intended to handle all of the messages for the entire application. Second choice is CMainFrameEx. Using the Event Handler Wizard for p_MsgCls I get: //.h DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClicked_MB_Btn2(); //.cpp

            BEGIN_MESSAGE_MAP(CJBK_Msg, CWnd)

                        ..........................
            

            ON_BN_CLICKED(ID_MB_Btn_2, &CJBK_Msg::OnBnClicked_MB_Btn2)
            END_MESSAGE_MAP()

            void CJBK_Msg::OnBnClicked_MB_Btn2()
            {
            // TODO: Add your control notification handler code here
            }

            I am working under the assumption that if the Event Handler Wizard (in general) presents me with a choice, it is a valid one and will work. Thanks, Barry

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            BarryPearlman wrote:

            I am working under the assumption

            Never do that, check everything. However good the wizards may be they are not infallible. You can easily check that things are plugged together correctly by setting a few breakpoints in your code and running some controlled tests.

            Veni, vidi, abiit domum

            B 1 Reply Last reply
            0
            • F Freak30

              You have wrapped the Create() functions in ASSERT() macros, which at least in Visual Studio 6.0 means they are executed only in debug mode. Assuming this behavior has not changed in VS 2010, you should use VERIFY() instead.

              The good thing about pessimism is, that you are always either right or pleasently surprised.

              B Offline
              B Offline
              BarryPearlman
              wrote on last edited by
              #6

              This post dealt with missing events, not a request for the difference between ASSERT() and VERIFY()! Frankly, I am hard pressed to find a decent explanation of the fine nuances between them, except their use during runtime and debug. It is my own personal philosophy that the end user should never see the arcane messages these macros produce. An error at a hex address means absolutely nothing to a user except that there is an error and that the developer has failed to take something into account. Perhaps a philosophical dissertation/lecture is in order here??

              F 1 Reply Last reply
              0
              • L Lost User

                BarryPearlman wrote:

                I am working under the assumption

                Never do that, check everything. However good the wizards may be they are not infallible. You can easily check that things are plugged together correctly by setting a few breakpoints in your code and running some controlled tests.

                Veni, vidi, abiit domum

                B Offline
                B Offline
                BarryPearlman
                wrote on last edited by
                #7

                I always do. That is how I found out that the code that the Event Wizard Handler was writing code that wasn't working in the first place. The question still remains why can't I get the event to fire in p_MSCls->? Thanks, Barry

                L 1 Reply Last reply
                0
                • B BarryPearlman

                  I always do. That is how I found out that the code that the Event Wizard Handler was writing code that wasn't working in the first place. The question still remains why can't I get the event to fire in p_MSCls->? Thanks, Barry

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Does the control that raises the event belong to this class, and are the message macros pointing to the right places? From the little pieces of code you have shown us it is not easy to understand how your project fits together.

                  Veni, vidi, abiit domum

                  B 1 Reply Last reply
                  0
                  • L Lost User

                    Does the control that raises the event belong to this class, and are the message macros pointing to the right places? From the little pieces of code you have shown us it is not easy to understand how your project fits together.

                    Veni, vidi, abiit domum

                    B Offline
                    B Offline
                    BarryPearlman
                    wrote on last edited by
                    #9

                    You may be on the right class concerning who belongs to which class and hence the missing events. I will get back to this project later on in the week and thanks to you have some new avenues to explore. Thanks & Happy Holidays, Barry

                    1 Reply Last reply
                    0
                    • B BarryPearlman

                      This post dealt with missing events, not a request for the difference between ASSERT() and VERIFY()! Frankly, I am hard pressed to find a decent explanation of the fine nuances between them, except their use during runtime and debug. It is my own personal philosophy that the end user should never see the arcane messages these macros produce. An error at a hex address means absolutely nothing to a user except that there is an error and that the developer has failed to take something into account. Perhaps a philosophical dissertation/lecture is in order here??

                      F Offline
                      F Offline
                      Freak30
                      wrote on last edited by
                      #10

                      This wasn't meant as a philosophical discussion. If you enclose an important function call, e.g. the creation of a dialog in an ASSERT(), the dialog will not be created in Release mode and therefore can't receive any messages. If you use VERIFY(), the dialog will be created in Release mode as well. However, the "arcance message" as you call it, will only be displayed in Debug mode.

                      The good thing about pessimism is, that you are always either right or pleasently surprised.

                      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