⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 patron.cpp

📁 英文版的 想要的话可以下载了 为大家服务
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        , NULL, NULL, 0, uState);

    //Add New Page, and Delete Page
    m_pTB->Add(utCmd, iLast++, IDM_PAGENEWPAGE, m_dxB, m_dyB
        , NULL, m_hBmp, 2, uState);
    m_pTB->Add(utCmd, iLast++, IDM_PAGEDELETEPAGE, m_dxB, m_dyB
        , NULL, m_hBmp, 3, uState);

    m_pTB->Add(GIZMOTYPE_SEPARATOR, iLast++, 0, 6, m_dyB
        , NULL, NULL, 0, uState);

    //First, Prev, Next, Last pages.
    m_pTB->Add(utCmd, iLast++, IDM_PAGEFIRSTPAGE, m_dxB, m_dyB
        , NULL, m_hBmp, 4, uState);
    m_pTB->Add(utCmd, iLast++, IDM_PAGEPREVIOUSPAGE, m_dxB, m_dyB
        , NULL, m_hBmp, 5, uState);
    m_pTB->Add(utCmd, iLast++, IDM_PAGENEXTPAGE, m_dxB, m_dyB
        , NULL, m_hBmp, 6, uState);
    m_pTB->Add(utCmd, iLast++, IDM_PAGELASTPAGE, m_dxB, m_dyB
        , NULL, m_hBmp, 7, uState);

    return iLast;
    }







/*
 * CPatronFrame::UpdateMenus
 *
 * Purpose:
 *  Handles the WM_INITMENU message for the frame window.  Depending
 *  on the existence of an active window, menu items are selectively
 *  enabled and disabled.
 *
 * Parameters:
 *  hMenu           HMENU of the menu to intialize
 *  iMenu           UINT position of the menu.
 *
 * Return Value:
 *  None
 */

