📄 cmenudrawer.cpp
字号:
RECT rcText;
int nBkModeOld;
nIndentLeft = 26;
nIndentRight = 8;
nTextTopMargin = 3;
/* for( i = 0; i < m_nMenuItemNum; ++i ){
if( (int)lpdis->itemID == m_nMenuItemFuncArr[i] ){
break;
}
}
if( i >= m_nMenuItemNum ){
return;
}
nItemIndex = i;
*/
//@@@ 2002.01.03 YAZAKI 極力メンバ関数を使用するように。
nItemIndex = Find( (int)lpdis->itemID );
pszItemStr = m_cmemMenuItemStrArr[nItemIndex].GetPtr( &nItemStrLen );
// hdc = ::GetDC( m_hWndOwner );
hdc = lpdis->hDC;
hFontOld = (HFONT)::SelectObject( hdc, m_hFontMenu );
/* アイテム矩形塗りつぶし */
// hBrush = ::CreateSolidBrush( ::GetSysColor( COLOR_MENU ) );
hBrush = ::GetSysColorBrush( COLOR_MENU );
::FillRect( hdc, &lpdis->rcItem, hBrush );
// ::DeleteObject( hBrush );
/* アイテムが選択されている */
nBkModeOld = ::SetBkMode( hdc, TRANSPARENT );
if( lpdis->itemState & ODS_SELECTED ){
// hBrush = ::CreateSolidBrush( ::GetSysColor( COLOR_HIGHLIGHT/*COLOR_3DHIGHLIGHT*/ ) );
hBrush = ::GetSysColorBrush( COLOR_HIGHLIGHT );
rc1 = lpdis->rcItem;
if( -1 != m_nMenuItemBitmapIdxArr[nItemIndex] || lpdis->itemState & ODS_CHECKED ){
rc1.left += (nIndentLeft - 2);
}
/* 選択ハイライト矩形 */
::FillRect( hdc, &rc1, hBrush );
// ::DeleteObject( hBrush );
/* アイテムが使用不可 */
if( lpdis->itemState & ODS_DISABLED ){
::SetTextColor( hdc, ::GetSysColor( COLOR_MENU/*COLOR_3DSHADOW*/ ) );
}else{
::SetTextColor( hdc, ::GetSysColor( COLOR_HIGHLIGHTTEXT/*COLOR_MENUTEXT*//*COLOR_3DHIGHLIGHT*/ ) );
}
}else{
/* アイテムが使用不可 */
if( lpdis->itemState & ODS_DISABLED ){
::SetTextColor( hdc, ::GetSysColor( COLOR_3DSHADOW ) );
}else{
::SetTextColor( hdc, ::GetSysColor( COLOR_MENUTEXT ) );
}
}
#ifdef _DEBUG
char szText[1024];
MENUITEMINFO mii;
// メニュー項目に関する情報を取得します。
memset( &mii, 0, sizeof( MENUITEMINFO ) );
#ifdef _WIN64
mii.cbSize = sizeof( MENUITEMINFO ); // 64bit版ではサイズ違う
#else
mii.cbSize = SIZEOF_MENUITEMINFO; // Jan. 29, 2002 genta
#endif
mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE;
mii.fType = MFT_STRING;
strcpy( szText, "--unknown--" );
mii.dwTypeData = (LPTSTR)szText;
mii.cch = sizeof( szText ) - 1;
if( 0 != ::GetMenuItemInfo( (HMENU)lpdis->hwndItem, lpdis->itemID, FALSE, (MENUITEMINFO*)&mii )
&& NULL == mii.hSubMenu
&& 0 == /* CEditWnd */::FuncID_To_HelpContextID( lpdis->itemID ) /* 機能IDに対応するメニューコンテキスト番号を返す */
){
//@@@ 2001.12.21 YAZAKI
if( lpdis->itemState & ODS_SELECTED ){
::SetTextColor( hdc, ::GetSysColor( COLOR_HIGHLIGHTTEXT ) ); // ハイライトカラー
}
else {
::SetTextColor( hdc, RGB( 0, 0, 255 ) ); // 青くしてる。
}
// ::SetTextColor( hdc, RGB( 0, 0, 255 ) );
}
#endif
rcText = lpdis->rcItem;
rcText.left += nIndentLeft;
rcText.right -= nIndentRight;
/* TAB文字の前と後ろに分割してテキストを描画する */
for( j = 0; j < nItemStrLen; ++j ){
if( pszItemStr[j] == '\t' ){
break;
}
}
/* TAB文字の後ろ側のテキストを描画する */
if( j < nItemStrLen ){
/* アイテムが使用不可 */
if( lpdis->itemState & ODS_DISABLED && !(lpdis->itemState & ODS_SELECTED) ){
COLORREF colOld = ::SetTextColor( hdc, ::GetSysColor( COLOR_3DHIGHLIGHT ) );
rcText.left++;
rcText.top++;
rcText.right++;
rcText.bottom++;
::DrawText( hdc, &pszItemStr[j + 1], strlen( &pszItemStr[j + 1] ), &rcText, DT_SINGLELINE | DT_VCENTER | DT_EXPANDTABS | DT_RIGHT );
rcText.left--;
rcText.top--;
rcText.right--;
rcText.bottom--;
::SetTextColor( hdc, colOld );
}
::DrawText( hdc, &pszItemStr[j + 1], strlen( &pszItemStr[j + 1] ), &rcText, DT_SINGLELINE | DT_VCENTER | DT_EXPANDTABS | DT_RIGHT );
}
/* TAB文字の前側のテキストを描画する */
/* アイテムが使用不可 */
if( lpdis->itemState & ODS_DISABLED && !(lpdis->itemState & ODS_SELECTED) ){
COLORREF colOld = ::SetTextColor( hdc, ::GetSysColor( COLOR_3DHIGHLIGHT ) );
rcText.left++;
rcText.top++;
rcText.right++;
rcText.bottom++;
::DrawText( hdc, pszItemStr, j, &rcText, DT_SINGLELINE | DT_VCENTER | DT_EXPANDTABS | DT_LEFT );
rcText.left--;
rcText.top--;
rcText.right--;
rcText.bottom--;
::SetTextColor( hdc, colOld );
}
::DrawText( hdc, pszItemStr, j, &rcText, DT_SINGLELINE | DT_VCENTER | DT_EXPANDTABS | DT_LEFT );
::SelectObject( hdc, hFontOld );
::SetBkMode( hdc, nBkModeOld );
/* チェック状態なら凹んだ3D枠を描画する */
if( lpdis->itemState & ODS_CHECKED ){
/* アイコンを囲む枠 */
CSplitBoxWnd::Draw3dRect(
hdc, lpdis->rcItem.left + 1, lpdis->rcItem.top,
2 + 16 + 2, lpdis->rcItem.bottom - lpdis->rcItem.top,
::GetSysColor( COLOR_3DSHADOW ),
::GetSysColor( COLOR_3DHILIGHT )
);
/* アイテムが選択されていない場合は3D枠の中を明るく塗りつぶす */
if( lpdis->itemState & ODS_SELECTED ){
}else{
// HBRUSH hbr = ::CreateSolidBrush( ::GetSysColor( COLOR_3DHILIGHT ) );
// HBRUSH hbr = ::CreateSolidBrush( ::GetSysColor( COLOR_3DLIGHT ) );
HBRUSH hbr = ::GetSysColorBrush( COLOR_3DLIGHT );
HBRUSH hbrOld = (HBRUSH)::SelectObject( hdc, hbr );
RECT rc;
::SetRect( &rc, lpdis->rcItem.left + 1 + 1, lpdis->rcItem.top + 1, lpdis->rcItem.left + 1 + 1 + 16 + 2, lpdis->rcItem.top + 1+ 15 + 2 );
::FillRect( hdc, &rc, hbr );
::SelectObject( hdc, hbrOld );
// ::DeleteObject( hbr );
}
}
/* 機能の画像が存在するならメニューアイコン?を描画する */
if( -1 != m_nMenuItemBitmapIdxArr[nItemIndex] ){
/* 3D枠を描画する */
/* アイテムが選択されている */
if( lpdis->itemState & ODS_SELECTED ){
/* アイテムが使用不可 */
if( lpdis->itemState & ODS_DISABLED /*&& !(lpdis->itemState & ODS_SELECTED)*/ ){
}else{
if( lpdis->itemState & ODS_CHECKED ){
}else{
/* アイコンを囲む枠 */
CSplitBoxWnd::Draw3dRect(
hdc, lpdis->rcItem.left + 1, lpdis->rcItem.top,
2 + 16 + 2, lpdis->rcItem.bottom - lpdis->rcItem.top,
::GetSysColor( COLOR_3DHILIGHT ),
::GetSysColor( COLOR_3DSHADOW )
);
}
}
}
/* アイテムが使用不可 */
if( lpdis->itemState & ODS_DISABLED ){
/* 淡色アイコン */
// 2003.09.04 Moca SetTextColorする必要は無い
// COLORREF cOld;
// cOld = SetTextColor( hdc, GetSysColor(COLOR_3DSHADOW) ); //Oct. 24, 2000 これは標準ではRGB(128,128,128)と同じ
// cOld = SetTextColor( hdc, RGB(132,132,132) ); //Oct. 24, 2000 JEPRO もう少し薄くした
m_pcIcons->Draw( m_nMenuItemBitmapIdxArr[nItemIndex],
hdc, // Target DC
lpdis->rcItem.left + 1, // X
//@@@ 2002.1.29 YAZ
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -