Annotation of mstools/ole20/samples/dispdemo/winmain.cpp, revision 1.1

1.1     ! root        1: /*** 
        !             2: *dispdemo.c - IDespatch demo/sample client application.
        !             3: *
        !             4: *  Copyright (C) 1992, Microsoft Corporation.  All Rights Reserved.
        !             5: *  Information Contained Herein Is Proprietary and Confidential.
        !             6: *
        !             7: *Purpose:
        !             8: *  This module is the main entry point for the sample IDispatch client,
        !             9: *  dispdemo.exe.
        !            10: *
        !            11: *  This program is intended to demonstrate a client invoking methods
        !            12: *  and referencing properties on a remote object via the IDispatch
        !            13: *  interface.
        !            14: *
        !            15: *  The bulk of the sample can be found in the file crempoly.cpp, which
        !            16: *  implements CRemPoly, the remote polygon class.
        !            17: *
        !            18: *Implementation Notes:
        !            19: *
        !            20: *****************************************************************************/
        !            21: 
        !            22: #include "dispdemo.h"
        !            23: 
        !            24: extern BOOL g_fTrace;
        !            25: 
        !            26: BOOL InitApplication(HANDLE);
        !            27: BOOL InitInstance(HANDLE, int);
        !            28: BOOL FAR PASCAL About(HWND, unsigned, WORD, LONG);
        !            29: 
        !            30: extern "C" {
        !            31: int PASCAL WinMain(HANDLE, HANDLE, LPSTR, int);
        !            32: LRESULT FAR PASCAL MainWndProc(HWND, UINT, WPARAM, LPARAM);
        !            33: }
        !            34: 
        !            35: HANDLE g_hInst;
        !            36: 
        !            37: char g_szDispDemoWClass[] = "DispDemoWClass";
        !            38: 
        !            39: extern "C" int PASCAL
        !            40: WinMain(
        !            41:     HANDLE hinst,
        !            42:     HANDLE hPrevInstance,
        !            43:     LPSTR lpCmdLine,
        !            44:     int nCmdShow)
        !            45: {
        !            46:     MSG msg;
        !            47: 
        !            48: 
        !            49:     (lpCmdLine); // UNUSED
        !            50: 
        !            51:     if(!hPrevInstance)
        !            52:       if(!InitApplication(hinst))
        !            53:        return FALSE;
        !            54: 
        !            55:     if(InitOle() != NOERROR)
        !            56:       return FALSE;
        !            57: 
        !            58:     if(!InitInstance(hinst, nCmdShow))
        !            59:       return FALSE;
        !            60: 
        !            61:     while(GetMessage(&msg, NULL, 0, 0)) {
        !            62:       TranslateMessage(&msg);
        !            63:       DispatchMessage(&msg);
        !            64:     }
        !            65: 
        !            66:     UninitOle();
        !            67: 
        !            68:     return msg.wParam;
        !            69: }
        !            70: 
        !            71: 
        !            72: BOOL
        !            73: InitApplication(HANDLE hinst)
        !            74: {
        !            75:     WNDCLASS  wc;
        !            76: 
        !            77:     wc.style           = NULL;
        !            78:     wc.lpfnWndProc     = MainWndProc;
        !            79:     wc.cbClsExtra      = 0;
        !            80:     wc.cbWndExtra      = 0;
        !            81:     wc.hInstance       = hinst;
        !            82:     wc.hIcon           = LoadIcon(hinst, "DISPDEMO");
        !            83:     wc.hCursor         = LoadCursor(NULL, IDC_ARROW);
        !            84:     wc.hbrBackground   = GetStockObject(WHITE_BRUSH); 
        !            85:     wc.lpszMenuName    = "DispDemoMenu";
        !            86:     wc.lpszClassName   = g_szDispDemoWClass;
        !            87:     if(!RegisterClass(&wc))
        !            88:       return FALSE;
        !            89: 
        !            90:     return TRUE;
        !            91: }
        !            92: 
        !            93: 
        !            94: BOOL
        !            95: InitInstance(HANDLE hinst, int nCmdShow)
        !            96: {
        !            97:     HWND hWnd;
        !            98: 
        !            99:     g_hInst = hinst;
        !           100: 
        !           101:     hWnd = CreateWindow(
        !           102:       g_szDispDemoWClass,
        !           103:       "IDispatch Demo App",
        !           104:       WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,
        !           105:       CW_USEDEFAULT, CW_USEDEFAULT, 300, 100,
        !           106:       NULL, NULL, hinst, NULL);
        !           107: 
        !           108:     if(!hWnd)
        !           109:       return FALSE;
        !           110: 
        !           111:     ShowWindow(hWnd, nCmdShow);
        !           112:     UpdateWindow(hWnd);
        !           113: 
        !           114:     return TRUE;
        !           115: }
        !           116: 
        !           117: 
        !           118: BOOL FAR PASCAL
        !           119: About(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
        !           120: {
        !           121:     switch(message){
        !           122:     case WM_INITDIALOG:
        !           123:       return TRUE;
        !           124: 
        !           125:     case WM_COMMAND:
        !           126:       switch(wParam){
        !           127:       case IDOK:
        !           128:       case IDCANCEL:
        !           129:        EndDialog(hDlg, TRUE);
        !           130:        return TRUE;
        !           131:       }
        !           132:       break;
        !           133:     }
        !           134:     return FALSE;
        !           135: }
        !           136: 
        !           137: 
        !           138: extern "C" LRESULT FAR PASCAL
        !           139: MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
        !           140: {
        !           141:     HMENU hmenu;
        !           142: static FARPROC pfnAbout;
        !           143: 
        !           144:     switch(message){
        !           145:     case WM_COMMAND:
        !           146:       switch(wParam){
        !           147:       case IDM_TRACE:
        !           148:        /* enable/disable trace */
        !           149:        g_fTrace = (g_fTrace) ? FALSE : TRUE;
        !           150:        hmenu = GetMenu(hwnd);
        !           151:        CheckMenuItem(hmenu, IDM_TRACE, g_fTrace ? MF_CHECKED : MF_UNCHECKED);
        !           152:        return 0;
        !           153: 
        !           154:       case IDM_POLY:
        !           155:        DoPoly(CLSID_CPoly);
        !           156:        return 0;
        !           157: 
        !           158:       case IDM_POLY2:
        !           159:        DoPoly(CLSID_CPoly2);
        !           160:        return 0;
        !           161: 
        !           162:       case IDM_ABOUT:
        !           163:        pfnAbout = (FARPROC)MakeProcInstance((FARPROC)About, g_hInst);
        !           164:        DialogBox(g_hInst, "AboutBox", hwnd, pfnAbout);
        !           165:        FreeProcInstance(pfnAbout);
        !           166:        return 0;
        !           167:       }
        !           168:       break;
        !           169: 
        !           170:     case WM_CLOSE:
        !           171:       DestroyWindow(hwnd);
        !           172:       return 0;
        !           173: 
        !           174:     case WM_DESTROY:
        !           175:       PostQuitMessage(0);
        !           176:       return 0;
        !           177:     }
        !           178:     return DefWindowProc(hwnd, message, wParam, lParam);
        !           179: }
        !           180: 

unix.superglobalmegacorp.com

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