A simple button and WM_COMMAND

This is a discussion on A simple button and WM_COMMAND within the Windows Programming forums, part of the Platform Specific Boards category; here's my code.. Code: case WM_COMMAND: switch(HIWORD(wParam)) { case BN_CLICKED: MessageBox(hwnd,"Button is Clicked","BTN WND",MB_ICONINFORMATION); break; } return 0; // Created ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    610

    A simple button and WM_COMMAND

    here's my code..
    Code:
    	case WM_COMMAND:	
    		switch(HIWORD(wParam))
    		{
    		case BN_CLICKED:		
    			MessageBox(hwnd,"Button is Clicked","BTN WND",MB_ICONINFORMATION);
    			break;
    		}
    		return 0;
    
    // Created a button...
    CreateButton(hwnd,cs->hInstance,BS_DEFPUSHBUTTON,initRecArea(305,320,150,30),
    			IDBC_DEFPUSHBUTTON,_T("DISPLAY"));
    As soon as i run the program, the message "Button is Clicked" appears whether or not the button is pressed! Anything wrong with my code?

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Sorry guys, was quick to ask before thinking more... Figured out the solution to the problem...

    Code:
    	case WM_COMMAND:
    		if (LOWORD(wParam) == IDBC_DEFPUSHBUTTON) {
    			MessageBox(hwnd,"Button is Clicked","BTN WND",MB_ICONINFORMATION);
    		}
    		return 0;

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    Read the Petzold, MSDN, and learn how to search on Google Groups.
    Your questions are really too childish.

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Alex31 View Post
    Read the Petzold, MSDN, and learn how to search on Google Groups.
    Your questions are really too childish.
    Google groups is blocked from work... Tried it, which is why i always ended up here... I started Win32 API programming last month and through cboard i've learned a lot. Sometimes i get completely stuck and as a new API developer i can't easily figure out things as u may... I'm greatfull for people who have answered my queries without questioning my childish knowledge.. Like now, i have a question but your comment has raised doubts!...

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    Ask your questions. Most people will either help you thru your code or point you in the direction of reference and/or tutorials without the sarcasm.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Oldman47 View Post
    Ask your questions. Most people will either help you thru your code or point you in the direction of reference and/or tutorials without the sarcasm.
    Agreed - however, getting Charles Petzold's book is sound advice, as it's well written, and explains API in it's concept with many examples.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by matsp View Post
    Agreed - however, getting Charles Petzold's book is sound advice, as it's well written, and explains API in it's concept with many examples.

    --
    Mats
    I've ordered a book three weeks ago, just check't the progress to my surprise it' the same book you guys are talking about! Coincidence working at best!

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    317
    Code:
    #define YOURBUTTONID 1001
    in CreateWindow , look for the hmenu parameter and do this
    (HMENU)YOURBUTTONID;
    it should be , 
    switch(wParam)
    {
    case YOURBUTTONID: 
    }

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21