|
|
1.1 root 1: /* Biorhythm - Utility to compute personal biorhythm charts.
2: *
1.1.1.2 ! root 3: * Created by Microsoft Corp., 1989
1.1 root 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];
1.1.1.2 ! root 49: ULONG AppCtlData = FCF_STANDARD | FCF_VERTSCROLL | FCF_NOBYTEALIGN & ~FCF_SHELLPOSITION;
! 50: ULONG KidCtlData = FCF_TITLEBAR;
! 51: PFNWP OldFrameWndProc;
1.1 root 52:
53: /* Read-only global variables */
54: extern FONTMETRICS tmFontInfo;
1.1.1.2 ! root 55: extern SHORT cxLegendField;
! 56: extern SHORT cxDateField;
1.1 root 57:
58: SHORT cdecl main( )
59: {
60: QMSG qMsg;
61: SHORT dx, dy, x, y;
1.1.1.2 ! root 62: SHORT cxSizeBorder;
! 63: SHORT cySizeBorder;
! 64: SHORT cxBorder;
! 65: SHORT cyBorder;
1.1 root 66:
67: /* Standard initialization. Get anchor block and message queue. */
68: hAB = WinInitialize(NULL);
69: hMsgQ = WinCreateMsgQueue( hAB, 0 );
70:
71: /* Get string constants for parent and child window registration
72: and creation from resource string table. */
1.1.1.2 ! root 73: WinLoadString( hAB, NULL, IDS_APPNAME, sizeof(szAppName), szAppName );
! 74: WinLoadString( hAB, NULL, IDS_KIDNAME, sizeof(szKidName), szKidName );
1.1 root 75:
76: /* Register parent window. Terminate if error. */
77: if ( !WinRegisterClass( hAB, szAppName, BioWndProc,
1.1.1.2 ! root 78: CS_CLIPCHILDREN | CS_SIZEREDRAW, NULL ) )
1.1 root 79: return( FALSE );
80:
81: /* Register child window. Terminate if error. */
1.1.1.2 ! root 82: if ( !WinRegisterClass( hAB, szKidName, KidWndProc, 0L, NULL ) )
1.1 root 83: return( FALSE );
84:
85: /* Create a parent window of class szAppName */
86: hwndAppFrame = WinCreateStdWindow(
87: HWND_DESKTOP,
1.1.1.2 ! root 88: 0L,
1.1 root 89: &AppCtlData,
90: szAppName,
1.1.1.2 ! root 91: NULL,
1.1 root 92: 0L,
93: NULL,
94: ID_BIO,
95: (HWND FAR *)&hwndApp
96: );
97:
98: /* Create a child window of class KidClass */
99: hwndKidFrame = WinCreateStdWindow(
100: hwndApp,
101: FS_BORDER,
102: &KidCtlData,
103: szKidName,
104: szKidName,
105: 0L,
106: NULL,
107: 0,
108: (HWND FAR *)&hwndKid
109: );
110:
1.1.1.2 ! root 111: /* Subclass frame so that minimum window size can be controled */
! 112: OldFrameWndProc = WinSubclassWindow( hwndAppFrame, FrameWndProc );
! 113:
! 114: /* Get the size of the screen and border. Used to place and size window */
! 115: cxSizeBorder = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSIZEBORDER );
! 116: cySizeBorder = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER );
! 117: cxBorder = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXBORDER );
! 118: cyBorder = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER );
! 119: x = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
! 120: y = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
1.1 root 121:
122: /* Calculate width and height of child window. Must be able to
1.1.1.2 ! root 123: display three lines and wide enough for text and corresponding colored
! 124: line. Must take into account titlebar and border vertical sizes. */
! 125: dx = cxLegendField * 2;
1.1 root 126: dy = (SHORT)(tmFontInfo.lMaxBaselineExt*3 +
127: WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ) +
128: WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER ) * 2);
129:
1.1.1.2 ! root 130: /* Place and size parent and child windows, then make them visible.
1.1 root 131: WinCreateStdWindow does not include position and size arguments.
1.1.1.2 ! root 132: Parent window is thin, but full screen high. Child window is placed
! 133: 10 pixels over and up from the parent window's lower left corner. */
! 134: WinSetWindowPos( hwndAppFrame, NULL,
! 135: x-(3*cxDateField)+cxSizeBorder,
! 136: -cySizeBorder,
! 137: (3*cxDateField),
! 138: y+2*cySizeBorder,
! 139: SWP_MOVE | SWP_SIZE | SWP_ACTIVATE | SWP_SHOW );
! 140: WinSetWindowPos( hwndKidFrame, NULL, 10, 10, dx, dy,
! 141: SWP_MOVE | SWP_SIZE | SWP_ACTIVATE | SWP_SHOW );
1.1 root 142:
143: /* Get messages from application queue and dispatch them for processing */
144: while( WinGetMsg( hAB, &qMsg, (HWND)NULL, 0, 0 ) )
145: {
146: WinDispatchMsg( hAB, &qMsg );
147: }
148:
1.1.1.2 ! root 149: /* Clean up. All child windows will be destoyed automatically */
1.1 root 150: WinDestroyWindow( hwndAppFrame );
151: WinDestroyMsgQueue( hMsgQ );
152: WinTerminate( hAB );
153: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.