home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / gw / oddev.exe / MPINIT.C < prev    next >
Text File  |  1994-07-01  |  5KB  |  152 lines

  1. /***************************************************************************
  2.  *                                       *
  3.  *  MODULE    : MpInit.c                           *
  4.  *                                       *
  5.  *  PURPOSE    : Contains initialization code for MultODMA.           *
  6.  *                                       *
  7.  *  FUNCTIONS    : InitializeApplication() - Sets up Class data structure   *
  8.  *                        and registers window class.    *
  9.  *                                       *
  10.  *          InitializeInstance ()   - Does a per-instance initial-   *
  11.  *                        ization of MultODMA. Creates   *
  12.  *                        the "frame" and MDI client.    *
  13.  *                                       *
  14.  ***************************************************************************/
  15.  
  16. #include "multipad.h"
  17. #include "commdlg.h"
  18.  
  19. extern PRINTDLG pd;                  /* Common print dialog structure */
  20.  
  21. char szFrame[] = "mpframe";   /* Class name for "frame" window */
  22. char szChild[] = "mpchild";   /* Class name for MDI window     */
  23.  
  24. /****************************************************************************
  25.  *                                        *
  26.  *  FUNCTION   : InitializeApplication ()                    *
  27.  *                                        *
  28.  *  PURPOSE    : Sets up the class data structures and does a one-time        *
  29.  *         initialization of the app by registering the window classes*
  30.  *                                        *
  31.  *  RETURNS    : TRUE  - If RegisterClass() was successful for both classes.*
  32.  *         FALSE - otherwise.                        *
  33.  *                                        *
  34.  ****************************************************************************/
  35.  
  36. BOOL FAR PASCAL InitializeApplication()
  37. {
  38.     WNDCLASS    wc;
  39.  
  40.     /* Register the frame class */
  41.     wc.style         = 0;
  42.     wc.lpfnWndProc   = MPFrameWndProc;
  43.     wc.cbClsExtra    = 0;
  44.     wc.cbWndExtra    = 0;
  45.     wc.hInstance     = hInst;
  46.     wc.hIcon         = LoadIcon(hInst,IDMULTIPAD);
  47.     wc.hCursor         = LoadCursor(NULL,IDC_ARROW);
  48.     wc.hbrBackground = COLOR_APPWORKSPACE+1;
  49.     wc.lpszMenuName  = IDMULTIPAD;
  50.     wc.lpszClassName = szFrame;
  51.  
  52.     if (!RegisterClass (&wc) )
  53.         return FALSE;
  54.  
  55.     /* Register the MDI child class */
  56.     wc.lpfnWndProc   = MPMDIChildWndProc;
  57.     wc.hIcon         = LoadIcon(hInst,IDNOTE);
  58.     wc.lpszMenuName  = NULL;
  59.     wc.cbWndExtra    = CBWNDEXTRA;
  60.     wc.lpszClassName = szChild;
  61.  
  62.     /* fill in non-variant fields of PRINTDLG struct. */
  63.  
  64.     pd.lStructSize    = sizeof(PRINTDLG);
  65.     pd.hDevMode       = NULL;
  66.     pd.hDevNames      = NULL;
  67.     pd.Flags          = PD_RETURNDC | PD_NOSELECTION | PD_NOPAGENUMS;
  68.     pd.nCopies        = 1;
  69.  
  70.  
  71.    if (!RegisterClass(&wc))
  72.         return FALSE;
  73.  
  74.     return TRUE;
  75. }
  76.  
  77. /****************************************************************************
  78.  *                                        *
  79.  *  FUNCTION   : InitializeInstance ()                        *
  80.  *                                        *
  81.  *  PURPOSE    : Performs a per-instance initialization of MultODMA. It     *
  82.  *         also creates the frame and an MDI window.            *
  83.  *                                        *
  84.  *  RETURNS    : TRUE  - If initialization was successful.            *
  85.  *         FALSE - otherwise.                        *
  86.  *                                        *
  87.  ****************************************************************************/
  88. BOOL FAR PASCAL InitializeInstance(LPSTR lpCmdLine, WORD nCmdShow)
  89. {
  90.     extern HWND  hwndMDIClient;
  91.     char     sz[256], *pCmdLine;
  92.  
  93.     /* Get the base window title */
  94.     LoadString (hInst, IDS_APPNAME, sz, sizeof(sz));
  95.  
  96.     /* Create the frame */
  97.     hwndFrame = CreateWindow (szFrame,
  98.                   sz,
  99.                   WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
  100.                   CW_USEDEFAULT,
  101.                   0,
  102.                   CW_USEDEFAULT,
  103.                   0,
  104.                   NULL,
  105.                   NULL,
  106.                   hInst,
  107.                   NULL);
  108.  
  109.     if ((!hwndFrame) || (!hwndMDIClient))
  110.         return FALSE;
  111.  
  112.     pd.hwndOwner = hwndFrame;
  113.  
  114.    /* Load main menu accelerators */
  115.     if (!(hAccel = LoadAccelerators (hInst, IDMULTIPAD)))
  116.         return FALSE;
  117.  
  118.     /* Display the frame window */
  119.     ShowWindow (hwndFrame, nCmdShow);
  120.     UpdateWindow (hwndFrame);
  121.  
  122.      /* Initialize ODMA. */
  123.      if (ODMRegisterApp( &odmHandle, ODM_API_VERSION, "multodma", hwndFrame,
  124.         NULL ))
  125.             odmHandle = NULL;
  126.  
  127.     /* If the command line string is empty, nullify the pointer to it
  128.     ** else copy command line into our data segment
  129.     */
  130.     pCmdLine = sz;
  131.     if ( lpCmdLine && !(*lpCmdLine))
  132.         *pCmdLine = NULL;
  133.     else {
  134.         lstrcpy(pCmdLine, lpCmdLine);
  135.     }
  136.  
  137.     /* If command line found - parse it into OpenFile structure */
  138.     ParseCmdLine(pCmdLine);
  139.  
  140.     /* Add the first MDI window */
  141.     AddFile (pCmdLine);
  142.  
  143.     /* if we allocated a buffer then free it */
  144.     if (pCmdLine)
  145.         LocalFree((LOCALHANDLE) pCmdLine);
  146.  
  147.     /* Default to minimized windows after the first. */
  148.     styleDefault = 0L;
  149.  
  150.     return TRUE;
  151. }
  152.