Thread: BN_CLICKED button message

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    BN_CLICKED button message

    I have a win32 form, and a button on it. But I have 1 problem, how do I know when the user clicks the button?

    I have this code so far:

    Code:
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message)                  /* handle the messages */
        {
        	case WM_COMMAND:
                if ((HWND) lParam == hwnd2)
                {
                    DeleteFile("Copy of Test.txt");
                }
                break;
    
            case WM_DESTROY:
                PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                break;
            default:                      /* for messages that we don't deal with */
                return DefWindowProc (hwnd, message, wParam, lParam);
        }
    
        return 0;
    }
    Look at the case WM_COMMAND case. That works perfectly, I can tell what button is pressed and do actions acordingly. But I am wondering is that correct? Slow? And is there a better more effecient way?

    Also the topic title says BN_CLICKED, but that doesn't work and msdn says it sends BN_CLICKED in the form of WM_COMMAND.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Correct. wParam contains the control ID.

    Kuphryn

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Thanks! I actaully did somthing correct on my own!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Custom button using bitmaps
    By Eirik in forum Windows Programming
    Replies: 2
    Last Post: 11-04-2008, 12:20 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. C Programming 2d Array Question
    By jeev2005 in forum C Programming
    Replies: 3
    Last Post: 04-26-2006, 03:18 PM
  4. input/output
    By dogbert234 in forum Windows Programming
    Replies: 11
    Last Post: 01-26-2005, 06:57 AM