void CPatronFrame::UpdateMenus(HMENU hMenu, UINT iMenu)
    {
    PCPatronDoc     pDoc;
    BOOL            fOK=FALSE;
    BOOL            fCallDefault=TRUE;
    UINT            uTemp;
    UINT            uTempE;
    UINT            uTempD;

    pDoc=(PCPatronDoc)m_pCL->ActiveDocument();

    uTempE=MF_ENABLED | MF_BYCOMMAND;
    uTempD=MF_DISABLED | MF_GRAYED | MF_BYCOMMAND;
    uTemp=((NULL!=pDoc) ? uTempE : uTempD);

    if (m_phMenu[0]==hMenu)
        {
        EnableMenuItem(hMenu, IDM_FILEPRINT, uTemp);

        if (NULL!=pDoc)
            fOK=pDoc->FQueryPrinterSetup();

        EnableMenuItem(hMenu, IDM_FILEPRINTERSETUP
            , (fOK) ? uTempE : uTempD);
        }

    if (m_phMenu[1]==hMenu)
        {
        if (NULL!=pDoc)
            fOK=pDoc->FQueryPaste();

        EnableMenuItem(hMenu, IDM_EDITPASTE
            , (fOK) ? uTempE : uTempD);
        EnableMenuItem(hMenu, IDM_EDITPASTESPECIAL
            , (fOK) ? uTempE : uTempD);

        //Cut, Copy, Delete depends on there being a selection.
        if (NULL!=pDoc)
            fOK=pDoc->FQueryObjectSelected(hMenu);
        else
            fOK=FALSE;

        EnableMenuItem(hMenu, IDM_EDITCUT, (fOK) ? uTempE : uTempD);
        EnableMenuItem(hMenu, IDM_EDITCOPY
            , (fOK) ? uTempE : uTempD);
        EnableMenuItem(hMenu, IDM_EDITDELETEOBJECT
            , (fOK) ? uTempE : uTempD);

        EnableMenuItem(hMenu, IDM_EDITINSERTOBJECT, uTemp);

        if (NULL!=pDoc)
            fOK=pDoc->FQueryEnableEditLinks();
        else
            fOK=FALSE;

        EnableMenuItem(hMenu, IDM_EDITLINKS
            , (fOK) ? uTempE : uTempD);

        //CHAPTER24MOD
        //Enable Events... if we have a control
        fOK=FALSE;

        if (NULL!=pDoc)
            fOK=pDoc->FQueryEnableEvents();

        EnableMenuItem(hMenu, IDM_EDITOBJECTEVENTS
            , (fOK) ? uTempE : uTempD);
        //End CHAPTER24MOD

        //We did the whole menu...
        fCallDefault=FALSE;
        }

    //Page menu
    if (m_phMenu[2]==hMenu)
        {
        EnableMenuItem(hMenu, IDM_PAGENEWPAGE,      uTemp);
        EnableMenuItem(hMenu, IDM_PAGEDELETEPAGE,   uTemp);
        EnableMenuItem(hMenu, IDM_PAGENEXTPAGE,     uTemp);
        EnableMenuItem(hMenu, IDM_PAGEPREVIOUSPAGE, uTemp);
        EnableMenuItem(hMenu, IDM_PAGEFIRSTPAGE,    uTemp);
        EnableMenuItem(hMenu, IDM_PAGELASTPAGE,     uTemp);

        //Check the Show Objects command or not.
        if (NULL!=pDoc)
            fOK=pDoc->ShowOrQueryObjectTypes(TRUE, FALSE);
        else
            fOK=FALSE;

        CheckMenuItem(hMenu, IDM_PAGESHOWOBJECTS, MF_BYCOMMAND
            | ((fOK) ? MF_CHECKED : MF_UNCHECKED));
        EnableMenuItem(hMenu, IDM_PAGESHOWOBJECTS, uTemp);

        //CHAPTER24MOD
        //Check the Design Mode command or not.
        if (NULL!=pDoc)
            fOK=pDoc->FToggleOrQueryDesignMode(TRUE, FALSE);
        else
            fOK=FALSE;

        CheckMenuItem(hMenu, IDM_PAGEDESIGNMODE, MF_BYCOMMAND
            | ((fOK) ? MF_CHECKED : MF_UNCHECKED));
        EnableMenuItem(hMenu, IDM_PAGEDESIGNMODE, uTemp);

        //Check the UI Disabled command or not.
        if (NULL!=pDoc)
            fOK=pDoc->FToggleOrQueryUIDead(TRUE, FALSE);
        else
            fOK=FALSE;

        CheckMenuItem(hMenu, IDM_PAGEUIDISABLED, MF_BYCOMMAND
            | ((fOK) ? MF_CHECKED : MF_UNCHECKED));
        EnableMenuItem(hMenu, IDM_PAGEUIDISABLED, uTemp);

        //Check the Show Hatch and Handles command or not.
        if (NULL!=pDoc)
            fOK=pDoc->FToggleOrQueryHatchHandles(TRUE, FALSE);
        else
            fOK=FALSE;

        CheckMenuItem(hMenu, IDM_PAGESHOWHATCHHANDLES, MF_BYCOMMAND
            | ((fOK) ? MF_CHECKED : MF_UNCHECKED));
        EnableMenuItem(hMenu, IDM_PAGESHOWHATCHHANDLES, uTemp);
        //End CHAPTER24MOD
        }

    if (fCallDefault)
        CFrame::UpdateMenus(hMenu, iMenu);

    return;
    }






/*
 * CPatronFrame::UpdateToolbar
 *
 * Purpose:
 *  Enables and disables tools depending on whether we have
 *  a document or not.
 *
 * Parameters:
 *  None
 *
 * Return Value:
 *  None
 */

void CPatronFrame::UpdateToolbar(void)
    {
    PCDocument  pDoc;
    BOOL        fEnable;

    //Let the default hack on its tools.
    CFrame::UpdateToolbar();

    pDoc=m_pCL->ActiveDocument();
    fEnable=(NULL!=pDoc);

    //No document, disable just about everything
    m_pTB->Enable(IDM_FILEPRINT,        fEnable);
    m_pTB->Enable(IDM_FILEPRINTERSETUP, fEnable);

    m_pTB->Enable(IDM_PAGENEWPAGE,      fEnable);
    m_pTB->Enable(IDM_PAGEDELETEPAGE,   fEnable);
    m_pTB->Enable(IDM_PAGEFIRSTPAGE,    fEnable);
    m_pTB->Enable(IDM_PAGEPREVIOUSPAGE, fEnable);
    m_pTB->Enable(IDM_PAGENEXTPAGE,     fEnable);
    m_pTB->Enable(IDM_PAGELASTPAGE,     fEnable);

    return;
    }





