Creating a Window – 1 call, 11 parms

      (Overhead Creating a Window)

        creates a window for the application

 

HWND CreateWindow

                         (LPCSTR  lpClassName,  // ptr to string classname

                             LPCSTR lpWindowName,    // ptr to windows title

                             DWORD    dwStyle,       // properties flags

                             int               x,         // x coord of window

                           int              y,                  // y coord of window

                           int              nWidth,        // window width

                           int              nHeight,       // window height

                            HWND      hWndParent,   // handle to parent

                             HMENU    hMenu,           // handle to menu

                             HANDLE  hinstance,      // app. handle

                             LPVOID    lpParam);        // creation parms

dwStyle is:

 

Value

Meaning

WS_OVERLAPPED

overlapped with borders

WS_OVERLAPPEDWINDOW

standard window

WS_POPUP

simple popup window

WS_POPUPWINDOW

popup with menus & borders

WS_VISIBLE

initially visible window

no ShowWindow() call needed

WS_VSCROLL

window w/vert scroll bar

WS_HSCROLL

window w/horiz scroll bar

WS_MAXIMIZED

initially maximized

WS_MINIMIZED

initiall minimized

 

BOOL ShowWindow(HWND hWnd, int nCmdShow);

SW_SHOW, SW_HIDE, SW_RESTORE, SW_MAXIMIZE, SW_MINIMIZED, SW_SHOWMAXIMIZED/MINIMIZED

 

BOOL UpdateWindow(HWND hWnd); // repaint  

    
Example:

HWND MyWindow = CreateWindow

                     (WINDOW_CLASS_NAME,    // class

                        "My First Window",                   // title

                        WS_OVERLAPPEDWINDOW | WS_VISIBLE,

                        CW_USEDEFAULT, CW_USEDEFAULT, // x,y

                        CW_USEDEFAULT, CW_USEDEFAULT, // size

                        NULL,                                       // handle to parent

                       NULL,                                         // handle to menu

                        hinstance,                          // Win instance – set in WinMain

                        NULL);                                    // creation parms