Annotation of pmsdk/samples/linefrac/linefrac.c, revision 1.1

1.1     ! root        1: /************************************************************************
        !             2: *
        !             3: *   linefrac.c
        !             4: *
        !             5: *   Main window procedure for LineFractal window class.
        !             6: *
        !             7: *   Created by Microsoft Corp., 1988
        !             8: *
        !             9: ************************************************************************/
        !            10: 
        !            11: #define INCL_WIN
        !            12: #define INCL_DOSSEMAPHORES
        !            13: 
        !            14: #include <os2.h>
        !            15: #include "linefrac.h"
        !            16: 
        !            17: 
        !            18: extern HAB     hAB;
        !            19:        HMQ     hMsgQ;
        !            20: extern HWND    hwndLineFrac;
        !            21: extern HWND    hwndLineFracFrame;
        !            22: extern LONG    lColorBack;
        !            23: 
        !            24: extern BOOL    fInterrupted;
        !            25: extern LONG    lSemAccumulateFractal;
        !            26: extern int     usRecursion;
        !            27: extern BOOL    fAutoScale;
        !            28: extern BOOL    fHaveAccumThread;
        !            29: extern BOOL    fHaveBitmap;
        !            30: 
        !            31: SHORT cdecl main(void);
        !            32: 
        !            33: 
        !            34: 
        !            35: 
        !            36: /************************************************************************
        !            37: *
        !            38: *   main
        !            39: *
        !            40: *   This is a C program, right?  Gotta have one of these (unless you're
        !            41: *   writing for Windows, that is).
        !            42: *
        !            43: *   WinInitialize resizes our ring 2 stack, among other things, so
        !            44: *   we won't GP fault trying to do graphics.  WinCreateMsgQueue defines
        !            45: *   us as a REAL Winthorn app. Call a sub to register our window class
        !            46: *   and create a window.  Loop over messages.  Exit cleanly.
        !            47: *
        !            48: ************************************************************************/
        !            49: 
        !            50: SHORT cdecl
        !            51: main()
        !            52: {
        !            53:     QMSG   qMsg;
        !            54: 
        !            55:     hAB   = WinInitialize(NULL);
        !            56:     hMsgQ = WinCreateMsgQueue(hAB, 0);
        !            57: 
        !            58:     if (!LineFracInitApp())
        !            59:        return FALSE;
        !            60: 
        !            61:     while (WinGetMsg( hAB, (PQMSG)&qMsg, (HWND)NULL, 0, 0 ))
        !            62:         WinDispatchMsg( hAB, (PQMSG)&qMsg );
        !            63: 
        !            64:     WinDestroyWindow( hwndLineFracFrame );
        !            65:     WinDestroyMsgQueue( hMsgQ );
        !            66:     WinTerminate( hAB );
        !            67: }
        !            68: 
        !            69: 
        !            70: 
        !            71: 
        !            72: /************************************************************************
        !            73: *
        !            74: *   LineFracWndProc
        !            75: *
        !            76: *   Process messages for the LineFractal window class.
        !            77: *
        !            78: ************************************************************************/
        !            79: 
        !            80: ULONG FAR PASCAL
        !            81: LineFracWndProc( hWnd, message, mp1, mp2 )
        !            82: HWND   hWnd;
        !            83: USHORT message;
        !            84: MPARAM  mp1;
        !            85: MPARAM  mp2;
        !            86: {
        !            87:     HPS     hPS;
        !            88:     RECTL   rect;
        !            89: 
        !            90:     switch( message )
        !            91:     {
        !            92:     case WM_CLOSE:
        !            93:        LineFracExit();
        !            94:        WinPostMsg( hWnd, WM_QUIT, 0L, 0L );
        !            95:        break;
        !            96: 
        !            97:     case WM_COMMAND:
        !            98:        LineFracCommand(hWnd, LOUSHORT(mp1));
        !            99:        break;
        !           100: 
        !           101:     case WM_ERASEBACKGROUND:
        !           102:        hPS = WinGetPS(hWnd);
        !           103:        WinQueryUpdateRect(hWnd, (PRECTL)&rect);
        !           104:        WinFillRect(hPS, (PRECTL)&rect, lColorBack);
        !           105:        WinReleasePS(hPS);
        !           106:        return FALSE;
        !           107:        break;
        !           108: 
        !           109:     case WM_PAINT:
        !           110:        /* initialization done here so that bitmap will have
        !           111:           meaningful size */
        !           112:        if (!fHaveAccumThread)
        !           113:            LineFracInit(hWnd);
        !           114: 
        !           115:        hPS = WinBeginPaint(hwndLineFrac, NULL, NULL);
        !           116:        LineFracPaint(hPS);
        !           117:        WinEndPaint(hPS);
        !           118:        break;
        !           119: 
        !           120:     case WM_BUTTON1UP:
        !           121:     case WM_BUTTON2UP:
        !           122:        if (message == WM_BUTTON1UP)
        !           123:            usRecursion = ++usRecursion;
        !           124:        else if (usRecursion > 0)
        !           125:            usRecursion = --usRecursion;
        !           126: 
        !           127:        fInterrupted = TRUE;
        !           128:        DosSemClear(&lSemAccumulateFractal);
        !           129:        break;
        !           130: 
        !           131:     case WM_SIZE:
        !           132:        if (fAutoScale && fHaveBitmap && fHaveAccumThread)
        !           133:            if (fHaveBitmap = ResizeBitmap(hWnd))
        !           134:            {
        !           135:                fInterrupted = TRUE;
        !           136:                DosSemClear(&lSemAccumulateFractal);
        !           137:            }
        !           138: 
        !           139:        /* fall through -- we might want to restart point accumulation,
        !           140:           but don't want to process the resize message */
        !           141: 
        !           142:     default:
        !           143:        return( (ULONG)WinDefWindowProc(hWnd, message, mp1, mp2));
        !           144:        break;
        !           145:     }
        !           146: 
        !           147:     return FALSE;
        !           148: }

unix.superglobalmegacorp.com

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