--- pmsdk/samples/petzold/chap03/welcome2.c 2018/08/09 12:28:13 1.1 +++ pmsdk/samples/petzold/chap03/welcome2.c 2018/08/09 12:28:28 1.1.1.2 @@ -2,61 +2,70 @@ WELCOME2.C -- A Program that Creates Two Top-Level Windows ------------------------------------------------------------*/ +#define INCL_WIN #include -#include MRESULT EXPENTRY Client1WndProc (HWND, USHORT, MPARAM, MPARAM) ; MRESULT EXPENTRY Client2WndProc (HWND, USHORT, MPARAM, MPARAM) ; int main (void) { - static CHAR szClientClass1 [] = "Welcome1", - szClientClass2 [] = "Welcome2" ; - HAB hab ; - HMQ hmq ; - HWND hwndFrame1, hwndFrame2, hwndClient1, hwndClient2 ; - QMSG qmsg ; - ULONG flFrameFlags = FCF_STANDARD & ~FCF_MENU ; - ULONG flFrameStyle = WS_VISIBLE ; + static CHAR szClientClass1 [] = "Welcome2.1", + szClientClass2 [] = "Welcome2.2" ; + static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | + FCF_SIZEBORDER | FCF_MINMAX | + FCF_SHELLPOSITION | FCF_TASKLIST ; + HAB hab ; + HMQ hmq ; + HWND hwndFrame1, hwndFrame2, hwndClient1, hwndClient2 ; + QMSG qmsg ; hab = WinInitialize (0) ; hmq = WinCreateMsgQueue (hab, 0) ; WinRegisterClass ( - hab, /* Anchor block handle */ - szClientClass1, /* Name of class being registered */ - Client1WndProc, /* Window procedure for class */ - CS_SIZEREDRAW, /* Class style */ - 0) ; /* Extra bytes to reserve */ + hab, // Anchor block handle + szClientClass1, // Name of class being registered + Client1WndProc, // Window procedure for class + CS_SIZEREDRAW, // Class style + 0) ; // Extra bytes to reserve WinRegisterClass ( - hab, /* Anchor block handle */ - szClientClass2, /* Name of class being registered */ - Client2WndProc, /* Window procedure for class */ - CS_SIZEREDRAW, /* Class style */ - 0) ; /* Extra bytes to reserve */ + hab, // Anchor block handle + szClientClass2, // Name of class being registered + Client2WndProc, // Window procedure for class + CS_SIZEREDRAW, // Class style + 0) ; // Extra bytes to reserve hwndFrame1 = WinCreateStdWindow ( - HWND_DESKTOP, /* Parent window handle */ - flFrameStyle, /* Style of frame window */ - &flFrameFlags, /* Pointer to control data */ - szClientClass1, /* Client window class name */ - "Window No. 1", /* Title bar text */ - 0L, /* Style of client window */ - NULL, /* Module handle for resources */ - 0, /* ID of resources */ - &hwndClient1) ; /* Pointer to client window handle */ + HWND_DESKTOP, // Parent window handle + WS_VISIBLE, // Style of frame window + &flFrameFlags, // Pointer to control data + szClientClass1, // Client window class name + NULL, // Title bar text + 0L, // Style of client window + NULL, // Module handle for resources + 0, // ID of resources + &hwndClient1) ; // Pointer to client window handle hwndFrame2 = WinCreateStdWindow ( - HWND_DESKTOP, /* Parent window handle */ - flFrameStyle, /* Style of frame window */ - &flFrameFlags, /* Pointer to control data */ - szClientClass2, /* Client window class name */ - "Window No. 2", /* Title bar text */ - 0L, /* Style of client window */ - NULL, /* Module handle for resources */ - 0, /* ID of resources */ - &hwndClient2) ; /* Pointer to client window handle */ + HWND_DESKTOP, // Parent window handle + WS_VISIBLE, // Style of frame window + &flFrameFlags, // Pointer to control data + szClientClass2, // Client window class name + " - Window No. 2", // Title bar text + 0L, // Style of client window + NULL, // Module handle for resources + 0, // ID of resources + &hwndClient2) ; // Pointer to client window handle + + WinSendMsg (hwndFrame1, WM_SETICON, + WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE), + NULL) ; + + WinSendMsg (hwndFrame2, WM_SETICON, + WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE), + NULL) ; while (WinGetMsg (hab, &qmsg, NULL, 0, 0)) WinDispatchMsg (hab, &qmsg) ; @@ -65,7 +74,6 @@ int main (void) WinDestroyWindow (hwndFrame2) ; WinDestroyMsgQueue (hmq) ; WinTerminate (hab) ; - return 0 ; } @@ -82,8 +90,7 @@ MRESULT EXPENTRY Client1WndProc (HWND hw 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) ; @@ -105,8 +112,7 @@ MRESULT EXPENTRY Client2WndProc (HWND hw 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) ;