CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Button

  1. #1
    Join Date
    May 1999
    Posts
    20

    Button

    Hello.

    I only need to know how i can know when a standard button is be clicked.

    i though it will be like this


    void Claden::Onladen()

    {

    while not (OKbuttonpressed); // then wait if it pressed then go further in this function...


    }



    plz help me out thx...





  2. #2
    Join Date
    May 1999
    Posts
    48

    Re: Button

    The parrent's button receives one WM_COMMAND message. In MFC the button, send to itself a reflected message WM_NOTIFY, BN_CLICKED.
    Sincerely, Mihai



  3. #3
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Button

    Mihai is correct. There is a little more to the story though. There
    are several messages sent during the process of clicking a button.
    Typically, the actual command message of being clicked is not sent
    until the button is released. You can also catch the push and release
    notifications if you want. They are WM_COMMAND messages with
    notify codes of BN_PUSHED and BN_UNPUSHED respectively.





  4. #4
    Join Date
    May 1999
    Posts
    20

    Re: Button

    how can i connect a WM_COMMAND with my button?


  5. #5
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Button

    The simplest method is to make an OnCmdMsg handler in the dialog
    that contains the button. The class wizard can do this for you. Its
    arguments will be OnCmdMsg( UINT nID, int nCode, void* pExtra,
    AFX_CMDHANDLERINFO* pHandlerInfo ) so you can identify whether
    the id matches your button and what the notify code is.

    If your button's code is contained in its own class you will probably
    need to use ON_CONTROL_REFLECT. See TN062 for more info
    on this. I have never used it so I can't help very much on this.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured