home *** CD-ROM | disk | FTP | other *** search
- $DEFINE KERNEL
- $DEFINE USER
- $DEFINE GDI
- $DEFINE MSG
- $DEFINE MENUS
- $DEFINE SYSMETRICS
- $DEFINE WINMESSAGES
- $DEFINE WINSTYLES
- $DEFINE RESOURCE
- INCLUDE 'WINDOWS.FI'
- C
- C Author : Kevin B Black
- C Date written : 23-Oct-1991
- C Abstract :
- C
- C FORTRAN WINDOWS 3.0 DIGITAL/ANALOGUE CLOCK
- C
- C WinMain - Main Windows 3.0 function for FWCLOCK
- C
- FUNCTION WinMain[PASCAL,FAR] (hInstance,hPrevInstance,
- * IpCmdLine,nCmdShow)
- IMPLICIT NONE
-
- INTEGER*2 WinMain
- INTEGER*2 hInstance ! current instance
- INTEGER*2 hPrevInstance ! previous instance
- INTEGER*4 IpCmdLine ! command line
- INTEGER*2 nCmdShow ! show-window type (open/icon)
-
- INCLUDE 'WINDOWS.FD'
- INTEGER*2 InitFWClock [EXTERN,FAR]
- INCLUDE 'FWCLOCK.FD'
-
- INTEGER*2 JUNK ! Dummy argument for 100ths seconds for GETTIM
-
- RECORD /MSG/ Wmsg ! message
-
- IF(hPrevInstance.EQ.0)THEN ! Other instances of app running?
- IF(InitFWClock(hInstance).EQ.0)THEN ! Initialize shared things
- WinMain=0 ! Exits if unable to initialize
- RETURN
- ENDIF
- ENDIF
- C
- C Perform initializations that apply to this specific instance
- C
- HINST=HINSTANCE
- c IMANICON=.FALSE.
- C
- C Determine the display device size and its aspect ratio
- C
- FWCPS.HDC=GetDC(NULL) ! Get device context
- DWIDTH=GetDeviceCaps(FWCPS.HDC,VERTRES)
- DHEIGHT=GetDeviceCaps(FWCPS.HDC,HORZRES)
- HASPECT=(DHEIGHT*1000/(GetDeviceCaps(FWCPS.HDC,HORZSIZE)*10)+5)/10
- VASPECT=(DWIDTH*1000/(GetDeviceCaps(FWCPS.HDC,VERTSIZE)*10)+5)/10
- VARATIO=FLOAT(VASPECT)/FLOAT(HASPECT)
- WSTATUS=ReleaseDC(NULL,FWCPS.HDC)
- C
- C Determine height and width to which the clock window is to be set, the
- C various bit around the work area are added on to make the window the
- C appropriate size (the work area is then a square)
- C
- WWIDTH=DWIDTH/2+
- * GetSystemMetrics(SM_CXFRAME)*2
- WHEIGHT=WWIDTH*VASPECT/HASPECT+
- * GetSystemMetrics(SM_CYCAPTION)+
- * GetSystemMetrics(SM_CYFRAME)*2
- RCLOCK.TOP=1
- RCLOCK.LEFT=1
- RCLOCK.BOTTOM=WHEIGHT
- RCLOCK.RIGHT=WWIDTH
- C
- C Create the main FWClock window and get its handle.
- C
- HWND=CreateWindow(
- * 'FWClockWClass'C, ! Window class
- * 'FWClock'C, ! Text for window title bar
- * WS_OVERLAPPEDWINDOW, ! Window style
- * CW_USEDEFAULT, ! Default horizontal position
- * CW_USEDEFAULT, ! Default vertical position
- * WWIDTH, ! Default width
- * WHEIGHT, ! Default height
- * NULL, ! No parent
- * NULL, ! Use the window class menu
- * hInstance, ! This instance owns this window
- * NULLSTR) ! Pointer not needed
- C
- C Read user selectable functions from profile file and check menu items if
- C enabled
- C
- SECONDSICON=0.NE.GetPrivateProfileInt('FWClock'C,'SecondsInIcon'C,
- * 0,'FWCLOCK.INI'C)
- IF(SECONDSICON)WSTATUS=CheckMenuItem(GetMenu(hWnd),
- * IDM_SECONDSICON,MF_CHECKED)
- SOLIDHANDS=0.NE.GetPrivateProfileInt('FWClock'C,'SolidHands'C,
- * 0,'FWCLOCK.INI'C)
- IF(SOLIDHANDS)WSTATUS=CheckMenuItem(GetMenu(hWnd),
- * IDM_SOLIDHANDS,MF_CHECKED)
- CHIMES=0.NE.GetPrivateProfileInt('FWClock'C,'Chimes'C,
- * 0,'FWCLOCK.INI'C)
- IF(CHIMES)WSTATUS=CheckMenuItem(GetMenu(hWnd),
- * IDM_CHIMES,MF_CHECKED)
- C
- C Get the current time, wait until the seconds change.
- C
- CALL GETTIM(HOURS,MINS,SECS,JUNK)
- CALL GETTIM(OHOURS,OMINS,OSECS,JUNK)
- DO WHILE (HOURS.EQ.OHOURS.AND.MINS.EQ.OMINS.AND.SECS.EQ.OSECS)
- CALL GETTIM(OHOURS,OMINS,OSECS,JUNK)
- ENDDO
- C
- C Create general tools
- C
- CALL TOOL_UP
- C
- C Start a timer for a open window every 200 milliseconds
- C
- IF(SetTimer(hWnd,MYTIMER,200,0).EQ.0)THEN
- CALL FatalAppExit(0,'FWClock: All public timers in use'C)
- STOP
- ENDIF
- C
- C Show window and acquire and dispatch messages until a WM_QUIT message
- C is received.
- C
- WSTATUS=ShowWindow(hWnd,nCmdShow) ! Show the window
- DO WHILE (GetMessage(Wmsg, ! message structure
- * NULL, ! handle of window receiving the message
- * NULL, ! lowest message to examine
- * NULL).NE.0) ! highest message to examine
- WSTATUS=TranslateMessage(Wmsg) ! Translates virtual key codes
- WSTATUS=DispatchMessage(Wmsg) ! Dispatches message to window
- ENDDO
- WinMain=Wmsg.wParam ! Returns the value from PostQuitMessage
- RETURN
- END
-