|
|
1.1 root 1: /*
2: clock.c Presentation Manager Analog Clock Application
3: Created by Microsoft Corporation, 1989
4: */
5: #define INCL_PM
6: #include <os2.h>
7: #include <string.h>
8: #include "res.h"
9:
10: extern MRESULT CALLBACK ClkWndProc ( HWND , USHORT , MPARAM , MPARAM ) ;
11:
12: int cdecl main ( int argc , char * argv [ ] ) ;
13: BOOL ClkInit ( VOID ) ;
14: HWND hwndFrame ;
15: HAB hab ;
16: HMQ hmq ;
17: HSWITCH hsw ;
18: extern HPS hps ;
19: BOOL fStartAsIcon = FALSE ;
20:
21: /*
22: main(argc, argv) Main program
23: */
24: int cdecl main ( int argc , char * argv [ ] )
25: {
26: QMSG qmsg ;
27:
28: /* have we been asked to start ourselves as an icon? */
29: if (argc > 0) {
30: if ( strcmpi ( argv [ 1 ] , "iconic" ) == 0 )
31: fStartAsIcon = TRUE ;
32: }
33:
34: if ( ClkInit ( ) ) {
35:
36: while ( WinGetMsg ( hab , & qmsg , NULL , 0 , 0 ) )
37: WinDispatchMsg ( hab , & qmsg ) ;
38:
39: /* Clean up code */
40: GpiDestroyPS( hps );
41: WinRemoveSwitchEntry ( hsw ) ;
42: WinDestroyWindow ( hwndFrame ) ;
43: WinDestroyMsgQueue ( hmq ) ;
44: WinTerminate ( hab ) ;
45: }
46:
47: return 0 ;
48: }
49:
50: /*
51: ClkInit() Clock Initialization routine
52: Returns TRUE if successful.
53: */
54: BOOL ClkInit ( )
55: {
56: /* application name, switch list info, and frame creation flags */
57: static PSZ pszClkName = "Clock" ;
58: static SWCNTRL swctl = { 0 , 0 , 0 , 0 , 0 , SWL_VISIBLE ,
59: SWL_JUMPABLE , "Clock" , 0 } ;
60: static LONG fcf = FCF_SIZEBORDER | FCF_TITLEBAR | FCF_MINMAX
61: | FCF_SYSMENU ;
62:
63: HWND hwndClient ;
64: PID pid ;
65: TID tid ;
66:
67: if ( ( hab = WinInitialize ( NULL ) ) == NULL )
68: return FALSE ;
69:
70: if ( ( hmq = WinCreateMsgQueue ( hab , NULL ) ) == NULL ) {
71: WinTerminate ( hab ) ;
72: return FALSE ;
73: }
74:
75: if ( ! WinRegisterClass ( hab , pszClkName , ClkWndProc ,
76: CS_SIZEREDRAW , 0 ) ) {
77: WinDestroyMsgQueue ( hmq ) ;
78: WinTerminate ( hab ) ;
79: return FALSE ;
80: }
81:
82: hwndFrame = WinCreateStdWindow ( HWND_DESKTOP , ( ULONG ) NULL , & fcf ,
83: pszClkName , pszClkName , WS_VISIBLE ,
84: NULL , ID_RESOURCE , & hwndClient ) ;
85:
86: if ( hwndFrame == NULL ) {
87: WinDestroyMsgQueue ( hmq ) ;
88: WinTerminate ( hab ) ;
89: return FALSE ;
90: }
91:
92: /* add ourselves to the switch list */
93: WinQueryWindowProcess ( hwndFrame , & pid , & tid ) ;
94: swctl . hwnd = hwndFrame ;
95: swctl . idProcess = pid ;
96: hsw = WinAddSwitchEntry ( & swctl ) ;
97:
98: return TRUE ;
99: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.