/*
 * CPatronFrame::MessageLoop
 *
 * Purpose:
 *  Override of standard message loop function in CLASSLIB to use
 *  in-place accelerators when necessary.
 *
 * Parameters:
 *  None
 *
 * Return Value:
 *  WPARAM          Contents of msg.wParam from WM_QUIT.
 */

WPARAM CPatronFrame::MessageLoop(void)
    {
    MSG     msg;

    while (GetMessage(&msg, NULL, 0,0 ))
        {
        HACCEL      hAccel=m_hAccel;

        //Always give the object first crack at translation.
        if (NULL!=m_pIOleIPActiveObject)
            {
            HRESULT     hr;

            hAccel=m_hAccelIP;
            hr=m_pIOleIPActiveObject->TranslateAccelerator(&msg);

            //If the object translated the accelerator, we're done
            if (NOERROR==hr)
                continue;
            }

        if (!m_pCL->TranslateAccelerator(&msg))
            {
            //hAccel is either the normal ones or the in-place ones.

            if (!::TranslateAccelerator(m_hWnd, hAccel, &msg))
                {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
                }
            }
        }

    return msg.wParam;
    }




/*
 * CPatronFrame::FMessageHook
 *
 * Purpose:
 *  Override of CFrame::FMessageHook so we can specifically trap
 *  WM_MENUSELECT messages for the Object verb menu to provide some
 *  meaningful information on the status strip.
 *
 * Parameters:
 *  <WndProc Parameters>
 *  pLRes           LRESULT * in which to store the return value
 *                  for the message.
 *
 * Return Value:
 *  BOOL            TRUE to prevent further processing,
 *                  FALSE otherwise.
 */

BOOL CPatronFrame::FMessageHook(HWND hWnd, UINT iMsg, WPARAM wParam
    , LPARAM lParam, LRESULT *pLRes)
    {
    BOOL        fRet=FALSE;
    int         dx, dy;
    //CHAPTER24MOD
    PCPatronDoc pDoc;
    MSG         msg;
    DWORD       dw;
    //End CHAPTER24MOD

    MENUSELECTPARAMS(wItem, wMenuFlags, hMenu);

    *pLRes=0;

    /*
     * We use a switch now because we previously only processed
     * WM_MENUSELECT which did not use a case statement.
     */

    switch (iMsg)
        {
        case WM_SIZE:
            if (NULL!=m_pIOleIPActiveObject)
                {
                RECT        rc;

                GetClientRect(m_hWnd, &rc);
                m_pIOleIPActiveObject->ResizeBorder(&rc
                    , this, TRUE);
                }

            /*
             * If we're not showing our tools, don't let CLASSLIB
             * resize the client, instead doing it ourselves.
             */
            if (m_fOurToolsShowing)
                return FALSE;

            m_fSizing=TRUE;
            dx=LOWORD(lParam);
            dy=HIWORD(lParam);

            //Change the Toolbar and StatStrip widths to match
            m_pTB->OnSize(hWnd);
            m_pSL->OnSize(hWnd);

            //Adjust the client properly, remembering the StatStrip.
            m_pCL->OnSize(m_cxLeft, m_cyTop, dx-m_cxLeft-m_cxRight
                , dy-m_cyTop-m_cyBottom-CYSTATSTRIP);

            m_fSizing=FALSE;
            return TRUE;

        case WM_ACTIVATEAPP:
            if (NULL!=m_pIOleIPActiveObject)
                {
                m_pIOleIPActiveObject->OnFrameWindowActivate
                    ((BOOL)wParam);
                }

            return FALSE;

        case WM_SETFOCUS:
            if (NULL!=m_pIOleIPActiveObject)
                {
                HWND    hWndObj;

                m_pIOleIPActiveObject->GetWindow(&hWndObj);
                SetFocus(hWndObj);
                }

            return TRUE;

        case WM_CLOSE:
            if (NULL!=m_pDocCreated)
                {
                if (m_pDocCreated->FDirtyGet())
                    {
                    CHourglass  wait;
                    m_pDocCreated->Save(0, NULL);
                    }
                }

            return FALSE;

        case WM_MENUSELECT:
            break;      //Continue processing below.

        //CHAPTER24MOD
        /*
         * Keyboard mnemonics can be Control- or Alt-keys with
         * any other modifier.  That means WM_KEYDOWN with
         * Control on or WM_SYSKEYDOWN by itself.
         */
        case WM_KEYDOWN:
            //Filter out things without Control
            if (!(0x8000 & GetKeyState(VK_CONTROL)))
                return FALSE;

            //FALL-THROUGH

        case WM_SYSKEYDOWN:
            pDoc=(PCPatronDoc)m_pCL->ActiveDocument();

            if (NULL==pDoc)
                return FALSE;

            msg.hwnd=hWnd;
            msg.message=iMsg;
            msg.wParam=wParam;
            msg.lParam=lParam;
            msg.time=GetMessageTime();
            dw=GetMessagePos();
            msg.pt.x=LOWORD(dw);
            msg.pt.y=HIWORD(dw);
            return pDoc->TryMnemonic(&msg);
        //End CHAPTER24MOD

        default:
            return FALSE;
        }

    //This happens when there's no menu selection.
    if (-1==wMenuFlags)
        return FALSE;

    if (MF_POPUP & wMenuFlags)
        {
        /*
         * If this is the cascade verb menu itself, display the same
         * message.  m_phMenu[1] contains the current edit menu
         * handle.
         */
        if (0!=wItem)
            {
            fRet=((HMENU)wItem==GetSubMenu(m_phMenu[1]
                , MENUPOS_OBJECT));
            }
        }
    else
        {
        /*
         * If the ID is in the verb range, use
         * IDS_ITEMMESSAGEEDITOBJECT message
         */
        fRet=(IDM_VERBMIN <= wItem && IDM_VERBMAX >= wItem);
        }

    if (fRet)
        m_pSL->MessageDisplay(IDM_EDITOBJECT);

    return fRet;
    }





