📄 patron.cpp
字号:
return 0L;
case IDM_FILEPRINTERSETUP:
pDoc->PrinterSetup(m_hWnd, FALSE);
return 0L;
case IDM_EDITPASTESPECIAL:
pDoc->PasteSpecial(m_hWnd);
return 0L;
case IDM_EDITDELETEOBJECT:
pDoc->Delete();
return 0L;
case IDM_EDITINSERTOBJECT:
pDoc->InsertObject(m_hWnd);
return 0L;
case IDM_EDITCONVERT:
pDoc->ConvertObject(m_hWnd);
return 0L;
case IDM_EDITLINKS:
pDoc->EditLinks(m_hWnd);
return 0L;
case IDM_PAGENEWPAGE:
pDoc->NewPage();
break;
case IDM_PAGEDELETEPAGE:
pDoc->DeletePage();
break;
case IDM_PAGENEXTPAGE:
pDoc->NextPage();
break;
case IDM_PAGEPREVIOUSPAGE:
pDoc->PreviousPage();
break;
case IDM_PAGEFIRSTPAGE:
pDoc->FirstPage();
break;
case IDM_PAGELASTPAGE:
pDoc->LastPage();
break;
case IDM_PAGESHOWOBJECTS:
{
BOOL fTemp;
//First get the current state, then toggle it.
fTemp=pDoc->ShowOrQueryObjectTypes(TRUE, FALSE);
pDoc->ShowOrQueryObjectTypes(FALSE, !fTemp);
}
break;
default:
return CFrame::OnCommand(hWnd, wParam, lParam);
}
return 0L;
}
/*
* CPatronFrame::CreateToolbar
*
* Purpose:
* Procedure to create all the necessary toolbar buttons.
*
* Parameters:
* None
*
* Return Value:
* UINT Number of tools added to the bar.
*/
UINT CPatronFrame::CreateToolbar(void)
{
UINT iLast;
UINT uState=GIZMO_NORMAL;
UINT utCmd =GIZMOTYPE_BUTTONCOMMAND;
//Insert the standard ones.
iLast=CFrame::CreateToolbar();
//Remove Undo: we don't use it.
m_pTB->Remove(IDM_EDITUNDO);
/*
* Insert Print File Import in the 5th position and account
* for it in iLast.
*/
m_pTB->Add(utCmd, 4, IDM_FILEPRINT, m_dxB, m_dyB
, NULL, NULL, 6, uState);
iLast++;
m_pTB->Add(GIZMOTYPE_SEPARATOR, iLast++, 0, 6, m_dyB
, 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);
//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);
}
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::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;
*pLRes=0;
MENUSELECTPARAMS(wItem, wMenuFlags, hMenu);
//CHAPTER21MOD
/*
* When closing, make sure any document create from the
* class factory is saved since the object in it might
* have been changed. We want to save without showing
* the user any message or asking if the user wants to save.
*/
if (WM_CLOSE==iMsg)
{
if (NULL!=m_pDocCreated)
{
if (m_pDocCreated->FDirtyGet())
{
CHourglass wait;
m_pDocCreated->Save(0, NULL);
}
}
return FALSE;
}
//End CHAPTER21MOD
//If this is the wrong message, nothing to do.
if (WM_MENUSELECT!=iMsg)
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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -