home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk12 / linefrac / lfinit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-05  |  4.9 KB  |  166 lines

  1. /****************************************************************************
  2. *
  3. *   lfinit.c -- Initialization portion of LineFractal Application.
  4. *
  5. *   Created by Microsoft Corporation, 1989
  6. *
  7. ****************************************************************************/
  8.  
  9. #define INCL_WIN
  10. #define INCL_GPI
  11. #include <os2.h>
  12.  
  13. #define INCL_GLOBALS
  14. #include "linefrac.h"
  15.  
  16. #define INCL_LFINIT
  17. #define INCL_LFMAIN
  18. #include "lffuncs.h"
  19.  
  20.  
  21.  
  22.  
  23. /************************************************************************
  24. *
  25. *   Global Variables
  26. *
  27. ************************************************************************/
  28.  
  29. extern GLOBALDATA global;
  30. extern ULONG aulRops[];
  31.  
  32.  
  33.  
  34.  
  35. /****************************************************************************
  36. *
  37. *   LfInitApp
  38. *
  39. *   Register application window class and creates standard window.
  40. *
  41. ****************************************************************************/
  42.  
  43. BOOL FAR
  44. LfInitApp(VOID)
  45. {
  46.     char szTitle[24];
  47.     ULONG ctldata;
  48.     PID pid;
  49.     TID tid;
  50.     HSWITCH hsw;
  51.     static SWCNTRL swctl = { 0, 0, 0, 0, 0, SWL_VISIBLE,
  52.                  SWL_JUMPABLE, "LineFractal", 0 };
  53.  
  54.  
  55.     /*  Register Application Window Class  */
  56.  
  57.     WinLoadString( global.hab, (HMODULE) NULL, IDS_TITLE, sizeof(szTitle), (PCH)szTitle );
  58.     if ( !WinRegisterClass( global.hab, (PCH)szTitle, (PFNWP)LineFracWndProc,
  59.         CS_SIZEREDRAW, 0 ))
  60.     return FALSE;
  61.  
  62.  
  63.     /* Load the window's default pointer. */
  64.     if (!((global.hptr)[0]   = WinLoadPointer( HWND_DESKTOP,(HMODULE) NULL, IDR_KOCH0 )))
  65.     return FALSE;
  66.     if (!((global.hptr)[1]   = WinLoadPointer( HWND_DESKTOP,(HMODULE) NULL, IDR_KOCH1 )))
  67.     return FALSE;
  68.     if (!((global.hptr)[2]   = WinLoadPointer( HWND_DESKTOP,(HMODULE) NULL, IDR_KOCH2 )))
  69.     return FALSE;
  70.     if (!((global.hptr)[3]   = WinLoadPointer( HWND_DESKTOP,(HMODULE) NULL, IDR_KOCH3 )))
  71.     return FALSE;
  72.     if (!(global.hptrTrack   = WinLoadPointer( HWND_DESKTOP,(HMODULE) NULL, IDR_TRACKINGPTR )))
  73.     return FALSE;
  74.     if (!(global.hptrPaste   = WinLoadPointer( HWND_DESKTOP,(HMODULE) NULL, IDR_PASTINGPTR )))
  75.     return FALSE;
  76.     if (!(global.hptrWait    = WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE)))
  77.     return FALSE;
  78.  
  79.  
  80.  
  81.     /* Create a window instance of class "LineFractal" */
  82.  
  83.     ctldata = FCF_STANDARD &
  84.      ~(ULONG)(FCF_ICON | FCF_ACCELTABLE | FCF_TASKLIST);
  85.  
  86.     if (global.hwndFrame = WinCreateStdWindow(
  87.     HWND_DESKTOP,           /* specify desktop as parent window        */
  88.     WS_VISIBLE,           /* window styles                */
  89.     &ctldata,           /* frame creation flags            */
  90.     (PCH)szTitle,           /* window class name             */
  91.     (PCH)szTitle,           /* name appearing in window caption        */
  92.     0L,               /*                        */
  93.     (HMODULE)NULL,           /* use current executable module id        */
  94.     IDR_LINEFRACTAL,       /* menu id                    */
  95.     (HWND FAR *)&global.hwnd   /* window handle                */
  96.     ))
  97.     {
  98.     global.fFirstThread          = TRUE;
  99.  
  100.     global.fAutoSwitch          = FALSE;
  101.     global.usSwitchDelay          = 1 * 1000;      /* 1 sec */
  102.     global.fThreadInheritance      = TRUE;
  103.     global.fUpdateMenusOnThreadSwitch = TRUE;
  104.     global.fTimerOn           = FALSE;
  105.     global.usMinTimerDelay          = 1 * 1000;      /* 1 sec */
  106.     global.usMaxTimerDelay          = 5 * 1000;      /* 5 sec */
  107.  
  108.     global.usRopIndex          = 0;
  109.     global.ulPasteROP          = aulRops[global.usRopIndex];
  110.     global.usPtrIncr          = 1;
  111.     global.usPtrCounter          = 1;
  112.     global.usUserPtr          = 2;
  113.     global.usCurPtr           = global.usUserPtr;
  114.     global.usPtrThreshold          = 5;
  115.     global.fUseClipbrd          = FALSE;
  116.     global.fTracking          = FALSE;
  117.     global.fSelecting          = FALSE;
  118.     global.fPasting           = FALSE;
  119.     global.fMouseChangesRecursion      = TRUE;
  120.     global.fAnimatePtr          = TRUE;
  121.     global.fTempSelect          = FALSE;
  122.     global.fShowSelectRc          = FALSE;
  123.     global.fHaveSelectRc          = FALSE;
  124.     global.fHaveCutCopyDC          = FALSE;
  125.  
  126.     global.fUpdateAttrs          = FALSE;
  127.     global.flLineAttrs          = 0L;
  128.     global.flMarkerAttrs          = 0L;
  129.     global.flAreaAttrs          = 0L;
  130.     global.flImageAttrs          = 0L;
  131.     global.flMiscAttrs          = 0L;
  132.  
  133.  
  134.     WinQueryWindowRect(global.hwnd, &global.rcl);
  135.  
  136.     global.cThr = 0;    /* start with no active threads */
  137.     global.pThrTop = NULL;    /* make sure this guy's invalid */
  138.  
  139.  
  140. #define INIT_MENU_ITEM(val, var)     \
  141.     TOGGLE_MENU_ITEM(global.hwndFrame, (val), (var))
  142.  
  143.     /* Check boolean menu items if they are set to true. */
  144.  
  145.     INIT_MENU_ITEM(IDM_AUTOSWITCH,         global.fAutoSwitch);
  146.     INIT_MENU_ITEM(IDM_UPDATEMENUS,         global.fUpdateMenusOnThreadSwitch);
  147.     INIT_MENU_ITEM(IDM_THREADINHERITANCE,     global.fThreadInheritance);
  148.     INIT_MENU_ITEM(IDM_USECLIPBRD,         global.fUseClipbrd);
  149.     INIT_MENU_ITEM(IDM_MOUSECHANGESRECURSION, global.fMouseChangesRecursion);
  150.     INIT_MENU_ITEM(IDM_ANIMATEPTR,         global.fAnimatePtr);
  151.  
  152.     CHECK_MENU_ITEM(global.hwndFrame, IDM_PASTES+global.usRopIndex);
  153.  
  154.  
  155.     /* Add ourselves to the switch list. */
  156.  
  157.     WinQueryWindowProcess(global.hwndFrame, &pid, &tid);
  158.     swctl.hwnd    = global.hwndFrame;
  159.     swctl.idProcess = pid;
  160.     hsw = WinAddSwitchEntry(&swctl);
  161.  
  162.     return TRUE;
  163.     }
  164.     return FALSE;
  165. }
  166.