是用API创建按钮,该怎么处理

是用API创建按钮
C/C++ code

#include <windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,     //当前窗口实例句柄
                     HINSTANCE hPrevInstance, //前一个实例句柄,Win32下为NULL
                     LPSTR     lpCmdLine,     //命令行参数字符
                     int       nCmdShow       //窗口的显示方式
                    )
{
    static TCHAR szAppName[] = TEXT("hellowindow");
    HWND hwnd;
    MSG msg;
    WNDCLASS wndclass;
    wndclass.style = CS_HREDRAW|CS_VREDRAW;
    wndclass.lpfnWndProc = WndProc;
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIcon(NULL,IDI_SHIELD);
    wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName = NULL;
    wndclass.lpszClassName = szAppName;
    if(!RegisterClass(&wndclass))
    {
        MessageBox(NULL,TEXT("注册类失败"),szAppName,MB_ICONERROR);
        return 0;
    }
    int x =((GetSystemMetrics(SM_CXSCREEN)/2)-200);//x剧中
    int y =((GetSystemMetrics(SM_CYSCREEN)/2)-200);//y剧中
    hwnd = CreateWindow(szAppName,TEXT("窗口标题"),WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,x,y,400,400,NULL,NULL,hInstance,NULL);
    ShowWindow(hwnd,nCmdShow);
    UpdateWindow(hwnd);
    while(GetMessage(&msg,NULL,0,0) > 0)
    {
        DispatchMessage(&msg);
    }
    return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    RECT rect;
    switch (message)
    {
    case WM_PAINT:
            hdc = BeginPaint(hwnd,&ps);
            GetClientRect(hwnd,&rect);
            DrawText(hdc,TEXT("输出文本内容为剧中"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
            EndPaint(hwnd,&ps);
            return 0;
    case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    }
    return DefWindowProc(hwnd,message,wparam,lparam);
}


请问窗口创建出来了,如何在窗口上创建按钮呢?


------解决方案--------------------
MSDN.
C/C++ code

hwndButton = CreateWindow( 
    "BUTTON",   // predefined class 
    "OK",       // button text 
    WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,  // styles 
 
    // Size and position values are given explicitly, because 
    // the CW_USEDEFAULT constant gives zero values for buttons. 
    10,         // starting x position 
    10,         // starting y position 
    100,        // button width 
    100,        // button height 
    hwnd,       // parent window 
    NULL,       // No menu 
    (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), 
    NULL);      // pointer not needed

------解决方案--------------------
在WndProc中拦截WM_CREATE,像创建窗口一样创建按钮。



Windows SDK笔记(二):在窗口上建立控件

http://www.vckbase.com/document/viewdoc/?id=1008
------解决方案--------------------
探讨
MSDN.
C/C++ code
hwndButton= CreateWindow("BUTTON",// predefined class"OK",// button text WS_VISIBLE| WS_CHILD| BS_DEFPUSHBUTTON,// styles// Size and position values are given explicitly, because// the CW_USEDEFAULT constant gives zero values for buttons.10,// starting x position10,// starting y position100,// button width100,// button height hwnd,// parent window NULL,// No menu (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),
NULL);// pointer not needed

------解决方案--------------------
探讨
MSDN.
C/C++ code
hwndButton= CreateWindow("BUTTON",// predefined class"OK",// button text WS_VISIBLE| WS_CHILD| BS_DEFPUSHBUTTON,// styles// Size and position values are given explicitly, because// the CW_USEDEFAULT constant gives zero values for buttons.10,// starting x position10,// starting y position100,// button width100,// button height hwnd,// parent window NULL,// No menu (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),