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. CDialogBar event handlers trouble

CDialogBar event handlers trouble

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
2 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.
  • A Offline
    A Offline
    Atropus
    wrote on last edited by
    #1

    Hi, first of all I do apologize if the question is already in the message board, but I cannot find it. Here's my problem. I've implemented a CDialogBar derived class (it makes common initializations to all the dialog bar I need); then I've derived from it a lot of classes each of which implements a specific dialog (created with the dialog designer); in one of them there are various controls (buttons, static text, list box, ecc.); when I add an event associated with a control (e.g. the OnClick event of a button) the designer creates the corresponding method in the class associated to the dialog. I run the program and the button is disabled. If I move the entry ON_BN_CLICKED of the CDialogBar derived class' message map into the MainFrm's one, the button is enable, but when the event is fired and the method is called the 'this' pointer within the method points to the MainFrm instance (I would like that the reference is the CDialogBar derived class). What's wrong? Thanks in advance for any response.

    R 1 Reply Last reply
    0
    • A Atropus

      Hi, first of all I do apologize if the question is already in the message board, but I cannot find it. Here's my problem. I've implemented a CDialogBar derived class (it makes common initializations to all the dialog bar I need); then I've derived from it a lot of classes each of which implements a specific dialog (created with the dialog designer); in one of them there are various controls (buttons, static text, list box, ecc.); when I add an event associated with a control (e.g. the OnClick event of a button) the designer creates the corresponding method in the class associated to the dialog. I run the program and the button is disabled. If I move the entry ON_BN_CLICKED of the CDialogBar derived class' message map into the MainFrm's one, the button is enable, but when the event is fired and the method is called the 'this' pointer within the method points to the MainFrm instance (I would like that the reference is the CDialogBar derived class). What's wrong? Thanks in advance for any response.

      R Offline
      R Offline
      Rajkumar R
      wrote on last edited by
      #2

      Keep the event handler in the CDialogBar[-derived] class itself. To enable the button, you need to handle ON_UPDATE_COMMAND_UI like,

      BEGIN_MESSAGE_MAP(CYourDialogBar, CDialogBar)
      //{{AFX_MSG_MAP(CYourDialogBar)
      ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
      ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()

      void CYourDialogBar::OnUpdateButton1(CCmdUI *pCmdUI)
      {
      pCmdUI->Enable(TRUE);
      }

      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