📄 bcgptoolbar.h
字号:
}
// By Jay Giganti
BOOL GetIgnoreSetText () const
{
return m_bIgnoreSetText;
}
void SetIgnoreSetText (BOOL bValue)
{
m_bIgnoreSetText = bValue;
}
///
BOOL GetRouteCommandsViaFrame ()
{
return m_bRouteCommandsViaFrame;
}
void SetRouteCommandsViaFrame (BOOL bValue)
{
m_bRouteCommandsViaFrame = bValue;
}
BOOL IsAddRemoveQuickCustomize()
{
return m_bQuickCustomize;
}
BOOL IsBrother()
{
return m_bHasBrother;
}
CBCGPToolBar* GetBrotherToolbar()
{
return m_pBrotherToolBar;
}
void SetBrotherToolbar(CBCGPToolBar* pBrotherToolbar);
BOOL IsOneRowWithBrother();
void SetOneRowWithBrother();
void SetTwoRowsWithBrother();
BOOL CanHandleBrothers();
static BOOL GetShowTooltips() {return m_bShowTooltips;} //JRG Modified 3/21/2000
static void SetShowTooltips(BOOL bValue) {m_bShowTooltips = bValue;} //JRG Modified 3/21/2000
HWND GetHwndLastFocus() const {return m_hwndLastFocus;};
static BOOL m_bDisableLabelsEdit;
public:
// for changing button info
void GetButtonInfo(int nIndex, UINT& nID, UINT& nStyle, int& iImage) const;
void SetButtonInfo(int nIndex, UINT nID, UINT nStyle, int iImage);
BOOL SetButtonText(int nIndex, LPCTSTR lpszText);
CString GetButtonText( int nIndex ) const;
void GetButtonText( int nIndex, CString& rString ) const;
// Save/load toolbar state + buttons:
void Serialize (CArchive& ar);
virtual BOOL LoadState (LPCTSTR lpszProfileName = NULL, int nIndex = -1, UINT uiID = (UINT) -1);
virtual BOOL SaveState (LPCTSTR lpszProfileName = NULL, int nIndex = -1, UINT uiID = (UINT) -1);
virtual BOOL RemoveStateFromRegistry (LPCTSTR lpszProfileName = NULL, int nIndex = -1, UINT uiID = (UINT) -1);
static BOOL LoadParameters (LPCTSTR lpszProfileName = NULL);
static BOOL SaveParameters (LPCTSTR lpszProfileName = NULL);
static BOOL LoadLargeIconsState (LPCTSTR lpszProfileName = NULL);
virtual BOOL CanBeRestored () const;
virtual BOOL CanBeClosed () const
{
return !m_bPermament;
}
virtual BOOL RestoreOriginalstate ();
virtual void OnReset () {}
static void ResetAll ();
virtual void AdjustLayout ();
virtual int HitTest(CPoint point);
virtual BOOL TranslateChar (UINT nChar);
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
virtual BOOL PrevMenu ();
virtual BOOL NextMenu ();
BOOL ProcessCommand (CBCGPToolbarButton* pButton);
CBCGPToolbarMenuButton* GetDroppedDownMenu (int* pIndex = NULL) const;
BOOL SetHot (CBCGPToolbarButton *pMenuButton);
virtual BOOL OnSetDefaultButtonText (CBCGPToolbarButton* pButton);
BOOL IsDragButton (const CBCGPToolbarButton* pButton) const
{
return pButton == m_pDragButton;
}
virtual void OnFillBackground (CDC* /*pDC*/) {}
virtual void OnGlobalFontsChanged ();
static BOOL m_bExtCharTranslation;
static void CBCGPToolBar::CleanUpImages ();
void AdjustSize ();
// Implementation
public:
virtual ~CBCGPToolBar();
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual CSize CalcSize (BOOL bVertDock);
int WrapToolBar (int nWidth, int nHeight = 32767);
virtual void OnChangeHot (int iHot);
virtual CSize StretchControlBar (int nLength, BOOL bVert);
CBCGPToolbarButton* InvalidateButton(int nIndex);
void UpdateButton(int nIndex);
protected:
virtual CSize CalcLayout (DWORD dwMode, int nLength = -1);
void SizeToolBar (int nLength, BOOL bVert = FALSE);
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
virtual int InsertButton (CBCGPToolbarButton* pButton, int iInsertAt = -1);
virtual BOOL DrawButton (CDC* pDC, CBCGPToolbarButton* pButton,
CBCGPToolBarImages* pImages, BOOL bHighlighted,
BOOL bDrawDisabledImages);
virtual void DrawDragMarker (CDC* pDC);
CBCGPToolBarImages* GetImageList (CBCGPToolBarImages& images, CBCGPToolBarImages& imagesLocked,
CBCGPToolBarImages& largeImages, CBCGPToolBarImages& largeImagesLocked) const;
void RebuildAccelerationKeys ();
virtual CWnd* GetCommandTarget () const
{
// determine target of command update
CFrameWnd* pTarget = (CFrameWnd*) GetOwner();
if (pTarget == NULL || (m_bRouteCommandsViaFrame && !pTarget->IsFrameWnd ()))
{
pTarget = BCGPGetParentFrame (this);
}
return pTarget;
}
void UpdateTooltips ();
virtual void OnAfterFloat ();
protected:
friend class CBCGPWorkspace;
static CBCGPToolBar* m_pSelToolbar; // "Selected" toolbar in the customization mode
static CBCGPToolBarImages m_Images; // Shared toolbar images
static CBCGPToolBarImages m_ColdImages; // Shared toolbar "cold" images
static CBCGPToolBarImages m_DisabledImages; // Shared disabled images
static CBCGPToolBarImages m_LargeImages; // Shared toolbar large "hot" images
static CBCGPToolBarImages m_LargeColdImages; // Shared toolbar large "cold" images
static CBCGPToolBarImages m_LargeDisabledImages; // Shared disabled large images
static CBCGPToolBarImages m_MenuImages;
static CBCGPToolBarImages m_DisabledMenuImages;
static CBCGPToolBarImages* m_pUserImages; // Shared user-defined images
CBCGPToolBarImages m_ImagesLocked; // "Locked" toolbar images
CBCGPToolBarImages m_ColdImagesLocked; // "Locked" toolbar "cold" images
CBCGPToolBarImages m_DisabledImagesLocked; // "Locked" toolbar disabled images
CBCGPToolBarImages m_LargeImagesLocked; // "Locked" toolbar large images
CBCGPToolBarImages m_LargeColdImagesLocked; // "Locked" toolbar large "cold" images
CBCGPToolBarImages m_LargeDisabledImagesLocked; // "Locked" toolbar large disabled images
CBCGPToolBarImages m_MenuImagesLocked; // "Locked" toolbar menu images
CBCGPToolBarImages m_DisabledMenuImagesLocked; // "Locked" toolbar menu disabled images
BOOL m_bLocked;
BOOL m_bLargeIconsAreEnbaled;
CBCGPControlBarImpl m_Impl;
BOOL m_bMasked;
BOOL m_bPermament; // Can't be closed
BOOL m_bTextLabels; // Text labels below the image are available
BOOL m_bDrawTextLabels;
int m_nMaxBtnHeight;// Actual only if m_bTextLabels is TRUE
static CMap<UINT, UINT, int, int> m_DefaultImages;
static CSize m_sizeButton; // original size of button
static CSize m_sizeImage; // original size of glyph
static CSize m_sizeMenuButton; // size of button on the menu
static CSize m_sizeMenuImage; // size of image on the menu
static CSize m_sizeCurButton; // size of button
static CSize m_sizeCurImage; // size of glyph
CSize m_sizeButtonLocked; // original size of button of the locked toolbars
CSize m_sizeImageLocked; // original size of glyph of the locked toolbars
CSize m_sizeCurButtonLocked; // size of button
CSize m_sizeCurImageLocked; // size of glyph
int m_iButtonCapture; // index of button with capture (-1 => none)
int m_iHighlighted; // highlighted button index
int m_iSelected; // selected button index
int m_iHot;
CObList m_Buttons;
CObList m_OrigButtons; // Original (not customized) items
CObList m_OrigResetButtons; // Original (not customized) items after reset
BOOL m_bResourceWasChanged; // Resource was changed since last session
BOOL m_bLeaveFocus; // Don't remove selection in the focused bars.
#ifndef BCG_NO_CUSTOMIZATION
CBCGPToolbarDropTarget m_DropTarget;
static CBCGPToolbarDropSource m_DropSource;
#endif // BCG_NO_CUSTOMIZATION
static BOOL m_bCustomizeMode;
static BOOL m_bAltCustomizeMode;
CToolTipCtrl m_ToolTip;
int m_nTooltipsCount;
int m_iDragIndex;
CRect m_rectDrag;
CPen m_penDrag;
CBCGPToolbarButton* m_pDragButton;
CPoint m_ptStartDrag;
BOOL m_bIsDragCopy;
BOOL m_bStretchButton;
CRect m_rectTrack;
int m_iImagesOffset;
UINT m_uiOriginalResID; // Toolbar resource ID
BOOL m_bTracked;
CPoint m_ptLastMouse;
BOOL m_bMenuMode;
CWnd* m_pWndLastCapture;
HWND m_hwndLastFocus;
BOOL m_bDisableControlsIfNoHandler;
BOOL m_bRouteCommandsViaFrame;
BOOL m_bDisableCustomize;
CSize m_sizeLast;
static COLORREF m_clrTextHot;
static HHOOK m_hookMouseHelp; // Mouse hook for the help mode
static CBCGPToolBar* m_pLastHookedToolbar;
CMap<UINT, UINT&, CBCGPToolbarButton*, CBCGPToolbarButton*&> m_AcellKeys; // Keyborad acceleration keys
static BOOL m_bShowTooltips;
static BOOL m_bShowShortcutKeys;
static BOOL m_bLargeIcons;
static CList<UINT, UINT> m_lstUnpermittedCommands;
static CList<UINT, UINT> m_lstBasicCommands;
static CCmdUsageCount m_UsageCount;
BOOL m_bShowHotBorder;
BOOL m_bGrayDisabledButtons;
BOOL m_bIgnoreSetText;
int m_nMaxLen;
static BOOL m_bAltCustomization;
CCustomizeButton* m_pCustomizeBtn;
BOOL m_bQuickCustomize;
BOOL m_bHasBrother;
BOOL m_bElderBrother;
CBCGPToolBar* m_pBrotherToolBar;
virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
virtual void OnDragLeave();
virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
virtual void DoPaint(CDC* pDC);
virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
virtual BOOL NotifyControlCommand (CBCGPToolbarButton* pButton,
BOOL bAccelerator,
int nNotifyCode,
WPARAM wParam,
LPARAM lParam);
virtual int FindDropIndex (const CPoint point, CRect& rectDrag) const;
virtual void AdjustLocations ();
virtual BOOL OnSendCommand (const CBCGPToolbarButton* /*pButton*/) { return FALSE; }
virtual BOOL AllowSelectDisabled () const { return FALSE; }
virtual BOOL AllowShowOnList () const { return TRUE; }
virtual void DrawSeparator (CDC* pDC, const CRect& rect, BOOL bHorz);
virtual CBCGPToolbarButton* CreateDroppedButton (COleDataObject* pDataObject);
virtual BOOL OnKey (UINT /*nChar*/) { return FALSE; }
virtual void OnCustomizeMode (BOOL bSet);
virtual BOOL EnableContextMenuItems (CBCGPToolbarButton* pButton, CMenu* pPopup);
virtual BOOL IsPureMenuButton (CBCGPToolbarButton* /*pButton*/) const
{
return m_bMenuMode;
}
virtual void OnCalcSeparatorRect (CBCGPToolbarButton* pButton,
CRect& rectSeparator,
BOOL bHorz);
void AddRemoveSeparator (const CBCGPToolbarButton* pButton,
const CPoint& ptStart, const CPoint& ptDrop);
virtual void ShowCommandMessageString (UINT uiCmdId);
static LRESULT CALLBACK BCGToolBarMouseProc (int nCode, WPARAM wParam, LPARAM lParam);
BOOL DropDownMenu (CBCGPToolbarButton* pButton);
virtual int CalcMaxButtonHeight ();
virtual BOOL OnUserToolTip (CBCGPToolbarButton* pButton, CString& strTTText) const;
// SmartUpdate methods:
virtual void SaveOriginalState (CBCGPRegistry& reg);
virtual BOOL LoadLastOriginalState (CBCGPRegistry& reg);
virtual BOOL SmartUpdate (const CObList& lstPrevButtons);
void SaveResetOriginalState (CBCGPRegistry& reg);
BOOL LoadResetOriginalState (CBCGPRegistry& reg);
//{{AFX_MSG(CBCGPToolBar)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnCancelMode();
afx_msg void OnSysColorChange();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnToolbarAppearance();
afx_msg void OnToolbarDelete();
afx_msg void OnToolbarImage();
afx_msg void OnToolbarImageAndText();
afx_msg void OnToolbarStartGroup();
afx_msg void OnToolbarText();
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnBcgbarresToolbarReset();
afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
afx_msg void OnNcPaint();
afx_msg UINT OnNcHitTest(CPoint point);
afx_msg void OnBcgbarresCopyImage();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnBcgbarresToolbarNewMenu();
afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
//}}AFX_MSG
afx_msg void OnContextMenu(CWnd*, CPoint point);
afx_msg LRESULT OnMouseLeave(WPARAM,LPARAM);
afx_msg LRESULT OnHelpHitTest(WPARAM,LPARAM);
afx_msg LRESULT OnGetButtonCount(WPARAM,LPARAM);
afx_msg LRESULT OnGetItemRect(WPARAM,LPARAM);
afx_msg LRESULT OnGetButton(WPARAM,LPARAM);
afx_msg LRESULT OnGetButtonText(WPARAM,LPARAM);
afx_msg BOOL OnNeedTipText(UINT id, NMHDR* pNMH, LRESULT* pResult);
afx_msg LRESULT OnPromptReset(WPARAM, LPARAM);
DECLARE_MESSAGE_MAP()
};
#endif //!_TOOLBAR_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -