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. MFC- receiving Button-Click-Message failed

MFC- receiving Button-Click-Message failed

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxtoolshelpquestion
3 Posts 2 Posters 2 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.
  • M Offline
    M Offline
    Member 11125624
    wrote on last edited by
    #1

    I've created a new dialog in my MFC dialog based application. the new dialog contains 5 control buttons. the following happens and I don't understand why? (buttonX is any button). 1. click on buttonX. (result ok, OnBnClicked message is sent) 2. click on on any place of the application, but not on the dialog. (removing focus from dialog) 3. click again on buttonX (FAILED, OnBnClicked message is NOT sent). but if instead I click on any other button in the dialog (result ok, OnBnClicked message is sent). and when I do: 1. ... 2. ... 3. click on the dialog area just to set focus on the dialog again 4. click again on buttonX. (result ok, OnBnClicked message is sent) (*) I need to do step 3 only if I want to click again on the buttonX! why?? I think it related to SetFocus() but I m not sure how.

    the buttons IDC are: IDC_BACK_MEDIA_PRESS_BUTTON 1180 IDC_TOOLS_LEFT_RIGHT 1024 IDC_MEDIA_FOREWARD_BUTTON 1103 IDC_MEDIA_BACKWARD_BUTTON 1104 IDC_TOOLS_HOOD_BUTTON 2346

    the dialog properties is:

    IDD_TOOLS_DIALOG DIALOGEX 0, 0, 51, 218 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Tools" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN PUSHBUTTON "Media &Foreward",IDC_MEDIA_FOREWARD_BUTTON,7,79,37,36,BS_MULTILINE PUSHBUTTON "&Media &BackWard",IDC_MEDIA_BACKWARD_BUTTON,7,43,37,36,BS_MULTILINE PUSHBUTTON "Back Media Press",IDC_BACK_MEDIA_PRESS_BUTTON,7,127,37,36,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Hood",IDC_TOOLS_HOOD_BUTTON,7,7,37,36 PUSHBUTTON "Left Right",IDC_TOOLS_LEFT_RIGHT,7,175,37,36 END

    I've tried different style like, tool windows, overlapped, popup. it happens in all the cases. Thanks for the help. .h

    <pre>

    class CToolsDlg : public CBDialog { DECLARE_DYNAMIC(CToolsDlg) public: CToolsDlg(CWnd* pParent = NULL); // standard constructor virtual ~CToolsDlg(); CToolTipCtrl m_ToolsTips; // Dialog Data enum { IDD = IDD_TOOLS_DIALOG }; protected: virtual void OnCancel(); virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: CMFCButton m_HoodButton; CMFCButton m_MediaForewardButton; CMFCButton m_MediaBackwardButton; CMFCButton m_LeftRightButton; virtual BOOL OnInitDialog(); virtual BOOL PreTranslateMessage(MSG* pMsg); afx_msg void OnTimer(UINT_PTR nIDEvent); afx_m

    Richard Andrew x64R 1 Reply Last reply
    0
    • M Member 11125624

      I've created a new dialog in my MFC dialog based application. the new dialog contains 5 control buttons. the following happens and I don't understand why? (buttonX is any button). 1. click on buttonX. (result ok, OnBnClicked message is sent) 2. click on on any place of the application, but not on the dialog. (removing focus from dialog) 3. click again on buttonX (FAILED, OnBnClicked message is NOT sent). but if instead I click on any other button in the dialog (result ok, OnBnClicked message is sent). and when I do: 1. ... 2. ... 3. click on the dialog area just to set focus on the dialog again 4. click again on buttonX. (result ok, OnBnClicked message is sent) (*) I need to do step 3 only if I want to click again on the buttonX! why?? I think it related to SetFocus() but I m not sure how.

      the buttons IDC are: IDC_BACK_MEDIA_PRESS_BUTTON 1180 IDC_TOOLS_LEFT_RIGHT 1024 IDC_MEDIA_FOREWARD_BUTTON 1103 IDC_MEDIA_BACKWARD_BUTTON 1104 IDC_TOOLS_HOOD_BUTTON 2346

      the dialog properties is:

      IDD_TOOLS_DIALOG DIALOGEX 0, 0, 51, 218 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Tools" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN PUSHBUTTON "Media &Foreward",IDC_MEDIA_FOREWARD_BUTTON,7,79,37,36,BS_MULTILINE PUSHBUTTON "&Media &BackWard",IDC_MEDIA_BACKWARD_BUTTON,7,43,37,36,BS_MULTILINE PUSHBUTTON "Back Media Press",IDC_BACK_MEDIA_PRESS_BUTTON,7,127,37,36,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Hood",IDC_TOOLS_HOOD_BUTTON,7,7,37,36 PUSHBUTTON "Left Right",IDC_TOOLS_LEFT_RIGHT,7,175,37,36 END

      I've tried different style like, tool windows, overlapped, popup. it happens in all the cases. Thanks for the help. .h

      <pre>

      class CToolsDlg : public CBDialog { DECLARE_DYNAMIC(CToolsDlg) public: CToolsDlg(CWnd* pParent = NULL); // standard constructor virtual ~CToolsDlg(); CToolTipCtrl m_ToolsTips; // Dialog Data enum { IDD = IDD_TOOLS_DIALOG }; protected: virtual void OnCancel(); virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: CMFCButton m_HoodButton; CMFCButton m_MediaForewardButton; CMFCButton m_MediaBackwardButton; CMFCButton m_LeftRightButton; virtual BOOL OnInitDialog(); virtual BOOL PreTranslateMessage(MSG* pMsg); afx_msg void OnTimer(UINT_PTR nIDEvent); afx_m

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Which button is it that is doing this behavior? I don't see any button called "buttonX". Or do all the buttons show this behavior?

      The difficult we do right away... ...the impossible takes slightly longer.

      M 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        Which button is it that is doing this behavior? I don't see any button called "buttonX". Or do all the buttons show this behavior?

        The difficult we do right away... ...the impossible takes slightly longer.

        M Offline
        M Offline
        Member 11125624
        wrote on last edited by
        #3

        Hello Richard, "buttonX" applies to all buttons.

        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