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. Basic Question

Basic Question

Scheduled Pinned Locked Moved C / C++ / MFC
5 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.
  • G Offline
    G Offline
    Gupta Suraj
    wrote on last edited by
    #1

    Hi All, If I place a button in a dialog box, my perception is that the button should be the part of my dialog class. But when I see my dialog box there is no Button object. How can I access that Button object. I need that object because I want to enable and disable that button according to some condition. I also want to attach toottip to that button. Please let me know if further clarification is required.

    Suraj

    C P R 3 Replies Last reply
    0
    • G Gupta Suraj

      Hi All, If I place a button in a dialog box, my perception is that the button should be the part of my dialog class. But when I see my dialog box there is no Button object. How can I access that Button object. I need that object because I want to enable and disable that button according to some condition. I also want to attach toottip to that button. Please let me know if further clarification is required.

      Suraj

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Gupta Suraj wrote:

      How can I access that Button object. I need that object because I want to enable and disable that button according to some condition.

      You need to associate a variable with the button (how to do this depends of which IDE you are using). The variable type must be a CButton in order to access functionalities of your button.


      Cédric Moonen Software developer
      Charting control [v1.1]

      K 1 Reply Last reply
      0
      • C Cedric Moonen

        Gupta Suraj wrote:

        How can I access that Button object. I need that object because I want to enable and disable that button according to some condition.

        You need to associate a variable with the button (how to do this depends of which IDE you are using). The variable type must be a CButton in order to access functionalities of your button.


        Cédric Moonen Software developer
        Charting control [v1.1]

        K Offline
        K Offline
        ksrameshkanth
        wrote on last edited by
        #3

        Other way is.... CWnd *pWnd = GetDlgItem( IDC_BUTTON/* Ur Button ID */); pWnd->EnableWindow( FALSE );//Disable the button pWnd->EnableWindow( TRUE );//Enable the button

        1 Reply Last reply
        0
        • G Gupta Suraj

          Hi All, If I place a button in a dialog box, my perception is that the button should be the part of my dialog class. But when I see my dialog box there is no Button object. How can I access that Button object. I need that object because I want to enable and disable that button according to some condition. I also want to attach toottip to that button. Please let me know if further clarification is required.

          Suraj

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          Gupta Suraj wrote:

          my perception is that the button should be the part of my dialog class.

          Dialog class will be based on dilaog template resource, button would be part of that resource.

          Gupta Suraj wrote:

          How can I access that Button object. I need that object because I want to enable and disable that button according to some condition.

          Apart from method Cedric has suggested, you can use GetDlgItem function for accessing controls on dialog,too.

          GetDlgItem(IDC_MYBUTTON)->EnableWindow(FALSE);

          Prasad Notifier using ATL | Operator new[],delete[][^]

          1 Reply Last reply
          0
          • G Gupta Suraj

            Hi All, If I place a button in a dialog box, my perception is that the button should be the part of my dialog class. But when I see my dialog box there is no Button object. How can I access that Button object. I need that object because I want to enable and disable that button according to some condition. I also want to attach toottip to that button. Please let me know if further clarification is required.

            Suraj

            R Offline
            R Offline
            Ranjoy Guha
            wrote on last edited by
            #5

            If u r using VC++ Put the button in the Dialog. Right Click on it and select "add variable" Select access type (public/private) Select Variable type (CButton) Give a variable name (ex: m_buttonHello) Now in the source file (.cpp) for dialog class write: m_buttonHello.EnableWindow(TRUE) or m_buttonHello.EnableWindow(FALSE) wherever necessary Cheers ;)

            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