--- pmsdk/samples/petzold/chap02/welcome.c 2018/08/09 12:28:13 1.1 +++ pmsdk/samples/petzold/chap02/welcome.c 2018/08/09 12:28:25 1.1.1.2 @@ -1,41 +1,47 @@ -/*--------------------------------------------------------- - WELCOME.C -- A Program that Writes to its Client Window - ---------------------------------------------------------*/ +/*----------------------------------------------------- + WELCOME.C -- A Program that Creates a Client Window + -----------------------------------------------------*/ +#define INCL_WIN #include MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ; int main (void) { - static CHAR szClientClass [] = "Welcome" ; - HAB hab ; - HMQ hmq ; - HWND hwndFrame, hwndClient ; - QMSG qmsg ; - ULONG flFrameFlags = FCF_STANDARD & ~FCF_MENU ; - ULONG flFrameStyle = WS_VISIBLE ; + static CHAR szClientClass [] = "Welcome" ; + static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | + FCF_SIZEBORDER | FCF_MINMAX | + FCF_SHELLPOSITION | FCF_TASKLIST ; + HAB hab ; + HMQ hmq ; + HWND hwndFrame, hwndClient ; + 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 + 0L, // Class style + 0) ; // Extra bytes to reserve hwndFrame = WinCreateStdWindow ( - HWND_DESKTOP, /* Parent window handle */ - flFrameStyle, /* Style of frame window */ - &flFrameFlags, /* Pointer to control data */ - szClientClass, /* Client window class name */ - "WELCOME Program", /* 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) ; while (WinGetMsg (hab, &qmsg, NULL, 0, 0)) WinDispatchMsg (hab, &qmsg) ; @@ -43,43 +49,10 @@ int main (void) WinDestroyWindow (hwndFrame) ; WinDestroyMsgQueue (hmq) ; WinTerminate (hab) ; - return 0 ; } MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) { - static CHAR szText [] = "Welcome to the OS/2 Presentation Manager" ; - HPS hps; - RECTL rcl ; - - switch (msg) - { - case WM_CREATE: - DosBeep (261, 100) ; - DosBeep (330, 100) ; - DosBeep (392, 100) ; - DosBeep (523, 500) ; - return 0 ; - - case WM_PAINT: - hps = WinBeginPaint (hwnd, NULL, NULL) ; - - WinQueryWindowRect (hwnd, &rcl) ; - - WinDrawText (hps, -1, szText, &rcl, - CLR_NEUTRAL, CLR_BACKGROUND, - DT_CENTER | DT_VCENTER | DT_ERASERECT) ; - - WinEndPaint (hps) ; - return 0 ; - - case WM_DESTROY: - DosBeep (523, 100) ; - DosBeep (392, 100) ; - DosBeep (330, 100) ; - DosBeep (261, 500) ; - return 0 ; - } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }