Thread: Problem with BN_CLICKED!! HELP!!

  1. #1
    BubbleMan
    Guest

    Question Problem with BN_CLICKED!! HELP!!

    Ok, I want to put the BN_CLICKED in an 'if' statement(to check if it was clicked). When I run it though, I get a popup that is supposed to popup only when the button is clicked. Help with the below code please!:

    case WM_CREATE:
    case WM_COMMAND:
    HWND btn;

    btn = CreateWindow(
    "button",
    "Click me",
    WS_CHILD | WS_BORDER | WS_VISIBLE,
    10,
    10,
    50,
    50,
    hwnd,
    (HMENU) 1,
    g_hInst,
    NULL
    );

    if((hwnd, (WPARAM)WM_COMMAND, (LPARAM)BN_CLICKED, btn) != 0)
    {
    MessageBox(hwnd, "Hello", "Greetings", MB_OK + MB_SYSTEMMODAL);
    }
    break;
    break;

  2. #2
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125
    Hi try this

    case WM_COMMAND:
    switch (LOWORD (wParam))
    {
    case ID_BN_CLICKED:
    MessageBox(hwnd, "Hello", "Greetings", MB_OK + MB_SYSTEMMODAL);
    break;
    }

  3. #3
    BubbleMan
    Guest

    Post Didn't work..

    When I use case WM_COMMAND:
    switch(LOWORD(wParam))

    The button won't even show up.

  4. #4
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125
    hey sorry it took me so long to reply, i have been really buisy

    i suspect that it didnt work because you are not breaking the case before your "paint" or "create" case's . anyway here is a WndProc that will show a button and display a msgbox when it is clicked.

    *****************************
    //make these global
    #define ID_CONNBUT 10
    HWND ConnBut;

    LRESULT CALLBACK WndProc(HWND hWnd,UINT messg, WPARAM wParam,LPARAM lParam)
    {

    HDC hdc ;
    HINSTANCE hInstance ;
    int x, y ;
    PAINTSTRUCT ps ;

    switch (messg)
    {

    case WM_CREATE:

    ConnBut = CreateWindowEx(WS_EX_STATICEDGE, "Button","Connect",WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT, 0,0,100,25, hWnd, (HMENU)ID_CONNBUT,g_hInst, 0);//connbut


    break;

    case WM_PAINT:
    hdc = BeginPaint (hWnd, &ps) ;


    EndPaint (hWnd, &ps) ;

    break;


    case WM_DESTROY:
    PostQuitMessage(0);
    break;

    case WM_COMMAND:
    switch (LOWORD (wParam))
    {
    case ID_CONNBUT:
    MessageBox(NULL,"TEXT","TITLE",NULL);
    break;
    }


    default:
    return(DefWindowProc(hWnd,messg,wParam,lParam));
    break;
    }

    return(0);

    }
    ***************************

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Try

    //*******************************
    case WM_COMMAND:

    idControl=GET_WM_COMMAND_ID(wParam,lParam) ;
    switch(idControl)
    {
    //*******************************
    //*******************************
    case IDC_SIDE:
    if(HIWORD(wParam)==BN_CLICKED)
    {

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM