Monday, February 21, 2011

Win32 API - Create Button help

I try to create 2 buttons inside my app

case WM_CREATE:{
    hWnd =CreateWindowEx(NULL,
            L"BUTTON",
            L"Giai PTB2",
            WS_TABSTOP|WS_VISIBLE|
            WS_CHILD|BS_DEFPUSHBUTTON,
            100,
            100,
            100,
            24,
            hWnd,
            (HMENU)IDC_PTB2_BUTTON,
            hInst,
            NULL);
    HWND hWndNew =CreateWindowEx(NULL,
            L"BUTTON",
            L"Tim max",
            WS_TABSTOP|WS_VISIBLE|
            WS_CHILD|BS_DEFPUSHBUTTON,
            200,
            200,
            100,
            100,
            hWnd,
            (HMENU)IDC_PTB2_BUTTON2,
            hInst,
            NULL);
    break;
               }

The problem is , only "Giai PTB2" button shows :) Thanks first :)

From stackoverflow
  • check hWnd .. you are changing is value by the first create the side effect is that you are passing the first button as parent of the second ...

    jpyllman : And by that creating the second button inside the first button. And also hWnd is probalby your handle for the main window. So you loose that handle and doing other things wrong too.
    nXqd : Thanks it does help :)

0 comments:

Post a Comment