Annotation of mstools/samples/multipad/mpinit.c, revision 1.1.1.2

1.1       root        1: 
1.1.1.2 ! root        2: /******************************************************************************\
        !             3: *       This is a part of the Microsoft Source Code Samples. 
        !             4: *       Copyright (C) 1993 Microsoft Corporation.
        !             5: *       All rights reserved. 
        !             6: *       This source code is only intended as a supplement to 
        !             7: *       Microsoft Development Tools and/or WinHelp documentation.
        !             8: *       See these sources for detailed information regarding the 
        !             9: *       Microsoft samples programs.
        !            10: \******************************************************************************/
        !            11: 
        !            12: 
1.1       root       13: /***************************************************************************
1.1.1.2 ! root       14:  *                                                                         *
        !            15:  *  MODULE      : MpInit.c                                                 *
        !            16:  *                                                                         *
        !            17:  *  PURPOSE     : Contains initialization code for MultiPad.               *
        !            18:  *                                                                         *
        !            19:  *  FUNCTIONS   : InitializeApplication() - Sets up Class data structure   *
        !            20:  *                                          and registers window class.    *
        !            21:  *                                                                         *
        !            22:  *                InitializeInstance ()   - Does a per-instance initial-   *
        !            23:  *                                          ization of MultiPad. Creates   *
        !            24:  *                                          the "frame" and MDI client.    *
        !            25:  *                                                                         *
1.1       root       26:  ***************************************************************************/
                     27: #include "multipad.h"
                     28: 
                     29: CHAR szFrame[] = "mpframe";   /* Class name for "frame" window */
                     30: CHAR szChild[] = "mpchild";   /* Class name for MDI window     */
                     31: 
                     32: /****************************************************************************
1.1.1.2 ! root       33:  *                                                                          *
        !            34:  *  FUNCTION   : InitializeApplication ()                                   *
        !            35:  *                                                                          *
        !            36:  *  PURPOSE    : Sets up the class data structures and does a one-time      *
        !            37:  *               initialization of the app by registering the window classes*
        !            38:  *                                                                          *
1.1       root       39:  *  RETURNS    : TRUE  - If RegisterClass() was successful for both classes.*
1.1.1.2 ! root       40:  *               FALSE - otherwise.                                         *
        !            41:  *                                                                          *
1.1       root       42:  ****************************************************************************/
                     43: 
                     44: BOOL APIENTRY InitializeApplication()
                     45: {
1.1.1.2 ! root       46:     WNDCLASS    wc;
1.1       root       47: 
                     48:     /* Register the frame class */
1.1.1.2 ! root       49:     wc.style         = 0;
1.1       root       50:     wc.lpfnWndProc   = (WNDPROC) MPFrameWndProc;
                     51:     wc.cbClsExtra    = 0;
                     52:     wc.cbWndExtra    = 0;
                     53:     wc.hInstance    = hInst;
1.1.1.2 ! root       54:     wc.hIcon         = LoadIcon(hInst,IDMULTIPAD);
        !            55:     wc.hCursor       = LoadCursor(NULL,IDC_ARROW);
1.1       root       56:     wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1);
                     57:     wc.lpszMenuName  = IDMULTIPAD;
                     58:     wc.lpszClassName = szFrame;
                     59: 
                     60:     if (!RegisterClass (&wc) )
1.1.1.2 ! root       61:         return FALSE;
1.1       root       62: 
                     63:     /* Register the MDI child class */
                     64:     wc.lpfnWndProc   = (WNDPROC) MPMDIChildWndProc;
1.1.1.2 ! root       65:     wc.hIcon         = LoadIcon(hInst,IDNOTE);
1.1       root       66:     wc.lpszMenuName  = NULL;
                     67:     wc.cbWndExtra    = CBWNDEXTRA;
                     68:     wc.lpszClassName = szChild;
                     69: 
                     70:     if (!RegisterClass(&wc))
1.1.1.2 ! root       71:         return FALSE;
1.1       root       72: 
                     73:     return TRUE;
                     74: 
                     75: }
                     76: 
                     77: /****************************************************************************
1.1.1.2 ! root       78:  *                                                                          *
        !            79:  *  FUNCTION   : InitializeInstance ()                                      *
        !            80:  *                                                                          *
1.1       root       81:  *  PURPOSE    : Performs a per-instance initialization of MultiPad. It     *
1.1.1.2 ! root       82:  *               also creates the frame and an MDI window.                  *
        !            83:  *                                                                          *
        !            84:  *  RETURNS    : TRUE  - If initialization was successful.                  *
        !            85:  *               FALSE - otherwise.                                         *
        !            86:  *                                                                          *
1.1       root       87:  ****************************************************************************/
                     88: BOOL APIENTRY InitializeInstance(LPSTR lpCmdLine, INT nCmdShow)
                     89: {
                     90:     extern HWND  hwndMDIClient;
1.1.1.2 ! root       91:     CHAR         sz[80], *pCmdLine;
        !            92:     HDC          hdc;
        !            93:     HMENU        hmenu;
1.1       root       94: 
                     95:     /* Get the base window title */
                     96:     LoadString (hInst, IDS_APPNAME, sz, sizeof(sz));
                     97: 
                     98:     /* Create the frame */
                     99:     hwndFrame = CreateWindow (szFrame,
1.1.1.2 ! root      100:                               sz,
        !           101:                               WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
        !           102:                               CW_USEDEFAULT,
        !           103:                               0,
        !           104:                               CW_USEDEFAULT,
        !           105:                               0,
        !           106:                               NULL,
        !           107:                               NULL,
        !           108:                               hInst,
        !           109:                               NULL);
1.1       root      110: 
                    111:     if ((!hwndFrame) || (!hwndMDIClient))
1.1.1.2 ! root      112:         return FALSE;
1.1       root      113: 
                    114:     /* Load main menu accelerators */
                    115:     if (!(hAccel = LoadAccelerators (hInst, IDMULTIPAD)))
1.1.1.2 ! root      116:         return FALSE;
1.1       root      117: 
                    118:     /* Display the frame window */
                    119:     ShowWindow (hwndFrame, nCmdShow);
                    120:     UpdateWindow (hwndFrame);
                    121: 
                    122:     /* If the command line string is empty, nullify the pointer to it 
                    123:     ** else copy command line into our data segment 
                    124:     */
                    125:     if ( lpCmdLine && !(*lpCmdLine))
1.1.1.2 ! root      126:              pCmdLine = NULL;
1.1       root      127:     else {
                    128:         pCmdLine = (CHAR *) LocalAlloc(LPTR, lstrlen(lpCmdLine) + 1);
                    129:         if (pCmdLine)
                    130:            lstrcpy(pCmdLine, lpCmdLine);
                    131:     }
                    132: 
                    133:     /* Add the first MDI window */
                    134:     AddFile (pCmdLine);
                    135: 
                    136:     /* if we allocated a buffer then free it */
                    137:     if (pCmdLine)
                    138:         LocalFree((LOCALHANDLE) pCmdLine);
                    139: 
                    140:     /* Default to minimized windows after the first. */
                    141:     styleDefault = 0L;
                    142: 
                    143:     return TRUE;
1.1.1.2 ! root      144:         UNREFERENCED_PARAMETER(hmenu);
        !           145:         UNREFERENCED_PARAMETER(hdc);
1.1       root      146: 
                    147: }

unix.superglobalmegacorp.com

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