|
|
Microsoft OS/2 SDK PM 02-24-1989
/*
clock.c Presentation Manager Analog Clock Application
Created by Microsoft Corporation, 1989
*/
#define INCL_PM
#include <os2.h>
#include <string.h>
#include "res.h"
extern MRESULT CALLBACK ClkWndProc ( HWND , USHORT , MPARAM , MPARAM ) ;
int cdecl main ( int argc , char * argv [ ] ) ;
BOOL ClkInit ( VOID ) ;
HWND hwndFrame ;
HAB hab ;
HMQ hmq ;
HSWITCH hsw ;
extern HPS hps ;
BOOL fStartAsIcon = FALSE ;
/*
main(argc, argv) Main program
*/
int cdecl main ( int argc , char * argv [ ] )
{
QMSG qmsg ;
/* have we been asked to start ourselves as an icon? */
if (argc > 0) {
if ( strcmpi ( argv [ 1 ] , "iconic" ) == 0 )
fStartAsIcon = TRUE ;
}
if ( ClkInit ( ) ) {
while ( WinGetMsg ( hab , & qmsg , NULL , 0 , 0 ) )
WinDispatchMsg ( hab , & qmsg ) ;
/* Clean up code */
GpiDestroyPS( hps );
WinRemoveSwitchEntry ( hsw ) ;
WinDestroyWindow ( hwndFrame ) ;
WinDestroyMsgQueue ( hmq ) ;
WinTerminate ( hab ) ;
}
return 0 ;
}
/*
ClkInit() Clock Initialization routine
Returns TRUE if successful.
*/
BOOL ClkInit ( )
{
/* application name, switch list info, and frame creation flags */
static PSZ pszClkName = "Clock" ;
static SWCNTRL swctl = { 0 , 0 , 0 , 0 , 0 , SWL_VISIBLE ,
SWL_JUMPABLE , "Clock" , 0 } ;
static LONG fcf = FCF_SIZEBORDER | FCF_TITLEBAR | FCF_MINMAX
| FCF_SYSMENU ;
HWND hwndClient ;
PID pid ;
TID tid ;
if ( ( hab = WinInitialize ( NULL ) ) == NULL )
return FALSE ;
if ( ( hmq = WinCreateMsgQueue ( hab , NULL ) ) == NULL ) {
WinTerminate ( hab ) ;
return FALSE ;
}
if ( ! WinRegisterClass ( hab , pszClkName , ClkWndProc ,
CS_SIZEREDRAW , 0 ) ) {
WinDestroyMsgQueue ( hmq ) ;
WinTerminate ( hab ) ;
return FALSE ;
}
hwndFrame = WinCreateStdWindow ( HWND_DESKTOP , ( ULONG ) NULL , & fcf ,
pszClkName , pszClkName , WS_VISIBLE ,
NULL , ID_RESOURCE , & hwndClient ) ;
if ( hwndFrame == NULL ) {
WinDestroyMsgQueue ( hmq ) ;
WinTerminate ( hab ) ;
return FALSE ;
}
/* add ourselves to the switch list */
WinQueryWindowProcess ( hwndFrame , & pid , & tid ) ;
swctl . hwnd = hwndFrame ;
swctl . idProcess = pid ;
hsw = WinAddSwitchEntry ( & swctl ) ;
return TRUE ;
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.