Annotation of mstools/ole20/samples/outline/main.c, revision 1.1

1.1     ! root        1: /*************************************************************************
        !             2: ** 
        !             3: **    OLE 2 Sample Code
        !             4: **    
        !             5: **    main.c
        !             6: **    
        !             7: **    This file contains initialization functions which are WinMain,
        !             8: **    WndProc, and OutlineApp_InitalizeMenu.
        !             9: **    
        !            10: **    (c) Copyright Microsoft Corp. 1992 - 1993 All Rights Reserved
        !            11: **
        !            12: *************************************************************************/
        !            13: 
        !            14: #if defined( OLE_SERVER ) || defined( OLE_CNTR )
        !            15: // OLE2NOTE: we must force our CLSID GUIDs to be initialized exactly once.
        !            16: #define INITCLSID
        !            17: #endif
        !            18: 
        !            19: #include "outline.h"
        !            20: #if defined( USE_STATUSBAR )
        !            21: #include "status.h"
        !            22: #endif  
        !            23: 
        !            24: #if !defined( WIN32 )
        !            25: #if defined( USE_CTL3D )
        !            26: #include "ctl3d.h"
        !            27: #endif  // USE_CTL3D
        !            28: #endif  // !WIN32
        !            29: 
        !            30: #if defined( OLE_CNTR )
        !            31: 
        !            32: #if defined( INPLACE_CNTR )
        !            33: OLEDBGDATA_MAIN("ICNTR")
        !            34: #else 
        !            35: OLEDBGDATA_MAIN("CNTR")
        !            36: #endif 
        !            37: 
        !            38: CONTAINERAPP g_OutlineApp;  // Global App object maintains app instance state
        !            39: 
        !            40: /* Global interface Vtbl's
        !            41:  * OLE2NOTE: we only need one copy of each Vtbl. When an object which 
        !            42:  *      exposes an interface is instantiated, its lpVtbl is intialized
        !            43:  *      to point to one of these global Vtbl's.
        !            44:  */
        !            45: IUnknownVtbl            g_OleApp_UnknownVtbl;
        !            46: IClassFactoryVtbl       g_OleApp_ClassFactoryVtbl;
        !            47: IMessageFilterVtbl      g_OleApp_MessageFilterVtbl;
        !            48: 
        !            49: IUnknownVtbl            g_OleDoc_UnknownVtbl;
        !            50: IPersistFileVtbl        g_OleDoc_PersistFileVtbl;
        !            51: IOleItemContainerVtbl   g_OleDoc_OleItemContainerVtbl;
        !            52: IDataObjectVtbl         g_OleDoc_DataObjectVtbl;
        !            53: 
        !            54: #if defined( USE_DRAGDROP )
        !            55: IDropSourceVtbl         g_OleDoc_DropSourceVtbl;
        !            56: IDropTargetVtbl         g_OleDoc_DropTargetVtbl;
        !            57: #endif  // USE_DRAGDROP
        !            58: 
        !            59: IOleUILinkContainerVtbl g_CntrDoc_OleUILinkContainerVtbl;
        !            60: 
        !            61: IOleClientSiteVtbl      g_CntrLine_UnknownVtbl;
        !            62: IOleClientSiteVtbl      g_CntrLine_OleClientSiteVtbl;
        !            63: IAdviseSinkVtbl         g_CntrLine_AdviseSinkVtbl;
        !            64: 
        !            65: #if defined( INPLACE_CNTR )
        !            66: IOleInPlaceSiteVtbl     g_CntrLine_OleInPlaceSiteVtbl;
        !            67: IOleInPlaceFrameVtbl    g_CntrApp_OleInPlaceFrameVtbl;
        !            68: BOOL g_fInsideOutContainer = FALSE;     // default to outside-in activation
        !            69: #endif  // INPLACE_CNTR
        !            70: 
        !            71: 
        !            72: #elif defined( OLE_SERVER )
        !            73: 
        !            74: 
        !            75: #if defined( INPLACE_SVR )
        !            76: OLEDBGDATA_MAIN("ISVR")
        !            77: #else 
        !            78: OLEDBGDATA_MAIN("SVR")
        !            79: #endif 
        !            80: 
        !            81: SERVERAPP g_OutlineApp; // Global App object maintains app instance state
        !            82: 
        !            83: /* Global interface Vtbl's
        !            84:  * OLE2NOTE: we only need one copy of each Vtbl. When an object which 
        !            85:  *      exposes an interface is instantiated, its lpVtbl is intialized
        !            86:  *      to point to one of these global Vtbl's.
        !            87:  */
        !            88: IUnknownVtbl            g_OleApp_UnknownVtbl;
        !            89: IClassFactoryVtbl       g_OleApp_ClassFactoryVtbl;
        !            90: IMessageFilterVtbl      g_OleApp_MessageFilterVtbl;
        !            91: 
        !            92: IUnknownVtbl            g_OleDoc_UnknownVtbl;
        !            93: IPersistFileVtbl        g_OleDoc_PersistFileVtbl;
        !            94: IOleItemContainerVtbl   g_OleDoc_OleItemContainerVtbl;
        !            95: IDataObjectVtbl         g_OleDoc_DataObjectVtbl;
        !            96: 
        !            97: #if defined( USE_DRAGDROP )
        !            98: IDropSourceVtbl         g_OleDoc_DropSourceVtbl;
        !            99: IDropTargetVtbl         g_OleDoc_DropTargetVtbl;
        !           100: #endif  // USE_DRAGDROP
        !           101: 
        !           102: IOleObjectVtbl          g_SvrDoc_OleObjectVtbl;
        !           103: IPersistStorageVtbl     g_SvrDoc_PersistStorageVtbl;
        !           104: 
        !           105: #if defined( SVR_TREATAS )
        !           106: IStdMarshalInfoVtbl            g_SvrDoc_StdMarshalInfoVtbl;
        !           107: #endif // SVR_TREATAS
        !           108: 
        !           109: #if defined( INPLACE_SVR )
        !           110: IOleInPlaceObjectVtbl       g_SvrDoc_OleInPlaceObjectVtbl;
        !           111: IOleInPlaceActiveObjectVtbl g_SvrDoc_OleInPlaceActiveObjectVtbl;
        !           112: #endif // INPLACE_SVR
        !           113: 
        !           114: IUnknownVtbl            g_PseudoObj_UnknownVtbl;
        !           115: IOleObjectVtbl          g_PseudoObj_OleObjectVtbl;
        !           116: IDataObjectVtbl         g_PseudoObj_DataObjectVtbl;
        !           117: 
        !           118: #else 
        !           119: 
        !           120: OLEDBGDATA_MAIN("OUTL")
        !           121: 
        !           122: OUTLINEAPP g_OutlineApp;    // Global App object maintains app instance state
        !           123: 
        !           124: #endif
        !           125: 
        !           126: 
        !           127: 
        !           128: LPOUTLINEAPP g_lpApp=(LPOUTLINEAPP)&g_OutlineApp;   // ptr to global app obj
        !           129: RECT        g_rectNull = {0, 0, 0, 0};
        !           130: UINT        g_uMsgHelp = 0;  // help msg from ole2ui dialogs 
        !           131: 
        !           132: 
        !           133: /* WinMain
        !           134: ** -------
        !           135: **    Main routine for the Windows application.
        !           136: */
        !           137: int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
        !           138:                         LPSTR lpszCmdLine, int nCmdShow)
        !           139: {
        !           140:     LPOUTLINEAPP lpOutlineApp = (LPOUTLINEAPP)g_lpApp;
        !           141:     MSG         msg;            /* MSG structure to store your messages */
        !           142: 
        !           143: #if defined( OLE_VERSION )
        !           144:     /* OLE2NOTE: it is recommended that all OLE applications to set
        !           145:     **    their message queue size to 96. this improves the capacity
        !           146:     **    and performance of OLE's LRPC mechanism.
        !           147:     */
        !           148:     int cMsg = 96;   // recommend msg queue size for OLE
        !           149:     while (cMsg && ! SetMessageQueue(cMsg))  // take largest size we can get.
        !           150:         cMsg -= 8;   
        !           151:     if (! cMsg) 
        !           152:         return -1;  // ERROR: we got no message queue
        !           153: #endif
        !           154: 
        !           155: #if defined( USE_CTL3D )
        !           156:    Ctl3dRegister(hInstance);
        !           157:    Ctl3dAutoSubclass(hInstance);
        !           158: #endif
        !           159: 
        !           160:     if(! hPrevInstance) {
        !           161:         /* register window classes if first instance of application */
        !           162:         if(! OutlineApp_InitApplication(lpOutlineApp, hInstance))
        !           163:             return 0;
        !           164:     }
        !           165: 
        !           166:     /* Create App Frame window */
        !           167:     if (! OutlineApp_InitInstance(lpOutlineApp, hInstance, nCmdShow)) 
        !           168:         return 0;
        !           169: 
        !           170:     if (! OutlineApp_ParseCmdLine(lpOutlineApp, lpszCmdLine, nCmdShow))
        !           171:         return 0;
        !           172: 
        !           173:     lpOutlineApp->m_hAccelApp = LoadAccelerators(hInstance, APPACCEL);
        !           174:     lpOutlineApp->m_hAccelFocusEdit = LoadAccelerators(hInstance, 
        !           175:             FB_EDIT_ACCEL);
        !           176:     lpOutlineApp->m_hAccel = lpOutlineApp->m_hAccelApp;
        !           177:     lpOutlineApp->m_hWndAccelTarget = lpOutlineApp->m_hWndApp;
        !           178: 
        !           179: 
        !           180:     // Main message loop
        !           181:     while(GetMessage(&msg, NULL, 0, 0)) {        /* Until WM_QUIT message */
        !           182:         if(!MyTranslateAccelerator(&msg)) {
        !           183:             TranslateMessage(&msg);
        !           184:             DispatchMessage(&msg);
        !           185:         }
        !           186:     }
        !           187:     
        !           188: #if defined( OLE_VERSION )
        !           189:     OleApp_TerminateApplication((LPOLEAPP)lpOutlineApp);
        !           190: #else 
        !           191:        /* OLE2NOTE: CoInitialize() is called in OutlineApp_InitInstance
        !           192:        **    and therefore we need to uninitialize it when exit. 
        !           193:        */
        !           194:        CoUninitialize();
        !           195: #endif
        !           196: 
        !           197: #if defined( USE_CTL3D )
        !           198:    Ctl3dUnregister(hInstance);
        !           199: #endif
        !           200: 
        !           201:     return msg.wParam;
        !           202: 
        !           203: } /*  End of WinMain */
        !           204: 
        !           205: 
        !           206: BOOL MyTranslateAccelerator(LPMSG lpmsg)
        !           207: {
        !           208:     if (g_lpApp->m_hWndAccelTarget &&
        !           209:                TranslateAccelerator(g_lpApp->m_hWndAccelTarget,
        !           210:                                                                                                        g_lpApp->m_hAccel,lpmsg))
        !           211:         return TRUE;
        !           212:     
        !           213: #if defined( INPLACE_SVR )
        !           214: 
        !           215:        /* OLE2NOTE: if we are in-place active and we did not translate the
        !           216:        **    accelerator, we need to give the top-level (frame) in-place
        !           217:        **    container a chance to translate the accelerator.
        !           218:        */
        !           219:     if (g_OutlineApp.m_lpIPData) {
        !           220:         if (OleTranslateAccelerator(g_OutlineApp.m_lpIPData->lpFrame, 
        !           221:                 (LPOLEINPLACEFRAMEINFO)&g_OutlineApp.m_lpIPData->frameInfo,
        !           222:                 lpmsg) == NOERROR)
        !           223:             return TRUE;
        !           224:     }
        !           225: #endif
        !           226: 
        !           227:     return FALSE;
        !           228: }
        !           229: 
        !           230: 
        !           231: /************************************************************************/
        !           232: /*                                                                      */
        !           233: /* Main Window Procedure                                                */
        !           234: /*                                                                      */
        !           235: /* This procedure provides service routines for the Windows events      */
        !           236: /* (messages) that Windows sends to the window, as well as the user     */
        !           237: /* initiated events (messages) that are generated when the user selects */
        !           238: /* the action bar and pulldown menu controls or the corresponding       */
        !           239: /* keyboard accelerators.                                               */
        !           240: /*                                                                      */
        !           241: /************************************************************************/
        !           242: 
        !           243: LRESULT FAR PASCAL AppWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
        !           244: {
        !           245:     LPOUTLINEAPP lpOutlineApp = (LPOUTLINEAPP)GetWindowLong(hWnd, 0);
        !           246:     LPOUTLINEDOC lpOutlineDoc = NULL;
        !           247:     HWND         hWndDoc = NULL;
        !           248:     HWND         hWndStatusBar = NULL;
        !           249: 
        !           250: #if defined( USE_FRAMETOOLS )
        !           251:     LPFRAMETOOLS lptb = OutlineApp_GetFrameTools(lpOutlineApp);
        !           252: #endif
        !           253: 
        !           254:     if (lpOutlineApp) {
        !           255:         lpOutlineDoc = OutlineApp_GetActiveDoc(lpOutlineApp);
        !           256: 
        !           257:         if (lpOutlineDoc) 
        !           258:             hWndDoc = OutlineDoc_GetWindow(lpOutlineDoc);
        !           259:         hWndStatusBar = OutlineApp_GetStatusWindow(lpOutlineApp);
        !           260:     }
        !           261: 
        !           262:     switch (Message) {
        !           263:         case WM_COMMAND:
        !           264:         {
        !           265: #ifdef WIN32
        !           266:                                WORD wID    = LOWORD(wParam);
        !           267: #else
        !           268:                                WORD wID    = wParam;
        !           269: #endif
        !           270: 
        !           271: 
        !           272:             switch (wID) {
        !           273: 
        !           274:                 case IDM_F_NEW:
        !           275: 
        !           276:                     OleDbgIndent(-2);   // Reset debug output indent level
        !           277: 
        !           278:                     OleDbgOutNoPrefix2("\r\n");
        !           279:                     OLEDBG_BEGIN2("OutlineApp_NewCommand\r\n")
        !           280: 
        !           281:                     OutlineApp_NewCommand(lpOutlineApp);
        !           282:                 
        !           283:                     OLEDBG_END2
        !           284: 
        !           285: #if defined( USE_FRAMETOOLS )
        !           286:                     OutlineDoc_UpdateFrameToolButtons(
        !           287:                             OutlineApp_GetActiveDoc(lpOutlineApp));
        !           288: #endif                      
        !           289:                     break;
        !           290: 
        !           291:                 case IDM_F_OPEN:
        !           292: 
        !           293:                     OleDbgOutNoPrefix2("\r\n");
        !           294:                     OLEDBG_BEGIN2("OutlineApp_OpenCommand\r\n")
        !           295:                         
        !           296:                     OutlineApp_OpenCommand(lpOutlineApp);
        !           297:                 
        !           298:                     OLEDBG_END2
        !           299:                         
        !           300: #if defined( USE_FRAMETOOLS )
        !           301:                     OutlineDoc_UpdateFrameToolButtons(
        !           302:                             OutlineApp_GetActiveDoc(lpOutlineApp));
        !           303: #endif                      
        !           304:                     break;
        !           305: 
        !           306:                 case IDM_F_SAVE:
        !           307: 
        !           308:                     OleDbgOutNoPrefix2("\r\n");
        !           309:                     OLEDBG_BEGIN2("OutlineApp_SaveCommand\r\n")
        !           310:                         
        !           311:                     OutlineApp_SaveCommand(lpOutlineApp);
        !           312:                 
        !           313:                     OLEDBG_END2
        !           314:                     break;
        !           315: 
        !           316:                 case IDM_F_SAVEAS:
        !           317: 
        !           318:                     OleDbgOutNoPrefix2("\r\n");
        !           319:                     OLEDBG_BEGIN2("OutlineApp_SaveAsCommand\r\n")
        !           320:                         
        !           321:                     OutlineApp_SaveAsCommand(lpOutlineApp);
        !           322:                 
        !           323:                     OLEDBG_END2
        !           324:                     break;
        !           325: 
        !           326:                 case IDM_F_PRINT:
        !           327: 
        !           328:                     OleDbgOutNoPrefix2("\r\n");
        !           329:                     OLEDBG_BEGIN2("OutlineApp_PrintCommand\r\n")
        !           330:                         
        !           331:                     OutlineApp_PrintCommand(lpOutlineApp);
        !           332:                 
        !           333:                     OLEDBG_END2
        !           334:                     break;
        !           335: 
        !           336:                 case IDM_F_PRINTERSETUP:
        !           337: 
        !           338:                     OleDbgOutNoPrefix2("\r\n");
        !           339:                     OLEDBG_BEGIN2("OutlineApp_PrinterSetupCommand\r\n")
        !           340:                         
        !           341:                     OutlineApp_PrinterSetupCommand(lpOutlineApp);
        !           342:                 
        !           343:                     OLEDBG_END2
        !           344:                     break;
        !           345: 
        !           346:                 case IDM_F_EXIT:
        !           347:                     SendMessage(hWnd, WM_CLOSE, 0, 0L);
        !           348:                     break;
        !           349: 
        !           350:                 case IDM_H_ABOUT:
        !           351:                     OutlineApp_AboutCommand(lpOutlineApp);
        !           352:                     break;
        !           353:                                        
        !           354:                 default:
        !           355:                     // forward message to document window
        !           356:                     if (hWndDoc) {
        !           357:                         return DocWndProc(hWndDoc, Message,wParam,lParam);
        !           358:                     }
        !           359:             }
        !           360:             
        !           361:             break;  /* End of WM_COMMAND */
        !           362:         }
        !           363:         case WM_INITMENU:
        !           364:             OutlineApp_InitMenu(lpOutlineApp, lpOutlineDoc, (HMENU)wParam);
        !           365:             break;
        !           366: 
        !           367: #if defined( OLE_VERSION )
        !           368: 
        !           369:                /* OLE2NOTE: WM_INITMENUPOPUP is trapped primarily for the Edit
        !           370:                **    menu. We didn't update the Edit menu until it is popped
        !           371:                **    up to avoid the overheads of the OLE calls which are
        !           372:                **    required to initialize some Edit menu items. 
        !           373:                */
        !           374:                case WM_INITMENUPOPUP:
        !           375:                {
        !           376:             HMENU hMenuEdit = GetSubMenu(lpOutlineApp->m_hMenuApp, 1);
        !           377: #if defined( INPLACE_CNTR )
        !           378:                        LPCONTAINERDOC lpContainerDoc = (LPCONTAINERDOC)lpOutlineDoc;
        !           379: 
        !           380:                        /* OLE2NOTE: we must check if there is an object currently
        !           381:                        **    in-place UIActive. if so, then our edit menu is not
        !           382:                        **    on the menu; we do not want to bother updating the
        !           383:                        **    edit menu when it is not even there. 
        !           384:                        */
        !           385:                        if (lpContainerDoc && lpContainerDoc->m_lpLastUIActiveLine &&
        !           386:                                lpContainerDoc->m_lpLastUIActiveLine->m_fUIActive)
        !           387:                                break;  // an object is in-place UI active
        !           388: #endif                 
        !           389:                        if ((HMENU)wParam == hMenuEdit &&
        !           390:                 (LOWORD(lParam) == POS_EDITMENU) && 
        !           391:                                OleDoc_GetUpdateEditMenuFlag((LPOLEDOC)lpOutlineDoc)) {
        !           392:                                OleApp_UpdateEditMenu(
        !           393:                         (LPOLEAPP)lpOutlineApp, lpOutlineDoc, hMenuEdit);
        !           394:                        }
        !           395:                        break;
        !           396:                }
        !           397: #endif                 // OLE_VERSION
        !           398:                        
        !           399:         case WM_SIZE:
        !           400:             if (wParam != SIZE_MINIMIZED)
        !           401:                 OutlineApp_ResizeWindows(lpOutlineApp);
        !           402:             break;
        !           403: 
        !           404:         case WM_ACTIVATEAPP:
        !           405: 
        !           406: #if defined( INPLACE_CNTR )
        !           407:             {
        !           408:                 LPCONTAINERAPP lpContainerApp = (LPCONTAINERAPP)lpOutlineApp;
        !           409:                 LPOLEINPLACEACTIVEOBJECT lpIPActiveObj = 
        !           410:                         lpContainerApp->m_lpIPActiveObj;
        !           411: 
        !           412:                 /* OLE2NOTE: the in-place container MUST inform the
        !           413:                 **    inner most in-place active object (this is NOT
        !           414:                 **    necessarily our immediate child if there are
        !           415:                 **    nested levels of embedding) of the WM_ACTIVATEAPP
        !           416:                 **    status.
        !           417:                 */
        !           418:                 if (lpIPActiveObj) {
        !           419:                     OLEDBG_BEGIN2("IOleInPlaceActiveObject::OnFrameWindowActivate called\r\n")
        !           420:                     lpIPActiveObj->lpVtbl->OnFrameWindowActivate(
        !           421:                         lpIPActiveObj, 
        !           422:                         (wParam ? TRUE : FALSE)
        !           423:                     );
        !           424:                     OLEDBG_END2
        !           425:                 }
        !           426:             }
        !           427: #endif  // INPLACE_CNTR
        !           428: 
        !           429:             // OLE2NOTE: We can't call OutlineDoc_UpdateFrameToolButtons
        !           430:                        //           right away which 
        !           431:             //           would generate some OLE calls and eventually 
        !           432:             //           WM_ACTIVATEAPP and a loop was formed. Therefore, we
        !           433:             //           should delay the frame tool initialization until 
        !           434:                        //                       WM_ACTIVATEAPP is finished by posting a message
        !           435:                        //                       to ourselves.
        !           436:             
        !           437:             /* Update enable/disable state of buttons in toolbar */
        !           438:             if (wParam) 
        !           439:                 PostMessage(hWnd, WM_U_INITFRAMETOOLS, 0, 0L);
        !           440:             break;
        !           441:             
        !           442:         case WM_SETFOCUS:
        !           443:             SetFocus(hWndDoc);
        !           444:             break;
        !           445: 
        !           446:         case WM_DESTROY:
        !           447:             PostQuitMessage(0);
        !           448:             break;
        !           449:             
        !           450:         case WM_CLOSE:  /* close the window */
        !           451: 
        !           452:             /* Close all active documents. if successful, then exit */
        !           453:  
        !           454:             OleDbgOutNoPrefix2("\r\n");
        !           455: 
        !           456:             OutlineApp_CloseAllDocsAndExitCommand(lpOutlineApp);
        !           457:             break;
        !           458:                
        !           459:                case WM_QUERYENDSESSION:
        !           460:                        
        !           461:                        if (OutlineApp_CloseAllDocsAndExitCommand(lpOutlineApp))
        !           462:                 return 1L;             /* can terminate */
        !           463: 
        !           464:                        /* else: can't terminate now */
        !           465:                        break;
        !           466: 
        !           467: #if defined( USE_STATUSBAR )
        !           468:         case WM_MENUSELECT:
        !           469:         {
        !           470: #ifdef WIN32
        !           471:             UINT fuFlags    = (UINT)HIWORD(wParam);
        !           472:                        UINT uItem      = (UINT)LOWORD(wParam);
        !           473: #else
        !           474:             UINT fuFlags    = (UINT)LOWORD(lParam);
        !           475:                        UINT uItem      = (UINT)wParam;
        !           476: #endif
        !           477: 
        !           478:             if (uItem == 0 && fuFlags == (UINT)-1) {
        !           479:                 ControlMessage(hWndStatusBar, STATUS_READY, lpOutlineDoc);
        !           480:             }
        !           481:             else if (fuFlags & MF_POPUP) {
        !           482: #ifdef WIN32
        !           483:                 HMENU hMainMenu = (HMENU)lParam;
        !           484:                 HMENU hPopupMenu = GetSubMenu(hMainMenu,uItem);
        !           485: #else
        !           486:                 HMENU hPopupMenu = (HMENU)wParam;
        !           487: #endif
        !           488:                 PopupMessage(hWndStatusBar, hPopupMenu, lpOutlineDoc);
        !           489:             }
        !           490:             else if (fuFlags & MF_SYSMENU) {
        !           491:                 SysMenuMessage(hWndStatusBar, uItem, lpOutlineDoc);
        !           492:             }
        !           493:             else if (uItem != 0) {  // Command Item
        !           494:                 ItemMessage(hWndStatusBar, uItem, lpOutlineDoc);
        !           495:             }
        !           496:             else {
        !           497:                 ControlMessage(hWndStatusBar, STATUS_BLANK, lpOutlineDoc);
        !           498:             }
        !           499:             break;
        !           500:         }
        !           501: #endif  
        !           502: 
        !           503: 
        !           504: #if defined( USE_FRAMETOOLS )
        !           505:         case WM_U_INITFRAMETOOLS:
        !           506:             OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !           507:             break;
        !           508: #endif
        !           509: 
        !           510:         default:
        !           511:             /* For any message for which you don't specifically provide a  */
        !           512:             /* service routine, you should return the message to Windows   */
        !           513:             /* for default message processing.                             */
        !           514: 
        !           515:             return DefWindowProc(hWnd, Message, wParam, lParam);
        !           516:     }
        !           517: 
        !           518:     return (LRESULT)0;
        !           519: }     /* End of AppWndProc                                         */
        !           520: 
        !           521: 
        !           522: /************************************************************************/
        !           523: /*                                                                      */
        !           524: /* Document Window Procedure                                            */
        !           525: /*                                                                      */
        !           526: /*   The Document Window is the parent of the OwnerDraw Listbox which   */
        !           527: /* maintains the list of lines in the current document. This window     */
        !           528: /* receives the ownerdraw callback messages from the list box.          */
        !           529: /************************************************************************/
        !           530: 
        !           531: LRESULT FAR PASCAL DocWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
        !           532: {
        !           533:     LPOUTLINEAPP       lpOutlineApp = (LPOUTLINEAPP)g_lpApp;
        !           534:     LPOUTLINEDOC       lpOutlineDoc = (LPOUTLINEDOC)GetWindowLong(hWnd, 0);
        !           535:     LPLINELIST         lpLL = OutlineDoc_GetLineList(lpOutlineDoc);
        !           536:        LPSCALEFACTOR   lpscale = OutlineDoc_GetScaleFactor(lpOutlineDoc);
        !           537: 
        !           538: #if defined( OLE_VERSION )
        !           539:     LPOLEAPP lpOleApp = (LPOLEAPP)lpOutlineApp;
        !           540:     LPOLEDOC lpOleDoc = (LPOLEDOC)lpOutlineDoc;
        !           541: #endif // OLE_VERSION
        !           542: 
        !           543:        switch(Message) {
        !           544:                        
        !           545:         case WM_MEASUREITEM:
        !           546:                {
        !           547:             LPMEASUREITEMSTRUCT lpmis = ((LPMEASUREITEMSTRUCT)lParam);
        !           548:             
        !           549:             switch (wParam) {
        !           550:                 case IDC_LINELIST:
        !           551:                 {
        !           552:                     HDC hDC = LineList_GetDC(lpLL);
        !           553:                     UINT uHeight;
        !           554:                     
        !           555:                     uHeight=Line_GetHeightInHimetric((LPLINE)lpmis->itemData);
        !           556:                                        uHeight = XformHeightInHimetricToPixels(hDC, uHeight);
        !           557:                                        uHeight = (UINT) (uHeight * lpscale->dwSyN / 
        !           558:                                                        lpscale->dwSyD);
        !           559:                                        
        !           560:                                        if (uHeight >LISTBOX_HEIGHT_LIMIT)
        !           561:                                                uHeight = LISTBOX_HEIGHT_LIMIT;
        !           562:                                        
        !           563:                                        lpmis->itemHeight = uHeight;
        !           564:                     LineList_ReleaseDC(lpLL, hDC);
        !           565:                     break;
        !           566:                 }
        !           567:                 
        !           568:                 case IDC_NAMETABLE:
        !           569:                 {
        !           570:                     // NOTE: NameTable is never made visible. do nothing.
        !           571:                     break;
        !           572:                 }
        !           573:                 
        !           574: #if defined( USE_HEADING )
        !           575:                                case IDC_ROWHEADING:
        !           576:                                {
        !           577:                                        UINT uHeight;
        !           578: 
        !           579:                                        uHeight = LOWORD(lpmis->itemData);
        !           580:                                        uHeight = (UINT) (uHeight * lpscale->dwSyN /
        !           581:                                                        lpscale->dwSyD);
        !           582:                                        if (uHeight >LISTBOX_HEIGHT_LIMIT)
        !           583:                                                uHeight = LISTBOX_HEIGHT_LIMIT;
        !           584:                                        lpmis->itemHeight = uHeight;
        !           585:                                        break;
        !           586:                                }
        !           587:                                        
        !           588:                                case IDC_COLHEADING:    
        !           589:                                {
        !           590:                                        UINT uHeight;
        !           591:                                        
        !           592:                                        uHeight = LOWORD(lpmis->itemData);
        !           593:                                        uHeight = (UINT) (uHeight * lpscale->dwSyN / 
        !           594:                                                        lpscale->dwSyD);
        !           595:                                        if (uHeight > LISTBOX_HEIGHT_LIMIT)
        !           596:                                                uHeight = LISTBOX_HEIGHT_LIMIT;
        !           597:                                        lpmis->itemHeight = uHeight;
        !           598:                                        break;
        !           599:                                }
        !           600: #endif
        !           601: 
        !           602:                        }
        !           603:             return (LRESULT)TRUE;
        !           604:         }
        !           605: 
        !           606:                case WM_DRAWITEM: 
        !           607:                {
        !           608:                        LPDRAWITEMSTRUCT lpdis = ((LPDRAWITEMSTRUCT)lParam);
        !           609: 
        !           610:                        switch (lpdis->CtlID) {
        !           611: 
        !           612:                 case IDC_LINELIST:
        !           613:                 {
        !           614:                     RECT   rcClient;
        !           615:                                        RECT   rcDevice;
        !           616:                     HWND   hWndLL = LineList_GetWindow(lpLL);
        !           617:                     LPLINE lpLine = (LPLINE)lpdis->itemData;
        !           618:                     
        !           619:                                        // NOTE: When itemID == -1, the listbox is empty. 
        !           620:                                        //       We are supposed to draw focus rect only 
        !           621:                                        //               But it is not done in this app. If this line is
        !           622:                                        //       removed, the app will crash in Line_DrawToScreen
        !           623:                                        //       because of invalid lpLine.
        !           624:                                        if (lpdis->itemID == -1) 
        !           625:                                                break;
        !           626:                                        
        !           627:                     GetClientRect(hWndLL, &rcClient);
        !           628: 
        !           629:                                        rcDevice = lpdis->rcItem;
        !           630:                                        
        !           631:                     // shift the item rect to account for horizontal scrolling
        !           632:                                        rcDevice.left += rcClient.right - lpdis->rcItem.right;
        !           633: 
        !           634:                                        // shift rect for left margin
        !           635:                                        rcDevice.left += (int)(XformWidthInHimetricToPixels(NULL,
        !           636:                                                        LOWORD(OutlineDoc_GetMargin(lpOutlineDoc))) *
        !           637:                                                        lpscale->dwSxN / lpscale->dwSxD);
        !           638:                                                
        !           639:                                        rcDevice.right = rcDevice.left +
        !           640:                                                        (int)(XformWidthInHimetricToPixels(lpdis->hDC,
        !           641:                                                                        Line_GetWidthInHimetric(lpLine)) *
        !           642:                                                        lpscale->dwSxN / lpscale->dwSxD);
        !           643:                                        
        !           644:                     Line_DrawToScreen(
        !           645:                             lpLine, 
        !           646:                             lpdis->hDC, 
        !           647:                             &lpdis->rcItem, 
        !           648:                             lpdis->itemAction, 
        !           649:                             lpdis->itemState,
        !           650:                                                        &rcDevice
        !           651:                     );
        !           652: 
        !           653: #if defined( USE_FRAMETOOLS )
        !           654:                     if (lpdis->itemState & ODS_FOCUS) 
        !           655:                         OutlineDoc_SetFormulaBarEditText(lpOutlineDoc,lpLine);
        !           656: #endif              
        !           657:                     break;
        !           658:                 }
        !           659:                 case IDC_NAMETABLE:
        !           660:                 {
        !           661:                     // NOTE: NameTable is never made visible. do nothing
        !           662:                     break;
        !           663:                 }
        !           664: 
        !           665: #if defined( USE_HEADING )
        !           666:                 case IDC_ROWHEADING:
        !           667:                 {
        !           668:                     LPHEADING lphead;
        !           669: 
        !           670:                                        // Last dummy item shouldn't be drawn
        !           671:                                        if (lpdis->itemID == (UINT)LineList_GetCount(lpLL))
        !           672:                                                break;
        !           673: 
        !           674:                                        // only DrawEntire need be trapped as window is disabled
        !           675:                                        if (lpdis->itemAction == ODA_DRAWENTIRE) {
        !           676:                                                lphead = OutlineDoc_GetHeading(lpOutlineDoc);
        !           677:                                                Heading_RH_Draw(lphead, lpdis);
        !           678:                                        }
        !           679:                     break;
        !           680:                 }
        !           681:                     
        !           682:                 case IDC_COLHEADING:
        !           683:                 {
        !           684:                     RECT   rect;
        !           685:                                        RECT   rcDevice;
        !           686:                                        RECT   rcLogical;
        !           687:                                        LPHEADING lphead;
        !           688:                                        
        !           689:                                        // only DrawEntire need be trapped as window is disabled
        !           690:                                        if (lpdis->itemAction == ODA_DRAWENTIRE) {
        !           691:                                                lphead = OutlineDoc_GetHeading(lpOutlineDoc);
        !           692:                                                GetClientRect(lpdis->hwndItem, &rect);
        !           693: 
        !           694:                                                rcDevice = lpdis->rcItem;
        !           695: 
        !           696:                                                // shift the item rect to account for 
        !           697:                                                // horizontal scrolling
        !           698:                                                rcDevice.left = -(rcDevice.right - rect.right);
        !           699: 
        !           700:                                                // shift rect for left margin
        !           701:                                                rcDevice.left += (int)(XformWidthInHimetricToPixels(
        !           702:                                                                NULL,
        !           703:                                                                LOWORD(OutlineDoc_GetMargin(lpOutlineDoc))) *
        !           704:                                                        lpscale->dwSxN / lpscale->dwSxD);
        !           705:                                                
        !           706:                                                rcDevice.right = rcDevice.left + (int)lpscale->dwSxN;
        !           707:                                                rcLogical.left = 0;
        !           708:                                                rcLogical.bottom = 0;
        !           709:                                                rcLogical.right = (int)lpscale->dwSxD;
        !           710:                                                rcLogical.top = LOWORD(lpdis->itemData);
        !           711: 
        !           712:                                                Heading_CH_Draw(lphead, lpdis, &rcDevice, &rcLogical);
        !           713:                                        }
        !           714:                                        break;
        !           715:                                }
        !           716: #endif
        !           717: 
        !           718:             }
        !           719:             return (LRESULT)TRUE;
        !           720:         } 
        !           721:         
        !           722:         case WM_SETFOCUS:
        !           723:             if (lpLL) 
        !           724:                 SetFocus(LineList_GetWindow(lpLL));
        !           725:             break;
        !           726: 
        !           727: #if !defined( OLE_VERSION )
        !           728: 
        !           729:         case WM_RENDERFORMAT:
        !           730:         {
        !           731:             LPOUTLINEDOC lpClipboardDoc = lpOutlineApp->m_lpClipboardDoc;
        !           732:             if (lpClipboardDoc) 
        !           733:                 OutlineDoc_RenderFormat(lpClipboardDoc, wParam);
        !           734: 
        !           735:             break;
        !           736:         }           
        !           737:         case WM_RENDERALLFORMATS:
        !           738:         {
        !           739:             LPOUTLINEDOC lpClipboardDoc = lpOutlineApp->m_lpClipboardDoc;
        !           740:             if (lpClipboardDoc) 
        !           741:                 OutlineDoc_RenderAllFormats(lpClipboardDoc);
        !           742: 
        !           743:             break;
        !           744:         }           
        !           745:         case WM_DESTROYCLIPBOARD:
        !           746:             if (g_lpApp->m_lpClipboardDoc) {
        !           747:                 OutlineDoc_Destroy(g_lpApp->m_lpClipboardDoc);
        !           748:                 g_lpApp->m_lpClipboardDoc = NULL;
        !           749:             }
        !           750:             break;
        !           751:             
        !           752: #endif   // OLE_VERSION
        !           753: 
        !           754: #if defined( OLE_CNTR )
        !           755:                case WM_U_UPDATEOBJECTEXTENT: 
        !           756:         {
        !           757:                        LPCONTAINERDOC lpContainerDoc = (LPCONTAINERDOC)lpOutlineDoc;
        !           758: 
        !           759:             /* Update the extents of any OLE object that is marked that
        !           760:             **    its size may  have changed. when an
        !           761:             **    IAdviseSink::OnViewChange notification is received,
        !           762:             **    the corresponding ContainerLine is marked
        !           763:             **    (m_fDoGetExtent==TRUE) and a message
        !           764:             **    (WM_U_UPDATEOBJECTEXTENT) is posted to the document
        !           765:             **    indicating that there are dirty objects.  
        !           766:             */
        !           767:             ContainerDoc_UpdateExtentOfAllOleObjects(lpContainerDoc);
        !           768:                        break;
        !           769:         }
        !           770: #endif  // OLE_CNTR
        !           771: 
        !           772: #if defined( INPLACE_SVR )
        !           773:         /* OLE2NOTE: when the in-place active, our in-place server
        !           774:         **    document window (passed to IOleInPlaceFrame::SetMenu)
        !           775:         **    will receive the WM_INITMENU and WM_INITMENUPOPUP messages.
        !           776:         */
        !           777: 
        !           778:         case WM_INITMENU:
        !           779:             OutlineApp_InitMenu(lpOutlineApp, lpOutlineDoc, (HMENU)wParam);
        !           780:             break;
        !           781: 
        !           782:                /* OLE2NOTE: WM_INITMENUPOPUP is trapped primarily for the Edit
        !           783:                **    menu. We didn't update the Edit menu until it is popped
        !           784:                **    up to avoid the overheads of the OLE calls which are
        !           785:                **    required to initialize some Edit menu items. 
        !           786:                */
        !           787:                case WM_INITMENUPOPUP:
        !           788:                {
        !           789:             HMENU hMenuEdit = GetSubMenu(lpOutlineApp->m_hMenuApp, 1);
        !           790:                        if ((HMENU)wParam == hMenuEdit &&
        !           791:                 (LOWORD(lParam) == POS_EDITMENU) && 
        !           792:                                OleDoc_GetUpdateEditMenuFlag((LPOLEDOC)lpOutlineDoc)) {
        !           793:                                OleApp_UpdateEditMenu(
        !           794:                         (LPOLEAPP)lpOutlineApp, lpOutlineDoc, hMenuEdit);
        !           795:                        }
        !           796:                        break;
        !           797:                }
        !           798: 
        !           799: #if defined( USE_FRAMETOOLS )
        !           800:         case WM_U_INITFRAMETOOLS:
        !           801:             OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !           802:             break;
        !           803: #endif      // USE_FRAMETOOLS
        !           804: 
        !           805: #endif      // INPLACE_SVR
        !           806: 
        !           807:         case WM_COMMAND:
        !           808:         {
        !           809: #ifdef WIN32
        !           810:                                WORD wNotifyCode = HIWORD(wParam);
        !           811:                                WORD wID                  = LOWORD(wParam);
        !           812:                                HWND hwndCtl     = (HWND) lParam;
        !           813: #else
        !           814:                                WORD wNotifyCode = HIWORD(lParam);
        !           815:                                WORD wID                     = wParam;
        !           816:                                HWND hwndCtl     = (HWND) LOWORD(lParam);
        !           817: #endif
        !           818: 
        !           819: 
        !           820:             switch (wID) {
        !           821:                                
        !           822:                                /*********************************************************
        !           823:                                ** File new, open, save and print as well as Help about
        !           824:                                **    are duplicated in this switch statement and they are
        !           825:                                **    used to trap the message from the toolbar
        !           826:                                **    
        !           827:                                *********************************************************/
        !           828: 
        !           829:                                case IDM_F_NEW:
        !           830: 
        !           831:                     OleDbgIndent(-2);   // Reset debug output indent level
        !           832: 
        !           833:                     OleDbgOutNoPrefix2("\r\n");
        !           834:                     OLEDBG_BEGIN2("OutlineApp_NewCommand\r\n")
        !           835: 
        !           836:                     OutlineApp_NewCommand(lpOutlineApp);
        !           837:                 
        !           838:                     OLEDBG_END2
        !           839: 
        !           840: #if defined( USE_FRAMETOOLS )
        !           841:                     OutlineDoc_UpdateFrameToolButtons(
        !           842:                             OutlineApp_GetActiveDoc(lpOutlineApp));
        !           843: #endif                      
        !           844:                     break;
        !           845: 
        !           846:                 case IDM_F_OPEN:
        !           847: 
        !           848:                     OleDbgOutNoPrefix2("\r\n");
        !           849:                     OLEDBG_BEGIN2("OutlineApp_OpenCommand\r\n")
        !           850:                         
        !           851:                     OutlineApp_OpenCommand(lpOutlineApp);
        !           852:                 
        !           853:                     OLEDBG_END2
        !           854:                         
        !           855: #if defined( USE_FRAMETOOLS )
        !           856:                     OutlineDoc_UpdateFrameToolButtons(
        !           857:                             OutlineApp_GetActiveDoc(lpOutlineApp));
        !           858: #endif                      
        !           859:                     break;
        !           860: 
        !           861:                 case IDM_F_SAVE:
        !           862: 
        !           863:                     OleDbgOutNoPrefix2("\r\n");
        !           864:                     OLEDBG_BEGIN2("OutlineApp_SaveCommand\r\n")
        !           865:                         
        !           866:                     OutlineApp_SaveCommand(lpOutlineApp);
        !           867:                 
        !           868:                     OLEDBG_END2
        !           869:                     break;
        !           870: 
        !           871:                 case IDM_F_PRINT:
        !           872: 
        !           873:                     OleDbgOutNoPrefix2("\r\n");
        !           874:                     OLEDBG_BEGIN2("OutlineApp_PrintCommand\r\n")
        !           875:                         
        !           876:                     OutlineApp_PrintCommand(lpOutlineApp);
        !           877:                 
        !           878:                     OLEDBG_END2
        !           879:                     break;
        !           880: 
        !           881: 
        !           882:                 case IDM_E_UNDO:
        !           883:                     break;
        !           884: 
        !           885:                 case IDM_E_CUT:
        !           886: 
        !           887:                     OleDbgOutNoPrefix2("\r\n");
        !           888:                     OLEDBG_BEGIN2("OutlineDoc_CutCommand\r\n")
        !           889:                         
        !           890:                     OutlineDoc_CutCommand(lpOutlineDoc);
        !           891:                 
        !           892:                     OLEDBG_END2
        !           893:                         
        !           894: #if defined( USE_FRAMETOOLS )
        !           895:                     OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !           896: #endif                      
        !           897:                     break;
        !           898: 
        !           899:                 case IDM_E_COPY:
        !           900: 
        !           901:                     OleDbgOutNoPrefix2("\r\n");
        !           902:                     OLEDBG_BEGIN2("OutlineDoc_CopyCommand\r\n")
        !           903:                         
        !           904:                     OutlineDoc_CopyCommand(lpOutlineDoc);
        !           905:                 
        !           906:                     OLEDBG_END2
        !           907:                         
        !           908: #if defined( USE_FRAMETOOLS )
        !           909:                     OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !           910: #endif                      
        !           911:                     break;
        !           912: 
        !           913:                 case IDM_E_PASTE:
        !           914: 
        !           915:                     OleDbgOutNoPrefix2("\r\n");
        !           916:                     OLEDBG_BEGIN2("OutlineDoc_PasteCommand\r\n")
        !           917:                         
        !           918:                     OutlineDoc_PasteCommand(lpOutlineDoc);
        !           919:                 
        !           920:                     OLEDBG_END2
        !           921:                         
        !           922: #if defined( USE_FRAMETOOLS )
        !           923:                     OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !           924: #endif                      
        !           925:                     break;
        !           926: 
        !           927: #if defined( OLE_VERSION )
        !           928:                 case IDM_E_PASTESPECIAL:
        !           929: 
        !           930:                     OleDbgOutNoPrefix2("\r\n");
        !           931:                     OLEDBG_BEGIN2("OleDoc_PasteSpecialCommand\r\n")
        !           932:                         
        !           933:                     OleDoc_PasteSpecialCommand((LPOLEDOC)lpOutlineDoc);
        !           934:                 
        !           935:                     OLEDBG_END2
        !           936:                         
        !           937: #if defined( USE_FRAMETOOLS )
        !           938:                     OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !           939: #endif                      
        !           940:                     break;
        !           941:                 
        !           942: #endif  // OLE_VERSION
        !           943: 
        !           944:                 case IDM_E_CLEAR:
        !           945: 
        !           946:                     OleDbgOutNoPrefix2("\r\n");
        !           947:                     OLEDBG_BEGIN2("OutlineDoc_ClearCommand\r\n")
        !           948:                         
        !           949:                     OutlineDoc_ClearCommand(lpOutlineDoc);
        !           950:                 
        !           951:                     OLEDBG_END2
        !           952:                         
        !           953: #if defined( USE_FRAMETOOLS )
        !           954:                     OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !           955: #endif                      
        !           956:                     break;
        !           957: 
        !           958:                                case IDM_L_ADDLINE:
        !           959: 
        !           960:                     OleDbgOutNoPrefix2("\r\n");
        !           961:                     OLEDBG_BEGIN2("OutlineDoc_AddTextLineCommand\r\n")
        !           962:                         
        !           963:                     OutlineDoc_AddTextLineCommand(lpOutlineDoc);
        !           964: 
        !           965:                     OLEDBG_END2
        !           966:                         
        !           967: #if defined( USE_FRAMETOOLS )
        !           968:                     OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !           969:                     SetFocus(LineList_GetWindow(lpLL));
        !           970: #endif                      
        !           971:                     break;
        !           972: 
        !           973:                 case IDM_L_EDITLINE:
        !           974: 
        !           975:                     OleDbgOutNoPrefix2("\r\n");
        !           976:                     OLEDBG_BEGIN2("OutlineDoc_EditLineCommand\r\n")
        !           977:                         
        !           978:                     OutlineDoc_EditLineCommand(lpOutlineDoc);
        !           979:                 
        !           980:                     OLEDBG_END2
        !           981:                     SetFocus(LineList_GetWindow(lpLL));                
        !           982:                     break;
        !           983: 
        !           984:                 case IDM_L_INDENTLINE:
        !           985: 
        !           986:                     OleDbgOutNoPrefix2("\r\n");
        !           987:                     OLEDBG_BEGIN2("OutlineDoc_IndentCommand\r\n")
        !           988:                         
        !           989:                     OutlineDoc_IndentCommand(lpOutlineDoc);
        !           990:                 
        !           991:                     OLEDBG_END2
        !           992:                     break;
        !           993: 
        !           994:                 case IDM_L_UNINDENTLINE:
        !           995: 
        !           996:                     OleDbgOutNoPrefix2("\r\n");
        !           997:                     OLEDBG_BEGIN2("OutlineDoc_UnindentCommand\r\n")
        !           998:                         
        !           999:                     OutlineDoc_UnindentCommand(lpOutlineDoc);
        !          1000:                 
        !          1001:                     OLEDBG_END2
        !          1002:                     break;
        !          1003:                                
        !          1004:                                case IDM_L_SETLINEHEIGHT:
        !          1005:                                        
        !          1006:                     OleDbgOutNoPrefix2("\r\n");
        !          1007:                     OLEDBG_BEGIN2("OutlineDoc_SetLineHeight\r\n")
        !          1008:                         
        !          1009:                     OutlineDoc_SetLineHeightCommand(lpOutlineDoc);
        !          1010:                 
        !          1011:                     OLEDBG_END2
        !          1012:                     break;
        !          1013: 
        !          1014:                 case IDM_E_SELECTALL:
        !          1015: 
        !          1016:                     OleDbgOutNoPrefix2("\r\n");
        !          1017:                     OLEDBG_BEGIN2("OutlineDoc_SelectAllCommand\r\n")
        !          1018:                         
        !          1019:                     OutlineDoc_SelectAllCommand(lpOutlineDoc);
        !          1020:                 
        !          1021:                     OLEDBG_END2
        !          1022:                     break;
        !          1023: 
        !          1024: #if defined( OLE_CNTR )
        !          1025:                                
        !          1026:                 case IDM_E_INSERTOBJECT:
        !          1027: 
        !          1028:                     OleDbgOutNoPrefix2("\r\n");
        !          1029:                     OLEDBG_BEGIN2("ContainerDoc_InsertOleObjectCommand\r\n")
        !          1030:                         
        !          1031:                     ContainerDoc_InsertOleObjectCommand((LPCONTAINERDOC)lpOutlineDoc);
        !          1032:                 
        !          1033:                     OLEDBG_END2
        !          1034:                         
        !          1035: #if defined( USE_FRAMETOOLS )
        !          1036:                     OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !          1037: #endif                      
        !          1038:                     break;
        !          1039: 
        !          1040:                 case IDM_E_EDITLINKS:
        !          1041: 
        !          1042:                     OleDbgOutNoPrefix2("\r\n");
        !          1043:                     OLEDBG_BEGIN2("ContainerDoc_EditLinksCommand\r\n")
        !          1044:                         
        !          1045:                     ContainerDoc_EditLinksCommand((LPCONTAINERDOC)lpOutlineDoc);
        !          1046:                 
        !          1047:                     OLEDBG_END2
        !          1048:                     break;
        !          1049: 
        !          1050:                 case IDM_E_CONVERTVERB:
        !          1051: 
        !          1052:                     OleDbgOutNoPrefix2("\r\n");
        !          1053:                     OLEDBG_BEGIN2("ContainerDoc_ConvertCommand\r\n")
        !          1054:                         
        !          1055:                     ContainerDoc_ConvertCommand(
        !          1056:                                                        (LPCONTAINERDOC)lpOutlineDoc,
        !          1057:                                                        FALSE           // fMustActivate
        !          1058:                                        );
        !          1059:                 
        !          1060:                     OLEDBG_END2
        !          1061:                     break;
        !          1062: 
        !          1063: 
        !          1064:                 case IDM_E_PASTELINK:
        !          1065: 
        !          1066:                     OleDbgOutNoPrefix2("\r\n");
        !          1067:                     OLEDBG_BEGIN2("ContainerDoc_PasteLinkCommand\r\n")
        !          1068:                         
        !          1069:                     ContainerDoc_PasteLinkCommand((LPCONTAINERDOC)lpOutlineDoc);
        !          1070:                 
        !          1071:                     OLEDBG_END2
        !          1072:                         
        !          1073: #if defined( USE_FRAMETOOLS )
        !          1074:                     OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !          1075: #endif                      
        !          1076:                     break;
        !          1077:                 
        !          1078: #endif  // OLE_CNTR
        !          1079: 
        !          1080:                 case IDM_N_DEFINENAME:
        !          1081: 
        !          1082:                     OleDbgOutNoPrefix2("\r\n");
        !          1083:                     OLEDBG_BEGIN2("OutlineDoc_DefineNameCommand\r\n")
        !          1084:                         
        !          1085:                     OutlineDoc_DefineNameCommand(lpOutlineDoc);
        !          1086:                 
        !          1087:                     OLEDBG_END2
        !          1088:                     break;
        !          1089: 
        !          1090:                 case IDM_N_GOTONAME:
        !          1091: 
        !          1092:                     OleDbgOutNoPrefix2("\r\n");
        !          1093:                     OLEDBG_BEGIN2("OutlineDoc_GotoNameCommand\r\n")
        !          1094:                         
        !          1095:                     OutlineDoc_GotoNameCommand(lpOutlineDoc);
        !          1096:                 
        !          1097:                     OLEDBG_END2
        !          1098:                     break;
        !          1099: 
        !          1100: #if defined( USE_FRAMETOOLS )
        !          1101:                 case IDM_O_BB_TOP:
        !          1102:                     FrameTools_BB_SetState(
        !          1103:                                                        lpOutlineDoc->m_lpFrameTools, BARSTATE_TOP);
        !          1104:                     OutlineDoc_AddFrameLevelTools(lpOutlineDoc);
        !          1105:                     break;
        !          1106: 
        !          1107:                 case IDM_O_BB_BOTTOM:
        !          1108:                     FrameTools_BB_SetState(
        !          1109:                                                        lpOutlineDoc->m_lpFrameTools, BARSTATE_BOTTOM);
        !          1110:                     OutlineDoc_AddFrameLevelTools(lpOutlineDoc);
        !          1111:                     break;
        !          1112: 
        !          1113:                 case IDM_O_BB_POPUP:
        !          1114:                     FrameTools_BB_SetState(
        !          1115:                                                        lpOutlineDoc->m_lpFrameTools, BARSTATE_POPUP);
        !          1116:                     OutlineDoc_AddFrameLevelTools(lpOutlineDoc);
        !          1117:                     break;
        !          1118: 
        !          1119:                 case IDM_O_BB_HIDE:
        !          1120:                     FrameTools_BB_SetState(
        !          1121:                                                        lpOutlineDoc->m_lpFrameTools, BARSTATE_HIDE);
        !          1122:                     OutlineDoc_AddFrameLevelTools(lpOutlineDoc);
        !          1123:                     break;
        !          1124:                     
        !          1125:                 case IDM_O_FB_TOP:
        !          1126:                     FrameTools_FB_SetState(
        !          1127:                                                        lpOutlineDoc->m_lpFrameTools, BARSTATE_TOP);
        !          1128:                     OutlineDoc_AddFrameLevelTools(lpOutlineDoc);
        !          1129:                     break;
        !          1130: 
        !          1131:                 case IDM_O_FB_BOTTOM:
        !          1132:                     FrameTools_FB_SetState(
        !          1133:                                                        lpOutlineDoc->m_lpFrameTools, BARSTATE_BOTTOM);
        !          1134:                     OutlineDoc_AddFrameLevelTools(lpOutlineDoc);
        !          1135:                     break;
        !          1136: 
        !          1137:                 case IDM_O_FB_POPUP:
        !          1138:                     FrameTools_FB_SetState(
        !          1139:                                                        lpOutlineDoc->m_lpFrameTools, BARSTATE_POPUP);
        !          1140:                     OutlineDoc_AddFrameLevelTools(lpOutlineDoc);
        !          1141:                     break;
        !          1142:                     
        !          1143:                 case IDM_FB_EDIT:
        !          1144:                     
        !          1145:                     switch (wNotifyCode) {
        !          1146:                         case EN_SETFOCUS:
        !          1147:                             OutlineDoc_SetFormulaBarEditFocus(
        !          1148:                                     lpOutlineDoc, TRUE);
        !          1149:                             OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !          1150:                             break;
        !          1151:                             
        !          1152:                         case EN_KILLFOCUS:
        !          1153:                             OutlineDoc_SetFormulaBarEditFocus(
        !          1154:                                     lpOutlineDoc, FALSE);
        !          1155:                             OutlineDoc_UpdateFrameToolButtons(lpOutlineDoc);
        !          1156:                             break;
        !          1157:                     }
        !          1158:                     break;
        !          1159:                     
        !          1160:                 case IDM_FB_CANCEL:
        !          1161:                     SetFocus(hWnd);
        !          1162:                     break;
        !          1163:                 
        !          1164:                     
        !          1165:                 case IDM_F2:
        !          1166:                     SendMessage(hWnd, WM_COMMAND, (WPARAM)IDM_FB_EDIT,
        !          1167:                             MAKELONG(0, EN_SETFOCUS));
        !          1168:                     break;
        !          1169: #endif  // USE_FRAMETOOLS
        !          1170: 
        !          1171: 
        !          1172: #if defined( USE_HEADING )
        !          1173:                 case IDC_BUTTON:
        !          1174:                     if (wNotifyCode == BN_CLICKED) {
        !          1175:                         SendMessage(hWnd, WM_COMMAND, IDM_E_SELECTALL, 0L);
        !          1176:                         SetFocus(hWnd);
        !          1177:                     }
        !          1178:                     break;
        !          1179: 
        !          1180:                 case IDM_O_HEAD_SHOW: 
        !          1181:                                        OutlineDoc_ShowHeading(lpOutlineDoc, TRUE);
        !          1182:                     break;
        !          1183:                     
        !          1184:                 case IDM_O_HEAD_HIDE:
        !          1185:                                        OutlineDoc_ShowHeading(lpOutlineDoc, FALSE);
        !          1186:                     break;
        !          1187: #endif  // USE_HEADING
        !          1188: 
        !          1189: 
        !          1190: #if defined( OLE_CNTR )
        !          1191:                                case IDM_O_SHOWOBJECT:
        !          1192:                                {
        !          1193:                                        LPCONTAINERDOC lpContainerDoc = 
        !          1194:                                                                (LPCONTAINERDOC)lpOutlineDoc;
        !          1195:                     BOOL               fShowObject;
        !          1196:                                        
        !          1197:                                        fShowObject = !ContainerDoc_GetShowObjectFlag(
        !          1198:                                                        lpContainerDoc);
        !          1199:                                        ContainerDoc_SetShowObjectFlag(
        !          1200:                             lpContainerDoc, fShowObject);
        !          1201:                                        LineList_ForceRedraw(lpLL, TRUE);
        !          1202:                                        
        !          1203:                                        break;
        !          1204:                                }
        !          1205: #endif  // OLE_CNTR
        !          1206: 
        !          1207: #if !defined( OLE_CNTR )
        !          1208:                 // Container does not allow zoom factors > 100%
        !          1209:                                case IDM_V_ZOOM_400:
        !          1210:                                case IDM_V_ZOOM_300:
        !          1211:                                case IDM_V_ZOOM_200:
        !          1212: #endif         // !OLE_CNTR
        !          1213: 
        !          1214:                                case IDM_V_ZOOM_100:
        !          1215:                                case IDM_V_ZOOM_75:
        !          1216:                                case IDM_V_ZOOM_50:
        !          1217:                                case IDM_V_ZOOM_25:
        !          1218:                     OutlineDoc_SetCurrentZoomCommand(lpOutlineDoc, wID);
        !          1219:                     break;
        !          1220:                                
        !          1221:                                case IDM_V_SETMARGIN_0:
        !          1222:                                case IDM_V_SETMARGIN_1:
        !          1223:                                case IDM_V_SETMARGIN_2:
        !          1224:                                case IDM_V_SETMARGIN_3:
        !          1225:                                case IDM_V_SETMARGIN_4:
        !          1226:                     OutlineDoc_SetCurrentMarginCommand(lpOutlineDoc, wID);
        !          1227:                                        break;
        !          1228:                                
        !          1229:                                case IDM_V_ADDTOP_1:
        !          1230:                                case IDM_V_ADDTOP_2:
        !          1231:                                case IDM_V_ADDTOP_3:
        !          1232:                                case IDM_V_ADDTOP_4:
        !          1233:                                {
        !          1234:                     UINT nHeightInHimetric;
        !          1235:                                        
        !          1236:                                        switch (wID) {
        !          1237:                                                case IDM_V_ADDTOP_1:
        !          1238:                                                        nHeightInHimetric = 1000;
        !          1239:                                                        break;
        !          1240:                                                        
        !          1241:                                                case IDM_V_ADDTOP_2:
        !          1242:                                                        nHeightInHimetric = 2000;
        !          1243:                                                        break;
        !          1244:                                                        
        !          1245:                                                case IDM_V_ADDTOP_3:
        !          1246:                                                        nHeightInHimetric = 3000;
        !          1247:                                                        break;
        !          1248:                                                        
        !          1249:                                                case IDM_V_ADDTOP_4:
        !          1250:                                                        nHeightInHimetric = 4000;
        !          1251:                                                        break;
        !          1252:                                        }
        !          1253:                                        
        !          1254:                                        OutlineDoc_AddTopLineCommand(
        !          1255:                             lpOutlineDoc, nHeightInHimetric);
        !          1256:                                        break;
        !          1257:                                }
        !          1258: 
        !          1259:                                
        !          1260:                 case IDM_H_ABOUT:
        !          1261:                     OutlineApp_AboutCommand(lpOutlineApp);
        !          1262:                     break;
        !          1263: 
        !          1264:                 case IDM_D_DEBUGLEVEL:
        !          1265:                     SetDebugLevelCommand();
        !          1266:                     break;
        !          1267: 
        !          1268: #if defined( OLE_VERSION )
        !          1269:                 case IDM_D_INSTALLMSGFILTER:
        !          1270:                     InstallMessageFilterCommand();
        !          1271:                     break;
        !          1272:                     
        !          1273:                 case IDM_D_REJECTINCOMING:
        !          1274:                     RejectIncomingCommand();
        !          1275:                     break;
        !          1276: #endif // OLE_VERSION
        !          1277: 
        !          1278: #if defined( INPLACE_CNTR )
        !          1279:                 case IDM_D_INSIDEOUT:
        !          1280:                     g_fInsideOutContainer = !g_fInsideOutContainer;
        !          1281:                     
        !          1282:                     // force all object to unload so they can start new 
        !          1283:                     // activation behavior.
        !          1284:                     ContainerDoc_UnloadAllOleObjectsOfClass(
        !          1285:                             (LPCONTAINERDOC)lpOutlineDoc, &CLSID_NULL);
        !          1286:                     OutlineDoc_ForceRedraw(lpOutlineDoc, TRUE);
        !          1287:                     break;
        !          1288: #endif  // INPLACE_CNTR
        !          1289: 
        !          1290: 
        !          1291:                 case IDC_LINELIST: {
        !          1292: 
        !          1293:                     if (wNotifyCode == LBN_DBLCLK) {
        !          1294:                         int nIndex = LineList_GetFocusLineIndex(lpLL);
        !          1295:                         LPLINE lpLine = LineList_GetLine(lpLL, nIndex);
        !          1296:                         
        !          1297:                         if (Line_GetLineType(lpLine) == CONTAINERLINETYPE) {
        !          1298:                             OutlineDoc_EditLineCommand( lpOutlineDoc );
        !          1299:                         }
        !          1300: 
        !          1301: #if defined( INPLACE_CNTR )
        !          1302:                         { // BEGIN BLOCK
        !          1303:                             LPCONTAINERDOC lpContainerDoc = 
        !          1304:                                     (LPCONTAINERDOC) lpOutlineDoc;
        !          1305:                             if (lpContainerDoc->m_fAddMyUI) {
        !          1306:                                 /* OLE2NOTE: fAddMyUI is TRUE when
        !          1307:                                 **    there was previously an in-place
        !          1308:                                 **    active object which got
        !          1309:                                 **    UIDeactivated as a result of this
        !          1310:                                 **    DBLCLK AND the DBLCLK did NOT
        !          1311:                                 **    result in in-place activating
        !          1312:                                 **    another object. 
        !          1313:                                 **    (see IOleInPlaceSite::OnUIActivate and
        !          1314:                                 **    IOleInPlaceSite::OnUIDeactivate
        !          1315:                                 **    methods).
        !          1316:                                 */
        !          1317: #if defined( USE_DOCTOOLS )
        !          1318:                                 ContainerDoc_AddDocLevelTools(lpContainerDoc);
        !          1319: #endif
        !          1320: 
        !          1321: #if defined( USE_FRAMETOOLS )
        !          1322:                                 ContainerDoc_AddFrameLevelUI(lpContainerDoc);
        !          1323: #endif
        !          1324:                                 lpContainerDoc->m_fAddMyUI = FALSE; 
        !          1325:                             }
        !          1326:                         } // END BLOCK
        !          1327: #endif // INPLACE_CNTR
        !          1328:                     }
        !          1329:                     break;
        !          1330:                 }
        !          1331:                 
        !          1332:                 
        !          1333:                 default:
        !          1334: 
        !          1335: #if defined( OLE_CNTR )
        !          1336:                     if (wID >= IDM_E_OBJECTVERBMIN) {
        !          1337: 
        !          1338:                         OleDbgOutNoPrefix2("\r\n");
        !          1339:                         OLEDBG_BEGIN2("ContainerDoc_ContainerLineDoVerbCommand\r\n")
        !          1340:                         ContainerDoc_ContainerLineDoVerbCommand(
        !          1341:                                 (LPCONTAINERDOC)lpOutlineDoc, 
        !          1342:                                 (LONG)(wID-IDM_E_OBJECTVERBMIN)
        !          1343:                         );
        !          1344: 
        !          1345:                         OLEDBG_END2
        !          1346:                         break;
        !          1347:                     }
        !          1348: #endif // OLE_CNTR
        !          1349:                     return DefWindowProc(hWnd, Message, wParam, lParam);
        !          1350:             }
        !          1351:             
        !          1352:             break;  /* End of WM_COMMAND */
        !          1353:         }
        !          1354:         default:
        !          1355: 
        !          1356:             if (Message == g_uMsgHelp) {
        !          1357:                 /* Handle OLE2UI dialog's help messages. 
        !          1358:                 ** We get the hDlg of the dialog that called us in the wParam
        !          1359:                 ** and the dialog type in the LOWORD of the lParam, 
        !          1360:                 ** so we pass this along to our help function.
        !          1361:                 */
        !          1362:                 OutlineDoc_DialogHelp((HWND)wParam, LOWORD(lParam));
        !          1363:                 break;
        !          1364:             }  
        !          1365: 
        !          1366:             /* For any message for which you don't specifically provide a  */
        !          1367:             /* service routine, you should return the message to Windows   */
        !          1368:             /* for default message processing.                             */
        !          1369:             return DefWindowProc(hWnd, Message, wParam, lParam);
        !          1370:     }
        !          1371:     
        !          1372:     return (LRESULT)0;
        !          1373: 
        !          1374: } /* End of DocWndProc */
        !          1375: 
        !          1376: 
        !          1377: 
        !          1378: //***********************************************************************
        !          1379: //*                                                                      
        !          1380: //* LineListWndProc()  Drag and Drop Listbox Window Proc Sub-Class   
        !          1381: //*                                                                     
        !          1382: //* Sub Class the Ownerdraw list box in order to activate the drag drop.
        !          1383: //***********************************************************************
        !          1384: 
        !          1385: LRESULT FAR PASCAL LineListWndProc(
        !          1386:     HWND   hWnd,
        !          1387:     UINT   Message,
        !          1388:     WPARAM wParam,
        !          1389:     LPARAM lParam
        !          1390: )
        !          1391: {
        !          1392:        HWND         hwndParent = GetParent ( hWnd );
        !          1393:     LPOUTLINEAPP lpOutlineApp = (LPOUTLINEAPP)g_lpApp;
        !          1394:     LPOUTLINEDOC lpOutlineDoc = (LPOUTLINEDOC) GetWindowLong( hwndParent, 0 );
        !          1395:     LPLINELIST   lpLL = OutlineDoc_GetLineList(lpOutlineDoc);
        !          1396: 
        !          1397: #if defined( OLE_VERSION )
        !          1398:     LPOLEAPP     lpOleApp = (LPOLEAPP)lpOutlineApp;
        !          1399:     LPOLEDOC     lpOleDoc = (LPOLEDOC)lpOutlineDoc;
        !          1400: #endif // OLE_VERSION
        !          1401: 
        !          1402: #if defined( INPLACE_SVR )
        !          1403:     LPSERVERDOC  lpServerDoc = (LPSERVERDOC)lpOutlineDoc;
        !          1404:     static BOOL  fUIActivateClick = FALSE;
        !          1405:     static BOOL  fInWinPosChged = FALSE; 
        !          1406: #endif  // INPLACE_SVR
        !          1407:  
        !          1408: #if defined( INPLACE_CNTR )
        !          1409:     LPCONTAINERAPP lpContainerApp=(LPCONTAINERAPP)lpOutlineApp;
        !          1410:     LPCONTAINERDOC lpContainerDoc=(LPCONTAINERDOC)lpOutlineDoc;
        !          1411: #endif  // INPLACE_CNTR
        !          1412: 
        !          1413:     switch (Message) {
        !          1414: 
        !          1415:         case WM_KILLFOCUS:
        !          1416:             /* OLE2NOTE: when our window looses focus we 
        !          1417:             **    should not display any active selection
        !          1418:             */
        !          1419: #if defined( INPLACE_CNTR )
        !          1420:             if (! lpContainerApp->m_fPendingUIDeactivate) 
        !          1421: #endif  // INPLACE_CNTR
        !          1422:                 LineList_RemoveSel(lpLL);
        !          1423:             break;
        !          1424: 
        !          1425:         case WM_SETFOCUS:
        !          1426: 
        !          1427: #if defined( INPLACE_CNTR )
        !          1428:             {
        !          1429:                 HWND hWndObj=ContainerDoc_GetUIActiveWindow(lpContainerDoc);
        !          1430:             
        !          1431:                 /* OLE2NOTE: if there is a UIActive in-place object, we must
        !          1432:                 **    forward focus to its window as long as there is
        !          1433:                 **    not a pending UIDeactivate. if the mouse is
        !          1434:                 **    clicked outside of the object and the object is
        !          1435:                 **    about to be deactivated then we do NOT want to
        !          1436:                 **    forward focus to the object. we do NOT want it to
        !          1437:                 **    restore its selection feedback.
        !          1438:                 */
        !          1439:                 if (lpContainerApp->m_fPendingUIDeactivate) 
        !          1440:                     break;  
        !          1441:                 else if (hWndObj) {
        !          1442:                     SetFocus(hWndObj);
        !          1443:                     break;      // do not restore containers selection state
        !          1444:                 }
        !          1445:             }
        !          1446: #endif  // INPLACE_CNTR
        !          1447: 
        !          1448:             /* OLE2NOTE: when our window gains focus we 
        !          1449:             **    should restore the previous selection
        !          1450:             */
        !          1451:             LineList_RestoreSel(lpLL);
        !          1452: 
        !          1453:             break;
        !          1454: 
        !          1455: #if defined( INPLACE_SVR )
        !          1456:                case WM_MOUSEACTIVATE: 
        !          1457:         {
        !          1458:             if (lpServerDoc->m_fInPlaceActive && !lpServerDoc->m_fUIActive) {
        !          1459:                 fUIActivateClick = TRUE;
        !          1460:             };
        !          1461:                        break;
        !          1462:         }
        !          1463: 
        !          1464: #endif  // INPLACE_SVR
        !          1465: 
        !          1466: 
        !          1467: #if defined( USE_FRAMETOOLS )
        !          1468:         case WM_CHAR: 
        !          1469:         {
        !          1470:             OutlineDoc_SetFormulaBarEditFocus(lpOutlineDoc, TRUE);
        !          1471:             FrameTools_FB_SetEditText(lpOutlineDoc->m_lpFrameTools, NULL);
        !          1472:             FrameTools_FB_SendMessage(
        !          1473:                     lpOutlineDoc->m_lpFrameTools,
        !          1474:                     IDM_FB_EDIT,
        !          1475:                     Message,
        !          1476:                     wParam,
        !          1477:                     lParam
        !          1478:             );
        !          1479:             
        !          1480:             return (LRESULT)0;   // don't do default listbox processing
        !          1481:         }
        !          1482: #endif // USE_FRAMETOOLS
        !          1483: 
        !          1484: #if defined( USE_HEADING )
        !          1485:         case WM_HSCROLL:
        !          1486:         {
        !          1487:             LPHEADING lphead = OutlineDoc_GetHeading(lpOutlineDoc);
        !          1488:             
        !          1489:             Heading_CH_SendMessage(lphead, Message, wParam, lParam);
        !          1490:                 
        !          1491:             break;
        !          1492:         }
        !          1493:         
        !          1494:         // NOTE: WM_PAINT trapped for vertical scroll only. Should have 
        !          1495:         //       WM_VSCROLL instead but it is not generated from scrolling
        !          1496:         //       without using scroll bar (e.g. use keyboard). 
        !          1497:         case WM_PAINT:
        !          1498:         {
        !          1499:             Heading_RH_Scroll(OutlineDoc_GetHeading(lpOutlineDoc), hWnd);
        !          1500:             break;
        !          1501:         }
        !          1502:         
        !          1503: #endif // USE_HEADING
        !          1504: 
        !          1505:         case WM_LBUTTONUP: 
        !          1506:         {   
        !          1507:             
        !          1508: #if defined( USE_DRAGDROP )
        !          1509:             if (lpOleDoc->m_fPendingDrag) {
        !          1510:                 /* ButtonUP came BEFORE mouse moved beyond threshhold
        !          1511:                 **    to start drag. clear fPendingDrag state.
        !          1512:                 */
        !          1513:                 ReleaseCapture();
        !          1514:                 lpOleDoc->m_fPendingDrag = FALSE;
        !          1515:             }
        !          1516: #endif  // USE_DRAGDROP
        !          1517: 
        !          1518: #if defined( INPLACE_SVR )
        !          1519:             if (fUIActivateClick) {
        !          1520:                 fUIActivateClick = FALSE;
        !          1521:                 ServerDoc_UIActivate((LPSERVERDOC) lpOleDoc);
        !          1522:             }
        !          1523: #endif  // INPLACE_SVR
        !          1524: 
        !          1525: #if defined( INPLACE_CNTR )
        !          1526:             {
        !          1527:                 /* check if a UIDeactivate is pending.   
        !          1528:                 **      (see comment in WM_LBUTTONDOWN)
        !          1529:                 */
        !          1530:                 if ( lpContainerApp->m_fPendingUIDeactivate ) {
        !          1531:                     ContainerLine_UIDeactivate(
        !          1532:                             lpContainerDoc->m_lpLastUIActiveLine);
        !          1533: 
        !          1534:                     lpContainerApp->m_fPendingUIDeactivate = FALSE;
        !          1535:                 }
        !          1536:             }
        !          1537: #endif  // INPLACE_CNTR
        !          1538: 
        !          1539:             break;
        !          1540:         }
        !          1541: 
        !          1542:         case WM_LBUTTONDOWN: 
        !          1543:         {
        !          1544:             POINT pt;
        !          1545: 
        !          1546:             pt.x = (int)(short)LOWORD (lParam );
        !          1547:             pt.y = (int)(short)HIWORD (lParam );
        !          1548: 
        !          1549: #if defined( INPLACE_CNTR )
        !          1550:             {
        !          1551:                 /* OLE2NOTE: both inside-out and outside-in style
        !          1552:                 **    containers must check if the mouse click is
        !          1553:                 **    outside of the current UIActive object (if
        !          1554:                 **    any). If so, then set the flag indicating that
        !          1555:                 **    there is a pending UIDeactivate needed. We do NOT
        !          1556:                 **    want to do it now, 
        !          1557:                 **    because that would result in un-wanted movement of
        !          1558:                 **    the data on the screen as frame adornments (eg.
        !          1559:                 **    toolbar) and/or object adornments (eg. ruler) would
        !          1560:                 **    be removed from the screen. we want to defer the
        !          1561:                 **    UIDeactivate till the mouse up event. The listbox's
        !          1562:                 **    default processing captures the mouse on button down
        !          1563:                 **    so that it is sure to get the button up message.
        !          1564:                 **    
        !          1565:                 **    SPECIAL NOTE: there is potential interaction here
        !          1566:                 **    with Drag/Drop. if this button down event actually
        !          1567:                 **    starts a Drag/Drop operation, then OLE does the mouse
        !          1568:                 **    capture. in this situation we will NOT get our button
        !          1569:                 **    up event. we must instead perform the UIDeactivate
        !          1570:                 **    when the drop operation finishes
        !          1571:                 */
        !          1572:                 lpContainerApp->m_fPendingUIDeactivate =
        !          1573:                         ContainerDoc_IsUIDeactivateNeeded(lpContainerDoc, pt);
        !          1574:             }
        !          1575: #endif  // INPLACE_CNTR
        !          1576: 
        !          1577: #if defined( USE_DRAGDROP )         
        !          1578: 
        !          1579:             /* OLE2NOTE: check if this is a button down on the region
        !          1580:             **    that is a handle to start a drag operation. for us,
        !          1581:             **    this this the top/bottom border of the selection.
        !          1582:             **    do NOT want to start a drag immediately; we want to
        !          1583:             **    wait until the mouse moves a certain threshold. if
        !          1584:             **    LButtonUp comes before mouse move to start drag, then
        !          1585:             **    the fPendingDrag state is cleared. we must capture
        !          1586:             **    the mouse to ensure the modal state is handled
        !          1587:             **    properly. 
        !          1588:             */
        !          1589:             if ( OleDoc_QueryDrag(lpOleDoc, pt.y) ) {
        !          1590:                 lpOleDoc->m_fPendingDrag = TRUE;
        !          1591:                 lpOleDoc->m_ptButDown = pt;
        !          1592:                 SetCursor(lpOleApp->m_hcursorDragMove);
        !          1593:                 SetCapture(hWnd);
        !          1594: 
        !          1595:                 /* We do NOT want to do the listbox's default
        !          1596:                 **    processing which would be to capture the mouse
        !          1597:                 **    and enter a modal multiple selection state until
        !          1598:                 **    a mouse up occurs. we have just finished a modal
        !          1599:                 **    drag/drop operation where OLE has captured the
        !          1600:                 **    mouse. thus by now the mouse up has already occured.
        !          1601:                 */
        !          1602: 
        !          1603:                 return (LRESULT)0;   // don't do default listbox processing
        !          1604:             }
        !          1605: #endif  // USE_DRAGDROP
        !          1606: 
        !          1607:             break;
        !          1608:         }
        !          1609: 
        !          1610: 
        !          1611:         case WM_MOUSEMOVE: {
        !          1612: 
        !          1613: #if defined( USE_DRAGDROP )         
        !          1614: 
        !          1615:             int  x = (int)(short)LOWORD (lParam );
        !          1616:             int  y = (int)(short)HIWORD (lParam );
        !          1617:             POINT pt = lpOleDoc->m_ptButDown;
        !          1618:             
        !          1619:             if (lpOleDoc->m_fPendingDrag) {
        !          1620:                 
        !          1621:                 if (! ( ((pt.x-(DD_SEL_THRESH/2)) <= x)
        !          1622:                         && (x <= (pt.x+(DD_SEL_THRESH/2)))
        !          1623:                         && ((pt.y-(DD_SEL_THRESH/2)) <= y)
        !          1624:                         && (y <= (pt.y+(DD_SEL_THRESH/2))) ) ) {
        !          1625: 
        !          1626:                     DWORD dwEffect;
        !          1627: 
        !          1628:                     // mouse moved beyond threshhold to start drag
        !          1629:                     ReleaseCapture();
        !          1630:                     lpOleDoc->m_fPendingDrag = FALSE;
        !          1631: 
        !          1632:                     // perform the modal drag/drop operation.
        !          1633:                     dwEffect = OleDoc_DoDragDrop( lpOleDoc );
        !          1634:                 
        !          1635: #if defined( INPLACE_CNTR )
        !          1636:                     {
        !          1637:                         /* if necessary UIDeactive the in-place object.
        !          1638:                         **    this applies to outside-in style
        !          1639:                         **    container only. 
        !          1640:                         **    (see comment above)
        !          1641:                         */
        !          1642:                         if (lpContainerApp->m_fPendingUIDeactivate) {
        !          1643:                             lpContainerApp->m_fPendingUIDeactivate = FALSE;
        !          1644: 
        !          1645:                             // do not UIDeactivate if drag/drop was canceled
        !          1646:                             if (dwEffect != DROPEFFECT_NONE) 
        !          1647:                                 ContainerLine_UIDeactivate(
        !          1648:                                         lpContainerDoc->m_lpLastUIActiveLine
        !          1649:                                 );
        !          1650:                         }
        !          1651:                     }
        !          1652: #endif  // INPLACE_CNTR
        !          1653: 
        !          1654:                     return (LRESULT)0; // don't do default listbox process
        !          1655:                 }
        !          1656:                 else {
        !          1657:                     /* cursor did not move from initial mouse down
        !          1658:                     **    (pending drag) point.
        !          1659:                     */
        !          1660:                     SetCursor(lpOleApp->m_hcursorDragMove);
        !          1661:                     return (LRESULT)0; // don't do default listbox process
        !          1662:                 }
        !          1663:             }
        !          1664: 
        !          1665: #endif  // USE_DRAGDROP
        !          1666: 
        !          1667: #if defined( INPLACE_CNTR )
        !          1668:             { // BEGIN BLOCK
        !          1669:                 if (lpContainerDoc->m_fAddMyUI) {
        !          1670:                     /* OLE2NOTE: fAddMyUI is TRUE when
        !          1671:                     **    there was previously an in-place
        !          1672:                     **    active object which got
        !          1673:                     **    UIDeactivated as a result of a
        !          1674:                     **    DBLCLK AND the DBLCLK did NOT
        !          1675:                     **    result in in-place activating
        !          1676:                     **    another object. 
        !          1677:                     **    (see IOleInPlaceSite::OnUIActivate and
        !          1678:                     **    IOleInPlaceSite::OnUIDeactivate
        !          1679:                     **    methods).
        !          1680:                     */
        !          1681: #if defined( USE_DOCTOOLS )
        !          1682:                     ContainerDoc_AddDocLevelTools(lpContainerDoc);
        !          1683: #endif
        !          1684: 
        !          1685: #if defined( USE_FRAMETOOLS )
        !          1686:                     ContainerDoc_AddFrameLevelUI(lpContainerDoc);
        !          1687: #endif
        !          1688:                     lpContainerDoc->m_fAddMyUI = FALSE; 
        !          1689:                 }
        !          1690:             } // END BLOCK
        !          1691: #endif // INPLACE_CNTR
        !          1692:             
        !          1693:             break;
        !          1694:         }
        !          1695: 
        !          1696: 
        !          1697:         case WM_SETCURSOR: 
        !          1698:         {
        !          1699:             RECT rc;
        !          1700:             POINT ptCursor;
        !          1701:                 
        !          1702:             GetCursorPos((POINT FAR*)&ptCursor);
        !          1703:             ScreenToClient(hWnd, (POINT FAR*)&ptCursor);
        !          1704:             GetClientRect(hWnd, (LPRECT)&rc);
        !          1705:                 
        !          1706:             // use arrow cursor if in scroll bar
        !          1707:             if (! PtInRect((LPRECT)&rc, ptCursor) )
        !          1708:                 SetCursor(LoadCursor( NULL, MAKEINTRESOURCE(IDC_ARROW) ) );
        !          1709: 
        !          1710: #if defined( USE_DRAGDROP )         
        !          1711:             // use arrow cursor if on drag handle (top/bottom of selection)
        !          1712:             else if ( OleDoc_QueryDrag ( lpOleDoc, ptCursor.y) )
        !          1713:                 SetCursor(LoadCursor( NULL, MAKEINTRESOURCE(IDC_ARROW) ) );
        !          1714: #endif  // USE_DRAGDROP
        !          1715: 
        !          1716:             else 
        !          1717:                 SetCursor(lpOutlineApp->m_hcursorSelCur);
        !          1718: 
        !          1719:             return (LRESULT)TRUE;
        !          1720:         }
        !          1721: 
        !          1722: #if defined( INPLACE_SVR )
        !          1723: 
        !          1724:         /* The handling of WM_WINDOWPOSCHANGED message is ISVROTL
        !          1725:         **    application specific. The nature of the owner-draw list
        !          1726:         **    box used by the ISVROTL application causes a recursive
        !          1727:         **    call to this message in some situations when in-place
        !          1728:         **    active. in order not to crash this recursive call must be
        !          1729:         **    guarded.
        !          1730:         */
        !          1731:         case WM_WINDOWPOSCHANGED:
        !          1732:         {
        !          1733:             WINDOWPOS FAR* lpWinPos = (WINDOWPOS FAR*) lParam;
        !          1734:             LRESULT lResult;
        !          1735: 
        !          1736:             // guard against recursive call
        !          1737:             if (fInWinPosChged) 
        !          1738:                 return (LRESULT)0;
        !          1739: 
        !          1740:             fInWinPosChged = TRUE;
        !          1741:             lResult = CallWindowProc(
        !          1742:                     (WNDPROC)lpOutlineApp->m_ListBoxWndProc,
        !          1743:                     hWnd,
        !          1744:                     Message,
        !          1745:                     wParam,
        !          1746:                     lParam
        !          1747:             );
        !          1748:             fInWinPosChged = FALSE;
        !          1749: 
        !          1750:             return lResult;
        !          1751:         }    
        !          1752: #endif  // INPLACE_SVR
        !          1753: 
        !          1754:     }       
        !          1755: 
        !          1756:     return CallWindowProc(
        !          1757:             (WNDPROC)lpOutlineApp->m_ListBoxWndProc,
        !          1758:             hWnd,
        !          1759:             Message,
        !          1760:             wParam,
        !          1761:             lParam
        !          1762:     );
        !          1763: 
        !          1764: }

unix.superglobalmegacorp.com

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