Creating a Button Outside a Dialog Box

The following example shows how to use the CreateWindow function to create a default push button.

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