本文整理汇总了C++中CClientDC::GetDeviceCaps方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientDC::GetDeviceCaps方法的具体用法?C++ CClientDC::GetDeviceCaps怎么用?C++ CClientDC::GetDeviceCaps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClientDC
的用法示例。
在下文中一共展示了CClientDC::GetDeviceCaps方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCreate
int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd ::OnCreate(lpCreateStruct) == -1)
return -1;
//
// Load the bitmap.
//
m_bitmap.LoadBitmap (IDB_BITMAP);
//
// Create a palette for a gradient fill if this is a palettized device.
//
CClientDC dc (this);
if (dc.GetDeviceCaps (RASTERCAPS) & RC_PALETTE) {
struct {
LOGPALETTE lp;
PALETTEENTRY ape[63];
} pal;
LOGPALETTE* pLP = (LOGPALETTE*) &pal;
pLP->palVersion = 0x300;
pLP->palNumEntries = 64;
for (int i=0; i<64; i++) {
pLP->palPalEntry[i].peRed = 0;
pLP->palPalEntry[i].peGreen = 0;
pLP->palPalEntry[i].peBlue = 255 - (i * 4);
pLP->palPalEntry[i].peFlags = 0;
}
m_palette.CreatePalette (pLP);
}
return 0;
}
示例2: OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CBCGPMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
HICON m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
SetIcon(m_hIcon, TRUE); // Set big icon
// Menu will not take the focus on activation:
CBCGPPopupMenu::SetForceMenuFocus (FALSE);
EnableDocking(CBRS_ALIGN_TOP);
if (!m_wndMenuBar.Create (this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_SIZE_DYNAMIC);
m_wndMenuBar.SetRecentlyUsedMenus(FALSE); //不加这句话,菜单初始时,只显示一个下拉键头,不显示全部菜单项.
// Detect color depth. 256 color toolbars can be used in the
// high or true color modes only (bits per pixel is > 8):
CClientDC dc (this);
BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;
UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0;
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to be dockable
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
EnableAutoHideBars(CBRS_ALIGN_ANY);
DockControlBar(&m_wndMenuBar);
CreateMineToolBar(); // 创建工具栏
m_MineToolbar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_MineToolbar);
// Allow user-defined toolbars operations:
InitUserToobars (NULL,
uiFirstUserToolBarId,
uiLastUserToolBarId);
AdjustClientArea();
// Enable windows manager:
EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE);
OnAppLook (m_nAppLook);
SetWindowText("综合设计环境");
SetTitle( "综合设计环境" );
// VISUAL_MANAGER
return 0;
}
示例3: OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// enable Windows XP look (in other OS Office XP look will be used):
CBCGPVisualManager::SetDefaultManager (RUNTIME_CLASS (CVisualManager));
CBCGPDockManager::SetDockMode (BCGP_DT_STANDARD);
CBCGPToolBar::m_dblLargeImageRatio = 1.2;
CBCGPToolBar::SetSizes (CSize (22, 22), CSize (16, 16));
CBCGPToolBar::SetMenuSizes (CBCGPToolBar::GetMenuButtonSize (), CSize (16, 16));
// Detect color depth. 256 color toolbars can be used in the
// high or true color modes only (bits per pixel is > 8):
CClientDC dc (this);
theApp.m_nColorMode = (WORD)dc.GetDeviceCaps (BITSPIXEL);
//-----------------------
// Create the addressbar:
//-----------------------
CBCGPToolbarComboBoxButton::SetFlatMode (FALSE);
CBCGPToolbarEditBoxButton::SetFlatMode (FALSE);
m_wndAddressBar.EnableNavigationButtons (ID_GOTO_BACK, ID_GOTO_FORWARD, ID_GOTO_HISTORY, ID_VIEW_HISTORY, 0);
if (!m_wndAddressBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndAddressBar.LoadToolBar (IDR_ADDRESS_BAR,
theApp.m_nColorMode >= 16 ? IDB_ADDRESS_BAR : 0, 0, 0,
theApp.m_nColorMode >= 16 ? IDB_ADDRESS_BAR_120 : 0))
{
TRACE0("Failed to create addressbar\n");
return -1; // fail to create
}
m_wndAddressBar.ReplaceButton (IDC_ADDRESS, CBCGPToolbarComboBoxButton (IDC_ADDRESS, -1, CBS_DROPDOWN));
m_wndAddressBar.SetStretchID (IDC_ADDRESS);
m_wndAddressBar.ReplaceButton (IDC_SEARCH, CBCGPToolbarEditBoxButton (IDC_SEARCH, -1));
CMenu menu;
VERIFY (menu.LoadMenu (IDR_SEARCH_POPUP));
CMenu* pMenuSearch = menu.GetSubMenu (0);
VERIFY (pMenuSearch != NULL);
m_wndAddressBar.ReplaceButton (ID_GOTO_SEARCH,
CBCGPToolbarMenuButton (ID_GOTO_SEARCH, pMenuSearch->GetSafeHmenu (), 4));
//--------------------
// Create the menubar:
//--------------------
if (!m_wndMenuBar.CreateEx (this, TBSTYLE_TRANSPARENT))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetBarStyle ((m_wndMenuBar.GetBarStyle() & ~(CBRS_GRIPPER | CBRS_BORDER_ANY)) | CBRS_SIZE_DYNAMIC);
m_wndMenuBar.EnableCustomizeButton (TRUE, (UINT)-1, _T(""));
//------------------
// Create links bar:
//------------------
if (!m_wndLinksBar.CreateEx (this, TBSTYLE_TRANSPARENT,
dwDefaultToolbarStyle, CRect(0, 0, 0, 0), AFX_IDW_DIALOGBAR + 1))
{
TRACE0("Failed to create linksbar\n");
}
CString strLinksLabel;
strLinksLabel.LoadString (IDS_LINKSBAR_NAME);
m_wndLinksBar.SetWindowText (strLinksLabel);
m_wndLinksBar.SetBarStyle (m_wndLinksBar.GetBarStyle() & ~(CBRS_GRIPPER | CBRS_BORDER_ANY));
m_wndLinksBar.EnableCustomizeButton (TRUE, (UINT)-1, _T(""));
//--------------
// Create rebar:
//--------------
m_wndReBar.LockBars ();
if (!m_wndReBar.Create(this) ||
!m_wndReBar.AddBar(&m_wndMenuBar, NULL, NULL,
RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK | RBBS_HIDDEN) ||
!m_wndReBar.AddBar(&m_wndLinksBar, strLinksLabel, NULL,
RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}
m_wndMenuBar.AdjustLayout ();
m_wndLinksBar.AdjustLayout ();
//---------------
// Create tabbar:
//---------------
//.........这里部分代码省略.........
示例4: OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
ModifyStyle (WS_CAPTION | FWS_ADDTOTITLE, 0);
ModifyStyleEx (WS_EX_CLIENTEDGE, 0);
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMSMVisualManager));
//---------------------------------
// Set toolbar and menu image size:
//---------------------------------
CMFCToolBarButton::m_bWrapText = FALSE;
CMFCToolBar::SetMenuSizes (CSize (22, 22), CSize (16, 16));
CMFCToolBarComboBoxButton::SetFlatMode ();
CMFCToolBarComboBoxButton::SetCenterVert ();
if (!m_wndCaptionBar.Create(this, IDR_MAINFRAME))
{
TRACE0("Failed to create captionbar\n");
return -1;
}
if (afxGlobalData.fontRegular.GetSafeHandle () != NULL)
{
LOGFONT lf;
ZeroMemory (&lf, sizeof (LOGFONT));
afxGlobalData.fontRegular.GetLogFont (&lf);
m_wndCaptionBar.SetCaptionFont (lf);
}
if (!m_wndMenuBar.Create (this, AFX_DEFAULT_TOOLBAR_STYLE))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
CClientDC dc (this);
m_bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 16;
UINT uiToolbarHotID = m_bIsHighColor ? IDB_HOTTOOLBAR : 0;
UINT uiToolbarColdID = m_bIsHighColor ? IDB_COLDTOOLBAR : 0;
UINT uiToolbarDisID = m_bIsHighColor ? IDB_DISABLEDTOOLBAR : 0;
UINT uiToolbarPresID = m_bIsHighColor ? IDB_PRESSEDTOOLBAR : 0;
UINT uiMenuID = m_bIsHighColor ? IDB_MENU_IMAGES : IDB_MENU_IMAGES_16;
if (!m_wndToolBar.CreateEx (this, TBSTYLE_FLAT,
CBRS_SIZE_FIXED | AFX_DEFAULT_TOOLBAR_STYLE) ||
!m_wndToolBar.LoadToolBar (IDR_MAINFRAME, uiToolbarColdID, uiMenuID,
FALSE /* Not locked */, uiToolbarDisID, 0, uiToolbarHotID, uiToolbarPresID))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndToolBar.InsertButton
(CMFCToolBarComboBoxButton (ID_GO_ADDRESS_EDIT, 0), 3);
DockPane (&m_wndToolBar);
if (!m_wndCategoryBar.CreateEx (this, TBSTYLE_FLAT,
CBRS_SIZE_FIXED | AFX_DEFAULT_TOOLBAR_STYLE,
CRect (1, 1, 1, 1), AFX_IDW_TOOLBAR + 3))
{
TRACE0("Failed to create categoriebar\n");
return -1; // fail to create
}
DockPane (&m_wndCategoryBar);
for (long i = 0; i < 8; i++)
{
if (!m_wndLinksBars[i].CreateEx (this, TBSTYLE_FLAT,
CBRS_SIZE_FIXED | AFX_DEFAULT_TOOLBAR_STYLE,
CRect (1, 1, 1, 1), AFX_IDW_TOOLBAR + 4 + i))
{
TRACE0("Failed to create linksbar\n");
return -1; // fail to create
}
DockPane (&m_wndLinksBars[i]);
ShowPane (&m_wndLinksBars[i], FALSE, FALSE, FALSE);
}
m_wndLinksBars[0].InsertButton (CMSMLinksBarButton (_T("My Money"), ID_LINKS_HOME_1));
m_wndLinksBars[0].InsertButton (CMSMLinksBarButton (_T("MSN Money News"), ID_LINKS_HOME_2));
m_wndLinksBars[0].SetCurrentCommand (ID_LINKS_HOME_1);
m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Account List"), ID_LINKS_BANKING_1));
m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Account Tools"), ID_LINKS_BANKING_2));
m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Mortgages && Loans"), ID_LINKS_BANKING_3));
m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Bank Services"), ID_LINKS_BANKING_4));
m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Credit Center"), ID_LINKS_BANKING_5));
//.........这里部分代码省略.........
示例5: Init
void CDIPDemoDoc::Init()
{
// 初始化
// 如果图像无效,直接返回
if ( !m_Image.IsValidate() )
{
return;
}
// 设置文档大小
m_sizeDoc = CSize ( m_Image.GetWidthPixel(),
m_Image.GetHeight() );
// 判断调色板是否为空
if ( m_pPalette != NULL )
{
// 删除调色板对象
delete m_pPalette;
// 重置调色板为空
m_pPalette = NULL;
}
//不是调色板显示模式,则直接返回
CClientDC dc ( NULL );
if ( ( dc.GetDeviceCaps ( RASTERCAPS ) &
RC_PALETTE ) == 0 )
{
return;
}
// 创建新调色板
m_pPalette = new CPalette;
int nEntries = m_Image.GetColorTableEntriesNum();
if ( nEntries == 0 )
{
return;
}
LOGPALETTE* lpPal = ( LOGPALETTE* ) new
BYTE[sizeof ( LOGPALETTE ) + ( sizeof (
PALETTEENTRY ) * ( nEntries - 1 ) )];
// 设置版本号
lpPal->palVersion = 0x300;
// 设置颜色数目
lpPal->palNumEntries = ( WORD ) nEntries;
RGBQUAD* pPal = ( RGBQUAD* ) (
m_Image.GetColorTable() );
int i;
// 创建调色板
for ( i = 0; i < nEntries; i++ )
{
// 读取红色分量
lpPal->palPalEntry[i].peRed = pPal[i].rgbRed;
// 读取绿色分量
lpPal->palPalEntry[i].peGreen = pPal[i].rgbGreen;
// 读取蓝色分量
lpPal->palPalEntry[i].peBlue = pPal[i].rgbBlue;
// 保留位
lpPal->palPalEntry[i].peFlags = 0;
}
// 按照逻辑调色板创建调色板,并返回指针
m_pPalette->CreatePalette ( lpPal );
delete[] lpPal;
}
示例6: OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
TRACE("CMainFrame::OnCreate");
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
OnAppLook (m_nAppLook);
CMFCToolBar::EnableQuickCustomization ();
UpdateMDITabs (FALSE);
if (!m_wndMenuBar.Create (this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC);
// Prevent the menu bar from taking the focus on activation
CMFCPopupMenu::SetForceMenuFocus(FALSE);
// Detect color depth. 256 color toolbars can be used in the
// high or true color modes only (bits per pixel is > 8):
CClientDC dc (this);
BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;
UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBarTheme.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_THEME_TOOLBAR) ||
!m_wndToolBarTheme.LoadToolBar (IDR_THEME, 0, 0, TRUE /* Locked */))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
CImageList imagesWorkspace;
imagesWorkspace.Create (IDB_WORKSPACE, 16, 0, RGB (255, 0, 255));
if (!m_wndWorkSpace.Create (_T("MDI Tabs Options"), this, CRect (0, 0, 300, 300),
TRUE, ID_VIEW_WORKSPACE,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Workspace bar\n");
return FALSE; // fail to create
}
m_wndWorkSpace.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE);
if (!m_wndWorkSpace2.Create (_T("My Second Tab Options"), this, CRect (0, 0, 300, 300),
TRUE, ID_VIEW_WORKSPACE2,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create Workspace bar\n");
return FALSE; // fail to create
}
m_wndWorkSpace2.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE);
m_wndToolBar.SetWindowText (_T("Standard"));
m_wndToolBarTheme.SetWindowText (_T("Visual Style"));
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarTheme.EnableDocking(CBRS_ALIGN_ANY);
m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY);
m_wndWorkSpace2.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
EnableAutoHidePanes(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&m_wndToolBar);
DockPane(&m_wndToolBarTheme);
DockPane (&m_wndWorkSpace);
DockPane (&m_wndWorkSpace2);
m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
m_wndToolBarTheme.EnableCustomizeButton (TRUE, -1, _T(""));
// Enable windows manager:
EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE);
//.........这里部分代码省略.........
示例7: OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CBCGPMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (CBCGPToolBar::GetUserImages () == NULL)
{
// Load toolbar user images:
if (!m_UserImages.Load (_T(".\\UserImages.bmp")))
{
TRACE(_T("Failed to load user images\n"));
}
else
{
CBCGPToolBar::SetUserImages (&m_UserImages);
}
}
CBCGPToolBar::EnableQuickCustomization ();
// TODO: Define your own basic commands. Be sure, that each pulldown
// menu have at least one basic command.
CList<UINT, UINT> lstBasicCommands;
// lstBasicCommands.AddTail (ID_VIEW_TOOLBARS);
// lstBasicCommands.AddTail (ID_FILE_NEW);
// lstBasicCommands.AddTail (ID_FILE_OPEN);
// lstBasicCommands.AddTail (ID_FILE_SAVE);
// lstBasicCommands.AddTail (ID_FILE_PRINT);
lstBasicCommands.AddTail (ID_APP_EXIT);
// lstBasicCommands.AddTail (ID_EDIT_CUT);
// lstBasicCommands.AddTail (ID_EDIT_PASTE);
// lstBasicCommands.AddTail (ID_EDIT_UNDO);
// lstBasicCommands.AddTail (ID_RECORD_NEXT);
// lstBasicCommands.AddTail (ID_RECORD_LAST);
lstBasicCommands.AddTail (ID_APP_ABOUT);
lstBasicCommands.AddTail (ID_VIEW_TOOLBAR);
lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE);
lstBasicCommands.AddTail (ID_WINDOW_TILE_HORZ);
// lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000);
// lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP);
// lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003);
// lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007);
// lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP);
// lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1);
// lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2);
// lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3);
// lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2008);
CBCGPToolBar::SetBasicCommands (lstBasicCommands);
if (!m_wndMenuBar.Create (this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_SIZE_DYNAMIC);
// Detect color depth. 256 color toolbars can be used in the
// high or true color modes only (bits per pixel is > 8):
CClientDC dc (this);
BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;
UINT uiToolbarHotID = bIsHighColor ;
// if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
// | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
// !m_wndToolBar.LoadToolBar(IDR_MAINFRAME_256, 0, 0, FALSE, 0, 0, uiToolbarHotID))
// {
// TRACE0("Failed to create toolbar\n");
// return -1; // fail to create
// }
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
{
TRACE0("未能创建工具栏\n");
return -1; // 未能创建
}
CString strToolBarName;
BOOL bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
ASSERT(bNameValid);
m_wndToolBar.SetWindowText(strToolBarName);
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// Load control bar icons:
CBCGPToolBarImages imagesWorkspace;
imagesWorkspace.SetImageSize (CSize (16, 16));
imagesWorkspace.SetTransparentColor (RGB (255, 0, 255));
imagesWorkspace.Load (IDB_WORKSPACE);
//.........这里部分代码省略.........
示例8: OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
OnAppLook (m_nAppLook);
CMFCToolBar::EnableQuickCustomization ();
// TODO: Define your own basic commands. Be sure, that each pulldown
// menu have at least one basic command.
CList<UINT, UINT> lstBasicCommands;
lstBasicCommands.AddTail (ID_VIEW_TOOLBARS);
lstBasicCommands.AddTail (ID_FILE_NEW);
lstBasicCommands.AddTail (ID_FILE_OPEN);
lstBasicCommands.AddTail (ID_FILE_SAVE);
lstBasicCommands.AddTail (ID_FILE_PRINT);
lstBasicCommands.AddTail (ID_APP_EXIT);
lstBasicCommands.AddTail (ID_EDIT_CUT);
lstBasicCommands.AddTail (ID_EDIT_PASTE);
lstBasicCommands.AddTail (ID_EDIT_UNDO);
lstBasicCommands.AddTail (ID_APP_ABOUT);
lstBasicCommands.AddTail (ID_VIEW_TOOLBAR);
lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_4);
CMFCToolBar::SetBasicCommands (lstBasicCommands);
if (!m_wndMenuBar.Create (this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC);
// Detect color depth. 256 color toolbars can be used in the
// high or true color modes only (bits per pixel is > 8):
CClientDC dc (this);
BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;
UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndToolBar.SetWindowText (_T("Standard"));
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
//------------------------------------------------------------------
// Outlook bar will be created at left, so temporary disable docking
// at the left side:
//------------------------------------------------------------------
EnableDocking (CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM | CBRS_ALIGN_RIGHT);
if (!CreateShortcutsBar ())
{
TRACE0("Failed to create shortcuts bar\n");
return -1; // fail to create
}
//----------------------------------------------------
// Outlook bar is created and docking on the left side
// should be allowed.
//----------------------------------------------------
EnableDocking (CBRS_ALIGN_LEFT);
if (!m_wndCaptionBar.Create (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, this,
ID_VIEW_CAPTIONBAR, -1))
{
TRACE0("Failed to create caption bar\n");
return -1; // fail to create
}
m_wndCaptionBar.SetFlatBorder ();
//.........这里部分代码省略.........
示例9: OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
OnAppLook (m_nAppLook);
CMFCToolBar::EnableQuickCustomization ();
// TODO: Define your own basic commands. Be sure, that each pulldown
// menu have at least one basic command.
CList<UINT, UINT> lstBasicCommands;
lstBasicCommands.AddTail (ID_VIEW_TOOLBARS);
lstBasicCommands.AddTail (ID_FILE_NEW);
lstBasicCommands.AddTail (ID_FILE_OPEN);
lstBasicCommands.AddTail (ID_FILE_SAVE);
lstBasicCommands.AddTail (ID_FILE_PRINT);
lstBasicCommands.AddTail (ID_APP_EXIT);
lstBasicCommands.AddTail (ID_EDIT_CUT);
lstBasicCommands.AddTail (ID_EDIT_PASTE);
lstBasicCommands.AddTail (ID_EDIT_UNDO);
lstBasicCommands.AddTail (ID_APP_ABOUT);
lstBasicCommands.AddTail (ID_VIEW_TOOLBAR);
lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3);
lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_4);
CMFCToolBar::SetBasicCommands (lstBasicCommands);
if (!m_wndMenuBar.Create (this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC);
// Detect color depth. 256 color toolbars can be used in the
// high or true color modes only (bits per pixel is > 8):
CClientDC dc (this);
BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;
UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBarTheme.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_THEME_TOOLBAR) ||
!m_wndToolBarTheme.LoadToolBar (IDR_THEME, 0, 0, TRUE /* Locked */))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndToolBar.SetWindowText (_T("Standard"));
m_wndToolBarTheme.SetWindowText (_T("Visual Style"));
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarTheme.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&m_wndToolBar);
DockPane(&m_wndToolBarTheme);
m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
m_wndToolBarTheme.EnableCustomizeButton (TRUE, -1, _T(""), FALSE);
return 0;
}
示例10: OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// enable Windows XP look:
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows));
CMFCToolBar::EnableQuickCustomization ();
//---------------------------------
// Set toolbar and menu image size:
//---------------------------------
CMFCToolBar::SetSizes (CSize (28, 28), CSize (22, 22));
CMFCToolBar::SetMenuSizes (CSize (22, 22), CSize (16, 16));
// TODO: Define your own basic commands. Be sure, that each pulldown
// menu have at least one basic command.
CList<UINT, UINT> lstBasicCommands;
lstBasicCommands.AddTail (ID_VIEW_TOOLBARS);
lstBasicCommands.AddTail (ID_APP_EXIT);
lstBasicCommands.AddTail (ID_APP_ABOUT);
lstBasicCommands.AddTail (ID_VIEW_TOOLBAR);
lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE);
lstBasicCommands.AddTail (ID_COMMAND_HISTORY);
lstBasicCommands.AddTail (ID_VIEW_LARGEICON);
lstBasicCommands.AddTail (ID_VIEW_SMALLICON);
lstBasicCommands.AddTail (ID_VIEW_LIST);
lstBasicCommands.AddTail (ID_VIEW_DETAILS);
lstBasicCommands.AddTail (ID_EDIT_CUT);
lstBasicCommands.AddTail (ID_EDIT_COPY);
lstBasicCommands.AddTail (ID_EDIT_PASTE);
CMFCToolBar::SetBasicCommands (lstBasicCommands);
if (!m_wndMenuBar.Create (this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC);
// Remove menubar gripper and borders:
m_wndMenuBar.SetPaneStyle (m_wndMenuBar.GetPaneStyle() &
~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
// Detect color depth. 256 color toolbars can be used in the
// high or true color modes only (bits per pixel is > 8):
CClientDC dc (this);
BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;
UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0;
UINT uiToolbarColdID = bIsHighColor ? IDB_TOOLBARCOLD256 : 0;
UINT uiMenuID = bIsHighColor ? IDB_MENU256 : IDB_MENU16;
if (!m_wndToolBar.CreateEx(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME, uiToolbarColdID, uiMenuID, FALSE, 0, 0, uiToolbarHotID))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// Remove toolbar gripper and borders:
m_wndToolBar.SetPaneStyle (m_wndToolBar.GetPaneStyle() &
~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
//----------------------------------------
// Create a combo box for the address bar:
//----------------------------------------
if (!m_wndAddress.Create (CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR + 1))
{
TRACE0("Failed to create combobox\n");
return -1; // fail to create
}
// Each rebar pane will ocupy its own row:
DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK;
if (!m_wndReBar.Create(this) ||
!m_wndReBar.AddBar (&m_wndMenuBar) ||
!m_wndReBar.AddBar (&m_wndToolBar, NULL, NULL, dwStyle) ||
!m_wndReBar.AddBar(&m_wndAddress, _T("Address"), NULL, dwStyle))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}
m_wndMenuBar.AdjustLayout ();
m_wndToolBar.AdjustLayout ();
//--------------------------------------------------------------
// Set up min/max sizes and ideal sizes for pieces of the rebar:
//--------------------------------------------------------------
REBARBANDINFO rbbi;
CRect rectToolBar;
m_wndToolBar.GetItemRect(0, &rectToolBar);
//.........这里部分代码省略.........