Annotation of mstools/samples/ddeml/client/clinit.c, revision 1.1.1.3

1.1.1.3 ! root        1: 
        !             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: 
1.1       root       12: /***************************************************************************
                     13:  *                                                                         *
                     14:  *  MODULE      : clinit.c                                                 *
                     15:  *                                                                         *
                     16:  *  PURPOSE     : Contains initialization code for Client                  *
                     17:  *                                                                         *
                     18:  ***************************************************************************/
                     19: 
                     20: #include "client.h"
                     21: 
                     22: CHAR szFrame[] = "mpframe";   /* Class name for "frame" window */
                     23: CHAR szChild[] = "mpchild";   /* Class name for MDI window     */
                     24: CHAR szList[] =  "mplist";    /* Class name for MDI window     */
                     25: 
                     26: /****************************************************************************
                     27:  *                                                                          *
                     28:  *  FUNCTION   : InitializeApplication ()                                   *
                     29:  *                                                                          *
                     30:  *  PURPOSE    : Sets up the class data structures and does a one-time      *
                     31:  *               initialization of the app by registering the window classes*
                     32:  *               Also registers the Link clipboard format                   *
                     33:  *                                                                          *
                     34:  *  RETURNS    : TRUE  - If successful.                                     *
                     35:  *               FALSE - otherwise.                                         *
                     36:  *                                                                          *
                     37:  ****************************************************************************/
                     38: 
                     39: BOOL  APIENTRY InitializeApplication()
                     40: {
                     41:     WNDCLASS    wc;
                     42: 
                     43:     fmtLink = RegisterClipboardFormat("Link");
                     44: 
                     45:     if (!fmtLink)
                     46:         return FALSE;
                     47: 
                     48:     /* Register the frame class */
                     49:     wc.style         = 0;
                     50:     wc.lpfnWndProc   = FrameWndProc;
                     51:     wc.cbClsExtra    = 0;
                     52:     wc.cbWndExtra    = 0;
                     53:     wc.hInstance     = hInst;
                     54:     wc.hIcon         = LoadIcon(hInst,MAKEINTRESOURCE(IDCLIENT));
                     55:     wc.hCursor       = LoadCursor(NULL,IDC_ARROW);
                     56:     wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE+1);
                     57:     wc.lpszMenuName  = MAKEINTRESOURCE(IDCLIENT);
                     58:     wc.lpszClassName = szFrame;
                     59: 
                     60:     if (!RegisterClass (&wc) )
                     61:         return FALSE;
                     62: 
                     63:     /* Register the MDI child class */
1.1.1.3 ! root       64:     wc.style         = WS_CLIPCHILDREN;
1.1       root       65:     wc.lpfnWndProc   = MDIChildWndProc;
                     66:     wc.hIcon         = LoadIcon(hInst,MAKEINTRESOURCE(IDCONV));
                     67:     wc.lpszMenuName  = NULL;
                     68:     wc.cbWndExtra    = CHILDCBWNDEXTRA;
                     69:     wc.lpszClassName = szChild;
                     70: 
                     71:     if (!RegisterClass(&wc))
                     72:         return FALSE;
                     73: 
                     74:     wc.hIcon         = LoadIcon(hInst, MAKEINTRESOURCE(IDLIST));
                     75:     wc.lpszClassName = szList;
                     76: 
                     77:     if (!RegisterClass(&wc))
                     78:         return FALSE;
                     79: 
                     80:     return TRUE;
                     81: 
                     82: }
                     83: 
                     84: /****************************************************************************
                     85:  *                                                                          *
                     86:  *  FUNCTION   : InitializeInstance ()                                      *
                     87:  *                                                                          *
                     88:  *  PURPOSE    : Performs a per-instance initialization of Client.          *
                     89:  *               - Enlarges message queue to handle lots of DDE messages.   *
                     90:  *               - Initializes DDEML for this app                           *
                     91:  *               - Creates atoms for our custom formats                     *
                     92:  *               - Creates the main frame window                            *
                     93:  *               - Loads accelerator table                                  *
                     94:  *               - Shows main frame window                                  *
                     95:  *                                                                          *
                     96:  *  RETURNS    : TRUE  - If initialization was successful.                  *
                     97:  *               FALSE - otherwise.                                         *
                     98:  *                                                                          *
                     99:  ****************************************************************************/
                    100: BOOL  APIENTRY InitializeInstance(
                    101: DWORD nCmdShow)
                    102: {
                    103:     extern HWND  hwndMDIClient;
                    104:     CHAR         sz[80];
                    105:     INT          i;
                    106: 
                    107:     if (DdeInitialize(&idInst, (PFNCALLBACK)MakeProcInstance(
                    108:             (FARPROC)DdeCallback, hInst), APPCMD_CLIENTONLY, 0L))
                    109:         return FALSE;
                    110: 
                    111:     CCFilter.iCodePage = CP_WINANSI;
                    112: 
                    113:     for (i = 0; i < CFORMATS; i++) {
                    114:         if (aFormats[i].fmt == 0)
                    115:             aFormats[i].fmt = RegisterClipboardFormat(aFormats[i].sz);
                    116:     }
1.1.1.2   root      117:     hszHuge = DdeCreateStringHandle(idInst, "Huge", 0);
1.1       root      118: 
                    119:     /* Get the base window title */
                    120:     LoadString(hInst, IDS_APPNAME, sz, sizeof(sz));
                    121: 
                    122:     /* Create the frame */
                    123:     hwndFrame = CreateWindow (szFrame,
                    124:                               sz,
                    125:                               WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                    126:                               CW_USEDEFAULT,
                    127:                               CW_USEDEFAULT,
                    128:                               400,
                    129:                               200,
                    130:                               NULL,
                    131:                               NULL,
                    132:                               hInst,
                    133:                               NULL);
                    134: 
                    135:     if (!hwndFrame || !hwndMDIClient)
                    136:         return FALSE;
                    137: 
                    138:     /* Load main menu accelerators */
                    139:     if (!(hAccel = LoadAccelerators (hInst, MAKEINTRESOURCE(IDCLIENT))))
                    140:         return FALSE;
                    141: 
                    142:     /* Display the frame window */
                    143:     ShowWindow (hwndFrame, nCmdShow);
                    144:     UpdateWindow (hwndFrame);
                    145: 
                    146:     /*
                    147:      * We set this hook up so that we can catch the MSGF_DDEMGR filter
                    148:      * which is called when DDEML is in a modal loop during synchronous
                    149:      * transaction processing.
                    150:      */
                    151:     lpMsgFilterProc = (FARPROC)MakeProcInstance((FARPROC)MyMsgFilterProc, hInst);
1.1.1.2   root      152:     ghhk = SetWindowsHookEx(WH_MSGFILTER, (HOOKPROC)lpMsgFilterProc, NULL,
                    153:             GetCurrentThreadId());
1.1       root      154: 
                    155:     return TRUE;
                    156: }
                    157: 
                    158: 
                    159: 

unix.superglobalmegacorp.com

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