/*
 * CPatronFrame::ShowUIAndTools
 *
 * Purpose:
 *  Installs or removes the in-place user interface which includes
 *  the menus and the tools.  The tools may be affected outside of
 *  the menu.
 *
 * Parameters:
 *  fShow           BOOL indicating to show (TRUE) or hide (FALSE)
 *  fMenu           BOOl indicating if the menu is also affected.
 *
 * Return Value:
 *  None
 */

void CPatronFrame::ShowUIAndTools(BOOL fShow, BOOL fMenu)
    {
    HWND    hWndTB;

    //This is the only menu case...restore our original menu
    if (fMenu && fShow)
        SetMenu(NULL, NULL, NULL);

    /*
     * If we're trying to hide our tools but the object didn't
     * want any space, then just leave our tools up and active.
     */

    hWndTB=m_pTB->Window();
    ShowWindow(hWndTB, fShow ? SW_SHOW : SW_HIDE);

    if (fShow)
        {
        InvalidateRect(hWndTB, NULL, TRUE);
        UpdateWindow(hWndTB);
        }

    m_fOurToolsShowing=fShow;
    return;
    }




/*
 * CPatronFrame::ReinstateUI
 *
 * Purpose:
 *  Reinstalls the application's normal toolbar and menu and
 *  readjusts the position of the client window and the documents
 *  within it.
 *
 * Parameters:
 *  None
 *
 * Return Value:
 *  None
 */

void CPatronFrame::ReinstateUI(void)
    {
    BORDERWIDTHS    bw;

    ShowUIAndTools(TRUE, TRUE);

    SetRect((LPRECT)&bw, 0, m_cyBar, 0, 0);
    SetBorderSpace(&bw);
    return;
    }



/*
 * CPatronFrame::QueryInterface
 * CPatronFrame::AddRef
 * CPatronFrame::Release
 */

STDMETHODIMP CPatronFrame::QueryInterface(REFIID riid, PPVOID ppv)
    {
    //We only know IUnknown and IOleInPlaceFrame
    *ppv=NULL;

    if (IID_IUnknown==riid || IID_IOleInPlaceUIWindow==riid
        || IID_IOleWindow==riid || IID_IOleInPlaceFrame==riid)
        *ppv=(LPOLEINPLACEFRAME)this;

    if (NULL!=*ppv)
        {
        ((LPUNKNOWN)*ppv)->AddRef();
        return NOERROR;
        }

    return ResultFromScode(E_NOINTERFACE);
    }


STDMETHODIMP_(ULONG) CPatronFrame::AddRef(void)
    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -