📄 ooextoolbar.cpp
字号:
SetStandardImageList( pTempNormalList );
// SetDisableImageList( pTempDisableList );
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// To set the image list in the control.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void COOExToolBar::InitImageList( void )
{
// Set the image list according to the current mode.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
AssignImageList();
}
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Private Image list method.
// ------------------------------------------------------------------------
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// Method to calculate the current size of the button.
// @rdesc The button size.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
CSize COOExToolBar::CalcButtonSize( void )
{
// Calcul the width of the drop button.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CSize theButtonSize;
if ( m_nShowIconMode == 0 )
{
theButtonSize = CSize( m_SmallIconSize.cx + 8, m_SmallIconSize.cy + 7 );
}
else if ( m_nShowIconMode == 1 )
{
theButtonSize = CSize( m_LargeIconSize.cx + 8, m_LargeIconSize.cy + 7 );
}
// Check the text mode and set or hide the text.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if ( m_bShowIconText )
{
// The text width is the maximum width of the bitmap. All toolbar size
// must at least be this width.
if ( theButtonSize.cx < m_nTextWidth )
{
theButtonSize.cx = m_nTextWidth;
}
// The text height is the height added to the button. Even in large mode
// we must add this text height.
theButtonSize.cy += m_nTextHeight;
}
return theButtonSize;
}
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Image list information method.
// ------------------------------------------------------------------------
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// To set the hoover image list.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void COOExToolBar::SetHotImageList(
CImageList* pList ) // @Parm The hoover image list.
{
// Retrieve the tool bar control and set the list reference.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CWnd* pWnd = &GetToolBarCtrl();
pWnd->SendMessage( TB_SETHOTIMAGELIST, 0, ( LPARAM ) ( HIMAGELIST ) *pList );
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// To set the normal image list.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void COOExToolBar::SetStandardImageList(
CImageList* pList ) // @Parm The normal image list.
{
// Retrieve the tool bar control and set the list reference.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CWnd* pWnd = &GetToolBarCtrl();
pWnd->SendMessage( TB_SETIMAGELIST, 0, ( LPARAM ) ( HIMAGELIST ) *pList );
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// To set the disable image list.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void COOExToolBar::SetDisableImageList(
CImageList* pList ) // @Parm The normal image list.
{
// Retrieve the tool bar control and set the list reference.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CWnd* pWnd = &GetToolBarCtrl();
pWnd->SendMessage( TB_SETDISABLEDIMAGELIST, 0, ( LPARAM ) ( HIMAGELIST ) *pList );
}
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usefull protected method.
// ------------------------------------------------------------------------
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// To display the dropdown button for the given button.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
/*void COOExToolBar::SetButtonDropDown(
int nID ) // @Parm The id to show the drop down.
{
// Change button style to dropdown.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
DWORD dwStyle = GetButtonStyle( CommandToIndex( nID ) );
dwStyle |= TBSTYLE_DROPDOWN;
SetButtonStyle( CommandToIndex( nID ), dwStyle );
// Calculate the drop button size.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CToolBarCtrl& bar = GetToolBarCtrl();
CSize theStdButtonSize = CalcButtonSize();
CRect rc( 0, 0, 0, 0 );
bar.GetItemRect( CommandToIndex( nID ), rc );
m_nDropButtonSize = rc.Width() - theStdButtonSize.cx;
}*/
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usefull protected method.
// ------------------------------------------------------------------------
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// To resieze the toolbar once something change.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void COOExToolBar::ResizeToolBar( void )
{
// Set the size of the toolbar corresponding to the current mode.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CSize theSize = ( m_nShowIconMode == 0 ) ? m_SmallIconSize : m_LargeIconSize;
CSize theButtonSize = CalcButtonSize();
// Resize the toolbar and the dock frame.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
SetSizes( theButtonSize, theSize );
MoveWindow( 0, 0, 450, theButtonSize.cy );
SendMessage( WM_SIZE, SIZE_RESTORED );
CFrameWnd* pFrameWnd = GetDockingFrame();
pFrameWnd->DelayRecalcLayout();
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// To draw the gripper on the toolbar.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
/*void COOExToolBar::DrawGripper(
CDC& dc ) const // @Parm The device context where to draw the gripper.
{
// No gripper if floating
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if( m_dwStyle & CBRS_FLOATING )
{
return;
}
// Retrieve the window coord and calculate the gripper position.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CRect gripper;
GetWindowRect( gripper );
ScreenToClient( gripper );
gripper.OffsetRect( -gripper.left, -gripper.top );
// Draw it accordingly to the orientation of the toolbar.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
COLORREF clrBtnHilight = ::GetSysColor(COLOR_BTNHILIGHT);
COLORREF clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW);
if( m_dwStyle & CBRS_ORIENT_HORZ ) {
// gripper at left
gripper.DeflateRect( 3, 3 );
gripper.right = gripper.left+3;
dc.Draw3dRect( gripper, clrBtnHilight, clrBtnShadow );
gripper.OffsetRect(5, 0);
dc.Draw3dRect( gripper, clrBtnHilight, clrBtnShadow );
}
else {
// gripper at top
gripper.DeflateRect( 3, 3 );
gripper.bottom = gripper.top+3;
dc.Draw3dRect( gripper, clrBtnHilight, clrBtnShadow );
gripper.OffsetRect(0, 5);
dc.Draw3dRect( gripper, clrBtnHilight, clrBtnShadow );
}
}*/
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// MFC Overloaded method.
// ------------------------------------------------------------------------
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// Only overloaded to use our cmdui instead of their. This is
// the same code found in CToolBar::OnUpdateCmdUI, but we
// replace the CCmdUI by CCoolCmdUI.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void COOExToolBar::OnUpdateCmdUI(
CFrameWnd* pTarget, // @Parm ??
BOOL bDisableIfNoHndler ) // @Parm ??
{
CCoolCmdUI state; // this is the only line that's different--PD
state.m_pOther = this;
state.m_nIndexMax = ( UINT ) DefWindowProc( TB_BUTTONCOUNT, 0, 0 );
for ( state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax; state.m_nIndex++ )
{
// get button state
TBBUTTON button;
VERIFY( DefWindowProc( TB_GETBUTTON, state.m_nIndex, ( LPARAM ) &button ) );
// TBSTATE_ENABLED == TBBS_DISABLED so invert it
button.fsState ^= TBSTATE_ENABLED;
state.m_nID = button.idCommand;
// ignore separators
if ( !( button.fsStyle & TBSTYLE_SEP ) )
{
// allow the toolbar itself to have update handlers
if ( CWnd::OnCmdMsg( state.m_nID, CN_UPDATE_COMMAND_UI, &state, NULL ) )
continue;
// allow the owner to process the update
state.DoUpdate( pTarget, bDisableIfNoHndler );
}
}
// update the dialog controls added to the toolbar
UpdateDialogControls( pTarget, bDisableIfNoHndler );
}
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// MFC Message method.
// ------------------------------------------------------------------------
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// This will draw the gripper on the toolbar then repaints
// client areas.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
/*void COOExToolBar::OnNcPaint( void )
{
CControlBar::EraseNonClient();
CWindowDC dc( this );
DrawGripper( dc );
CRect pRect;
GetClientRect( &pRect );
InvalidateRect( &pRect, TRUE );
CWnd* pWnd = &GetToolBarCtrl();
pWnd->GetClientRect( &pRect );
pWnd->InvalidateRect( &pRect, TRUE );
}
*/
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// Trap to set the flat bar style.
// @RDesc Nonzero if the toolbar is correctly created.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
int COOExToolBar::OnCreate(
LPCREATESTRUCT lpCreateStruct ) // @Parm Toolbar creation information.
{
// Call the base class method.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if ( CToolBar::OnCreate( lpCreateStruct ) == -1 )
{
return -1;
}
// Set the style to flat.
// There is a but when docking vertical. The size of the separator
// is not calculate correctly by MFC. Only in style flat.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
ModifyStyle( 0, TBSTYLE_FLAT );
SendMessage( TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS );
// The window is now created.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
return 0;
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @mfunc: (FUNCTIONAL)
// <c COOExToolBar>
// Trap to size correctly the toolbar with the carret.
// @end =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
/*void COOExToolBar::OnNcCalcSize(
BOOL bCalcValidRects, // @Parm MFC Specific message.
NCCALCSIZE_PARAMS FAR* lpncsp ) // @Parm MFC Specific message.
{
// No gripper if floating
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if( !( m_dwStyle & CBRS_FLOATING ) )
{
// Adjust non-client area for gripper at left or top.
if( m_dwStyle & CBRS_ORIENT_HORZ ) {
lpncsp->rgrc[0].left += 5;
lpncsp->rgrc[0].right += 5;
}
else {
lpncsp->rgrc[0].top += 5;
lpncsp->rgrc[0].bottom += 5;
}
}
CToolBar::OnNcCalcSize( bCalcValidRects, lpncsp );
}*/
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -