|
|
1.1 root 1: /* Biorhythm - Utility to compute personal biorhythm charts.
2: *
3: * Created by Microsoft Corp., 1988
4: *
5: * Purpose:
6: * Program entry point, initialization and GetMessage loop.
7: *
8: * Arguments:
9: * None
10: *
11: * Globals (modified):
12: * hAB - Handle to the Anchor Block
13: * hMsgQ - Handle to the application's message queue
14: * hwndAppFrame - Window handle of parent window's frame
15: * hwndKidFrame - Window handle of parent window's frame
16: * hwndApp - Window handle of parent window's client area
17: * hwndKid - Window handle of child window's client area
18: * szAppName[10] - RC file program name (Biorhythm).
19: * szKidName[10] - RC file child window name (Legend).
20: *
21: * Globals (referenced):
22: * tmFontInfo - Text Metric structure defined during WM_CREATE
23: *
24: * Description:
25: * The theory of biorhythms states that life consists of three cycles,
26: * physical, emotional and intellectual of 23, 28 and 33 days,
27: * respectively. The cycles each begin on the date of birth.
28: *
29: * Limits:
30: * The intended use of this program is for the 20th and 21st centuries.
31: * The calculations of biorhythms will not be accurate outside of this
32: * range due to formulae used to compute days between dates.
33: *
34: */
35:
36: #define INCL_WIN
37: #include <os2.h>
38:
39: #include <stddef.h>
40: #include "bio.h"
41:
42: /* Write-once global variables */
43: HAB hAB;
44: HMQ hMsgQ;
45: HWND hwndApp, hwndKid;
46: HWND hwndAppFrame, hwndKidFrame;
47: char szAppName[10];
48: char szKidName[10];
49: ULONG AppCtlData = FCF_STANDARD | FCF_VERTSCROLL;
50: ULONG KidCtlData = FCF_TITLEBAR | FCF_SYSMENU;
51:
52: /* Read-only global variables */
53: extern FONTMETRICS tmFontInfo;
54:
55: SHORT cdecl main( )
56: {
57: QMSG qMsg;
58: SHORT dx, dy, x, y;
59:
60: /* Standard initialization. Get anchor block and message queue. */
61: hAB = WinInitialize(NULL);
62: hMsgQ = WinCreateMsgQueue( hAB, 0 );
63:
64: /* Get string constants for parent and child window registration
65: and creation from resource string table. */
66: WinLoadString( hAB, NULL, IDSAPPNAME, sizeof(szAppName), szAppName );
67: WinLoadString( hAB, NULL, IDSKIDNAME, sizeof(szKidName), szKidName );
68:
69: /* Register parent window. Terminate if error. */
70: if ( !WinRegisterClass( hAB, szAppName, BioWndProc,
71: CS_CLIPCHILDREN | CS_SIZEREDRAW, NULL ) )
72: return( FALSE );
73:
74: /* Register child window. Terminate if error. */
75: if ( !WinRegisterClass( hAB, szKidName, KidWndProc,
76: CS_SIZEREDRAW, NULL ) )
77: return( FALSE );
78:
79: /* Create a parent window of class szAppName */
80: hwndAppFrame = WinCreateStdWindow(
81: HWND_DESKTOP,
82: FS_ICON | FS_ACCELTABLE,
83: &AppCtlData,
84: szAppName,
85: szAppName,
86: 0L,
87: NULL,
88: ID_BIO,
89: (HWND FAR *)&hwndApp
90: );
91:
92: /* Create a child window of class KidClass */
93: hwndKidFrame = WinCreateStdWindow(
94: hwndApp,
95: FS_BORDER,
96: &KidCtlData,
97: szKidName,
98: szKidName,
99: 0L,
100: NULL,
101: 0,
102: (HWND FAR *)&hwndKid
103: );
104:
105: /* Get the size of the screen in pixels. Used to place and size window */
106: x = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
107: y = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
108:
109: /* Calculate width and height of child window. Must be able to
110: display three lines vertically by 21 characters wide. Must
111: include Titlebar and border vertical sizes. */
112: dx = (SHORT)tmFontInfo.lAveCharWidth * 21;
113: dy = (SHORT)(tmFontInfo.lMaxBaselineExt*3 +
114: WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ) +
115: WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER ) * 2);
116:
117: /* Place and size parent and child windows. Then make 'em visible.
118: WinCreateStdWindow does not include position and size arguments.
119: Parent window is a 256 pixels wide by full screen high. Child
120: window is placed 10 pixels over and up from the parent window's
121: lower left corner. */
122: WinSetWindowPos( hwndAppFrame, NULL, x-256, 0, 256, y, SWP_MOVE | SWP_SIZE | SWP_ACTIVATE );
123: WinSetWindowPos( hwndKidFrame, NULL, 10, 10, dx, dy, SWP_MOVE | SWP_SIZE | SWP_ACTIVATE );
124: WinShowWindow( hwndAppFrame, TRUE );
125: WinShowWindow( hwndKidFrame, TRUE );
126:
127: /* Get messages from application queue and dispatch them for processing */
128: while( WinGetMsg( hAB, &qMsg, (HWND)NULL, 0, 0 ) )
129: {
130: WinDispatchMsg( hAB, &qMsg );
131: }
132:
133: /* Cleanup mess. All child windows will be destoyed automatically */
134: WinDestroyWindow( hwndAppFrame );
135: WinDestroyMsgQueue( hMsgQ );
136: WinTerminate( hAB );
137: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.