--- pmsdk/samples/petzold/chap03/welcome3.c 2018/08/09 12:28:13 1.1 +++ pmsdk/samples/petzold/chap03/welcome3.c 2018/08/09 12:28:27 1.1.1.2 @@ -3,82 +3,95 @@ -----------------------------------------------------------*/ #define INCL_WIN - #include -#include MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ; MRESULT EXPENTRY ChildWndProc (HWND, USHORT, MPARAM, MPARAM) ; int main (void) { - static CHAR szClientClass [] = "Welcome3" ; - static CHAR szChildClass [] = "Welcome3.Child" ; - HAB hab ; - HMQ hmq ; - HWND hwndFrame, hwndChildFrame1, hwndChildFrame2, - hwndClient, hwndChildClient1, hwndChildClient2 ; - QMSG qmsg ; - ULONG flFrameFlags = FCF_STANDARD & ~FCF_MENU ; - ULONG flFrameStyle = WS_VISIBLE ; + static CHAR szClientClass [] = "Welcome3", + szChildClass [] = "Welcome3.Child" ; + static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | + FCF_SIZEBORDER | FCF_MINMAX | + FCF_SHELLPOSITION | FCF_TASKLIST ; + HAB hab ; + HMQ hmq ; + HWND hwndFrame, hwndChildFrame1, hwndChildFrame2, + hwndClient, hwndChildClient1, hwndChildClient2 ; + QMSG qmsg ; hab = WinInitialize (0) ; hmq = WinCreateMsgQueue (hab, 0) ; WinRegisterClass ( - hab, /* Anchor block handle */ - szClientClass, /* Name of class being registered */ - ClientWndProc, /* Window procedure for class */ - CS_SIZEREDRAW, /* Class style */ - 0) ; /* Extra bytes to reserve */ + hab, // Anchor block handle + szClientClass, // Name of class being registered + ClientWndProc, // Window procedure for class + CS_SIZEREDRAW, // Class style + 0) ; // Extra bytes to reserve WinRegisterClass ( - hab, /* Anchor block handle */ - szChildClass, /* Name of class being registered */ - ChildWndProc, /* Window procedure for class */ - CS_SIZEREDRAW, /* Class style */ - sizeof (PVOID)) ; /* Extra bytes to reserve */ + hab, // Anchor block handle + szChildClass, // Name of class being registered + ChildWndProc, // Window procedure for class + CS_SIZEREDRAW, // Class style + sizeof (PVOID)) ; // Extra bytes to reserve /*------------------------- Create top-level window -------------------------*/ hwndFrame = WinCreateStdWindow ( - HWND_DESKTOP, /* Parent window handle */ - flFrameStyle, /* Style of frame window */ - &flFrameFlags, /* Pointer to control data */ - szClientClass, /* Client window class name */ - "Top-Level Window", /* Title bar text */ - 0L, /* Style of client window */ - NULL, /* Module handle for resources */ - 0, /* ID of resources */ - &hwndClient) ; /* Pointer to client window handle */ + HWND_DESKTOP, // Parent window handle + WS_VISIBLE, // Style of frame window + &flFrameFlags, // Pointer to control data + szClientClass, // Client window class name + NULL, // Title bar text + 0L, // Style of client window + NULL, // Module handle for resources + 0, // ID of resources + &hwndClient) ; // Pointer to client window handle + + WinSendMsg (hwndFrame, WM_SETICON, + WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE), + NULL) ; /*-------------------------- Create two child windows --------------------------*/ + flFrameFlags &= ~FCF_TASKLIST ; + hwndChildFrame1 = WinCreateStdWindow ( - hwndClient, /* Parent window handle */ - flFrameStyle, /* Style of frame window */ - &flFrameFlags, /* Pointer to control data */ - szChildClass, /* Client window class name */ - "Child No. 1", /* Title bar text */ - 0L, /* Style of client window */ - NULL, /* Module handle for resources */ - 0, /* ID of resources */ - &hwndChildClient1) ;/* Pointer to client window handle */ + hwndClient, // Parent window handle + WS_VISIBLE, // Style of frame window + &flFrameFlags, // Pointer to control data + szChildClass, // Client window class name + "Child No. 1", // Title bar text + 0L, // Style of client window + NULL, // Module handle for resources + 0, // ID of resources + &hwndChildClient1) ;// Pointer to client window handle hwndChildFrame2 = WinCreateStdWindow ( - hwndClient, /* Parent window handle */ - flFrameStyle, /* Style of frame window */ - &flFrameFlags, /* Pointer to control data */ - szChildClass, /* Client window class name */ - "Child No. 2", /* Title bar text */ - 0L, /* Style of client window */ - NULL, /* Module handle for resources */ - 0, /* ID of resources */ - &hwndChildClient2) ;/* Pointer to client window handle */ + hwndClient, // Parent window handle + WS_VISIBLE, // Style of frame window + &flFrameFlags, // Pointer to control data + szChildClass, // Client window class name + "Child No. 2", // Title bar text + 0L, // Style of client window + NULL, // Module handle for resources + 0, // ID of resources + &hwndChildClient2) ;// Pointer to client window handle + + WinSendMsg (hwndChildFrame1, WM_SETICON, + WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE), + NULL) ; + + WinSendMsg (hwndChildFrame2, WM_SETICON, + WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE), + NULL) ; /*----------------------------------------------------- Set reserved area of window to text string pointers @@ -93,7 +106,6 @@ int main (void) WinDestroyWindow (hwndFrame) ; WinDestroyMsgQueue (hmq) ; WinTerminate (hab) ; - return 0 ; } @@ -110,8 +122,7 @@ MRESULT EXPENTRY ClientWndProc (HWND hwn WinQueryWindowRect (hwnd, &rcl) ; - WinDrawText (hps, -1, szText, &rcl, - CLR_NEUTRAL, CLR_BACKGROUND, + WinDrawText (hps, -1, szText, &rcl, CLR_NEUTRAL, CLR_BACKGROUND, DT_CENTER | DT_VCENTER | DT_ERASERECT) ; WinEndPaint (hps) ; @@ -122,8 +133,8 @@ MRESULT EXPENTRY ClientWndProc (HWND hwn MRESULT EXPENTRY ChildWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) { - HPS hps ; - RECTL rcl ; + HPS hps ; + RECTL rcl ; switch (msg) {