Annotation of os232sdk/toolkt20/c/samples/bio/bio.c, revision 1.1

1.1     ! root        1: /*  Biorhythm - Utility to compute personal biorhythm charts.
        !             2: *
        !             3: *   Created by Microsoft, IBM Corporation, 1990
        !             4: *
        !             5: *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is 
        !             6: *      sample code created by Microsoft Corporation and/or IBM 
        !             7: *      Corporation. This sample code is not part of any standard 
        !             8: *      Microsoft or IBM product and is provided to you solely for 
        !             9: *      the purpose of assisting you in the development of your 
        !            10: *      applications.  The code is provided "AS IS", without 
        !            11: *      warranty of any kind.  Neither Microsoft nor IBM shall be 
        !            12: *      liable for any damages arising out of your use of the sample 
        !            13: *      code, even if they have been advised of the possibility of 
        !            14: *      such damages.
        !            15: *
        !            16: *   Purpose:
        !            17: *       Program entry point, initialization and GetMessage loop.
        !            18: *
        !            19: *   Arguments:
        !            20: *       None
        !            21: *
        !            22: *   Globals (modified):
        !            23: *       hAB           - Handle to the Anchor Block
        !            24: *       hMsgQ         - Handle to the application's message queue
        !            25: *       hwndAppFrame  - Window handle of parent window's frame
        !            26: *       hwndKidFrame  - Window handle of parent window's frame
        !            27: *       hwndApp       - Window handle of parent window's client area
        !            28: *       hwndKid       - Window handle of child window's client area
        !            29: *       szAppName[10] - RC file program name (Biorhythm).
        !            30: *       szKidName[10] - RC file child window name (Legend).
        !            31: *
        !            32: *   Globals (referenced):
        !            33: *       tmFontInfo    - Text Metric structure defined during WM_CREATE 
        !            34: *
        !            35: *   Description:
        !            36: *       The theory of biorhythms states that life consists of three cycles,
        !            37: *       physical, emotional and intellectual of 23, 28 and 33 days,
        !            38: *       respectively.  The cycles each begin on the date of birth.
        !            39: *
        !            40: *   Limits:
        !            41: *       The intended use of this program is for the 20th and 21st centuries.
        !            42: *       The calculations of biorhythms will not be accurate outside of this
        !            43: *       range due to formulae used to compute days between dates.
        !            44: *
        !            45: */
        !            46: 
        !            47: #define INCL_WIN
        !            48: #include <os2.h>
        !            49: 
        !            50: #include <stddef.h>
        !            51: 
        !            52: #include "bio.h"
        !            53: 
        !            54: /* Write-once global variables */
        !            55: HAB     hAB;
        !            56: HMQ     hMsgQ;
        !            57: HWND    hwndApp, hwndKid;
        !            58: HWND    hwndAppFrame, hwndKidFrame;
        !            59: char    szAppName[10];
        !            60: char    szKidName[10];
        !            61: ULONG  AppCtlData = FCF_STANDARD | FCF_VERTSCROLL | FCF_NOBYTEALIGN & ~FCF_SHELLPOSITION;
        !            62: ULONG  KidCtlData = FCF_TITLEBAR;
        !            63: PFNWP  OldFrameWndProc;
        !            64: 
        !            65: /* Read-only global variables */
        !            66: extern  FONTMETRICS     tmFontInfo;
        !            67: extern SHORT           cxLegendField;
        !            68: extern SHORT           cxDateField;
        !            69: 
        !            70: BOOL cdecl main( VOID )
        !            71: {
        !            72:     QMSG        qMsg;
        !            73:     SHORT       dx, dy, x, y;
        !            74:     SHORT      cxSizeBorder;
        !            75:     SHORT      cySizeBorder;
        !            76:     SHORT      cxBorder;
        !            77:     SHORT      cyBorder;
        !            78: 
        !            79:     /* Standard initialization.  Get anchor block and message queue. */
        !            80:     hAB   = WinInitialize(NULL);
        !            81:     hMsgQ = WinCreateMsgQueue( hAB, 0 );
        !            82: 
        !            83:     /* Get string constants for parent and child window registration
        !            84:        and creation from resource string table. */
        !            85:     WinLoadString( hAB, NULL, IDS_APPNAME, sizeof(szAppName), szAppName );
        !            86:     WinLoadString( hAB, NULL, IDS_KIDNAME, sizeof(szKidName), szKidName );
        !            87: 
        !            88:     /* Register parent window.  Terminate if error. */
        !            89:     if ( !WinRegisterClass( hAB, szAppName, (PFNWP)BioWndProc,
        !            90:            CS_CLIPCHILDREN | CS_SIZEREDRAW, NULL ) )
        !            91:         return( FALSE );
        !            92: 
        !            93:     /* Register child window.  Terminate if error. */
        !            94:     if ( !WinRegisterClass( hAB, szKidName, (PFNWP)KidWndProc, 0L, NULL ) )
        !            95:         return( FALSE );
        !            96: 
        !            97:     /* Create a parent window of class szAppName */
        !            98:     hwndAppFrame = WinCreateStdWindow(
        !            99:         HWND_DESKTOP,
        !           100:        0L,
        !           101:        &AppCtlData,
        !           102:         szAppName,
        !           103:        NULL,
        !           104:         0L,
        !           105:         NULL,
        !           106:         ID_BIO,
        !           107:         (HWND FAR *)&hwndApp
        !           108:         );
        !           109: 
        !           110:     /* Create a child window of class KidClass */
        !           111:     hwndKidFrame = WinCreateStdWindow(
        !           112:         hwndApp,
        !           113:        FS_BORDER,
        !           114:        &KidCtlData,
        !           115:         szKidName,
        !           116:         szKidName,
        !           117:         0L,
        !           118:         NULL,
        !           119:         0,
        !           120:         (HWND FAR *)&hwndKid
        !           121:         );
        !           122: 
        !           123:     /* Subclass frame so that minimum window size can be controled */
        !           124:     OldFrameWndProc = WinSubclassWindow( hwndAppFrame, (PFNWP)FrameWndProc );
        !           125: 
        !           126:     /* Get the size of the screen and border.  Used to place and size window */
        !           127:     cxSizeBorder =  (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSIZEBORDER );
        !           128:     cySizeBorder =  (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER );
        !           129:     cxBorder    =  (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXBORDER );
        !           130:     cyBorder    =  (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER );
        !           131:     x           =  (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
        !           132:     y           =  (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
        !           133: 
        !           134:     /* Calculate width and height of child window.  Must be able to
        !           135:        display three lines and wide enough for text and corresponding colored
        !           136:        line.  Must take into account titlebar and border vertical sizes. */
        !           137:     dx = cxLegendField * 2;
        !           138:     dy = (SHORT)(tmFontInfo.lMaxBaselineExt*3 +
        !           139:          WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ) +
        !           140:          WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER ) * 2);
        !           141: 
        !           142:     /* Place and size parent and child windows, then make them visible.
        !           143:        WinCreateStdWindow does not include position and size arguments.
        !           144:        Parent window is thin, but full screen high.  Child window is placed
        !           145:        10 pixels over and up from the parent window's lower left corner. */
        !           146:     WinSetWindowPos( hwndAppFrame, NULL,
        !           147:                     x-(3*cxDateField)+cxSizeBorder,
        !           148:                     -cySizeBorder,
        !           149:                     (3*cxDateField),
        !           150:                     y+2*cySizeBorder,
        !           151:                     SWP_MOVE | SWP_SIZE | SWP_ACTIVATE | SWP_SHOW );
        !           152:     WinSetWindowPos( hwndKidFrame, NULL, 10, 10, dx, dy,
        !           153:                     SWP_MOVE | SWP_SIZE | SWP_ACTIVATE | SWP_SHOW );
        !           154: 
        !           155:     /* Get messages from application queue and dispatch them for processing */
        !           156:     while( WinGetMsg( hAB, &qMsg, (HWND)NULL, 0, 0 ) )
        !           157:     {
        !           158:         WinDispatchMsg( hAB, &qMsg );
        !           159:     }
        !           160: 
        !           161:     /* Clean up.  All child windows will be destoyed automatically */
        !           162:     WinDestroyWindow( hwndAppFrame );
        !           163:     WinDestroyMsgQueue( hMsgQ );
        !           164:     WinTerminate( hAB );
        !           165: }

unix.superglobalmegacorp.com

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