File:  [OS/2 SDKs] / pmsdk / samples / clock / clock.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:28:20 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: pmsdk-1989, HEAD
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 ;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.