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. Catching clicking

Catching clicking

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
6 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.
  • Y Offline
    Y Offline
    YaronNir
    wrote on last edited by
    #1

    Hi all, i have a modal dialog. i've created a button in run-time using new operator to CButton class, and then Create; my question is i want the dialog to catch the pressing of the button or other buttons created at run-time for that matter..... how to do that??? i know i need to use reflection or something like that.. i would like to see some sample code .... Thanks in advanced Yaron Ask not what your application can do for you, Ask what you can do for your application

    A Y P 3 Replies Last reply
    0
    • Y YaronNir

      Hi all, i have a modal dialog. i've created a button in run-time using new operator to CButton class, and then Create; my question is i want the dialog to catch the pressing of the button or other buttons created at run-time for that matter..... how to do that??? i know i need to use reflection or something like that.. i would like to see some sample code .... Thanks in advanced Yaron Ask not what your application can do for you, Ask what you can do for your application

      A Offline
      A Offline
      alex barylski
      wrote on last edited by
      #2

      It's to my understanding that message reflection is MFC compile time only. If your creating windows dynamically I don't think there is a way to map handlers using macros :) So I would suggest probably using OnCommand() and using an if statement:

      MyDialog::OnCommand( WPARAM wParam, LPARAM lParam )
      {
      if(LOWORD(wParam) <= IDC_DNYCTRL_FIRST && LOWORD(wParam) >= IDC_DNYCTRL_LAST)
      // Handle any button click within a range of values
      }

      HTH Cheers :) I'm drinking triples, seeing double and acting single :cool:

      D 1 Reply Last reply
      0
      • A alex barylski

        It's to my understanding that message reflection is MFC compile time only. If your creating windows dynamically I don't think there is a way to map handlers using macros :) So I would suggest probably using OnCommand() and using an if statement:

        MyDialog::OnCommand( WPARAM wParam, LPARAM lParam )
        {
        if(LOWORD(wParam) <= IDC_DNYCTRL_FIRST && LOWORD(wParam) >= IDC_DNYCTRL_LAST)
        // Handle any button click within a range of values
        }

        HTH Cheers :) I'm drinking triples, seeing double and acting single :cool:

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Hockey wrote: if(LOWORD(wParam) <= IDC_DNYCTRL_FIRST && LOWORD(wParam) >= IDC_DNYCTRL_LAST) Shouldn't this be:

        if(LOWORD(wParam) <= IDC_DNYCTRL_LAST && LOWORD(wParam) >= IDC_DNYCTRL_FIRST)


        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

        A 1 Reply Last reply
        0
        • D David Crow

          Hockey wrote: if(LOWORD(wParam) <= IDC_DNYCTRL_FIRST && LOWORD(wParam) >= IDC_DNYCTRL_LAST) Shouldn't this be:

          if(LOWORD(wParam) <= IDC_DNYCTRL_LAST && LOWORD(wParam) >= IDC_DNYCTRL_FIRST)


          Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

          A Offline
          A Offline
          alex barylski
          wrote on last edited by
          #4

          Something like that :) I must have typed it with my eyes closed I'm drinking triples, seeing double and acting single :cool:

          1 Reply Last reply
          0
          • Y YaronNir

            Hi all, i have a modal dialog. i've created a button in run-time using new operator to CButton class, and then Create; my question is i want the dialog to catch the pressing of the button or other buttons created at run-time for that matter..... how to do that??? i know i need to use reflection or something like that.. i would like to see some sample code .... Thanks in advanced Yaron Ask not what your application can do for you, Ask what you can do for your application

            Y Offline
            Y Offline
            yndfcd
            wrote on last edited by
            #5

            Add a button on the dialog use dialog editor, and appoint the same ID as you call CButton::Create.Than you can add message handler for that button.After a the message handler has been added, you can delete that button on the dialog, and create it at run-time. Note:using the same ID is crucial. This is very tricky techniques.

            1 Reply Last reply
            0
            • Y YaronNir

              Hi all, i have a modal dialog. i've created a button in run-time using new operator to CButton class, and then Create; my question is i want the dialog to catch the pressing of the button or other buttons created at run-time for that matter..... how to do that??? i know i need to use reflection or something like that.. i would like to see some sample code .... Thanks in advanced Yaron Ask not what your application can do for you, Ask what you can do for your application

              P Offline
              P Offline
              Peter Molnar
              wrote on last edited by
              #6

              Hi Yaron, wouldn't help you to create your button within the dialog editor and hide/show it with ShowWindow(TRUE/FALSE)? Bunburry

              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