第四章Officeスタイルツールバーとメニューの作成方法
第四章Xtreme Toolkit Pro v 13.2使用マニュアル
Up | Previous | Next
Officeスタイルツールバーとメニューの作成方法
次のガイドは、Visual Studio 6.0アプリケーションウィザードを使用してOfficeメニューとツールバースタイルのMDIアプリケーションを作成する方法です.このテクニックは、バージョンを更新するVisual Studioにも適用されます.NET .
MFC AppWizardを使用して簡単なMDIアプリケーションを作成する: Visual StudioからFile|Newを選択し、Projectsタグを選択する. MFC Appwizard(exe)をプロジェクトカテゴリとして選択する、「MDISample」をプロジェクト名として入力.
Visual Studio新規ダイアログ...
の最初のステップは、Multiple documentsが選択することを確認し、「Finish」ボタンを押す.
Xtremeコマンドツールバーコンポーネントを追加するには、次の手順に従います.次のコードを
Xtreme Toolkit Pro:
は
次のコードを
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
テキスト
Chapter 4: Tutorials for Using Xtreme Toolkit Pro v13.2
Up | Previous | Next
The following is a tutorial on how to create an MDI application using the Visual Studio 6.0 Application Wizard that will have Office style menus and toolbars. The same technique can be used for later versions of Visual Studio .NET as well.
Create a simple MDI application using the MFC AppWizard: From Visual Studio and select File thenNew and select theProjects tab. Choose MFC Appwizard(exe) as your project type and enter ‘MDISample’ as the project name.
Visual Studio New Dialog...
For the first step, make sure that Multiple documents is selected then press the ‘Finish’ button.
Add Xtreme Command Bars components: Add the following line to your
Xtreme Toolkit Pro:
In your
If you plan to override either
Add the following code to the
Now we have an MDI application with an Offiice 2003 interface...it’s that Easy!
MDI Sample Application...
Up | Previous | Next
Officeスタイルツールバーとメニューの作成方法
次のガイドは、Visual Studio 6.0アプリケーションウィザードを使用してOfficeメニューとツールバースタイルのMDIアプリケーションを作成する方法です.このテクニックは、バージョンを更新するVisual Studioにも適用されます.NET .
MFC AppWizardを使用して簡単なMDIアプリケーションを作成する:
Visual Studio新規ダイアログ...
Xtremeコマンドツールバーコンポーネントを追加するには、次の手順に従います.
StdAfx.h
ファイルに追加します.Xtreme Toolkit Pro:
#include // Xtreme Toolkit Pro component library
MainFrm.h
ファイル、MDIアプリケーションに対してCXTPMDIFrameWnd
ベースクラスを変更し、SDIアプリケーションに対してCXTPFrameWnd
ベースクラスを変更します.class CMainFrame : public CXTPMDIFrameWnd
{
...
};
PreTranslateMessage
またはOnWndMsg
を上書きする場合は、CXTPFrameWnd
またはCXTPMDIFrameWnd
のベースクラスを呼び出します.たとえば、次のようにします.//ダミー関数BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CXTPMDIFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; }
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { // TODO: Add your specialized code here and/or call the base class return CXTPMDIFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
関数に追加します.int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; 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)) { TRACE0("Failed to create toolbar
"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar
"); return -1; // fail to create } // 3 // TODO: Delete these three lines if you don't want the toolbar to be dockable // m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); // EnableDocking(CBRS_ALIGN_ANY); // DockControlBar(&m_wndToolBar); // // if (!InitCommandBars()) return -1; // . CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) { TRACE0("Failed to create command bars object.
"); return -1; // fail to create } // CXTPCommandBar* pMenuBar = pCommandBars->SetMenu( _T("Menu Bar"), IDR_MDISAMTYPE); if(pMenuBar == NULL) { TRACE0("Failed to create menu bar.
"); return -1; // fail to create } // CXTPToolBar* pToolBar = (CXTPToolBar*) pCommandBars->Add(_T("Standard"), xtpBarTop); if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar
"); return -1; } // Office 2003 CXTPPaintManager::SetTheme(xtpThemeOffice2003); return 0; }
Office 2003インタフェースを持つMDIアプリケーションがあります.こんなに簡単です!
MDIサンプルプログラム...
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
テキスト
Chapter 4: Tutorials for Using Xtreme Toolkit Pro v13.2
Up | Previous | Next
The following is a tutorial on how to create an MDI application using the Visual Studio 6.0 Application Wizard that will have Office style menus and toolbars. The same technique can be used for later versions of Visual Studio .NET as well.
Create a simple MDI application using the MFC AppWizard:
Visual Studio New Dialog...
Add Xtreme Command Bars components:
StdAfx.h
file: Xtreme Toolkit Pro:
#include // Xtreme Toolkit Pro component library
MainFrm.h
file you need to change your base class to be CXTPMDIFrameWnd
for MDI applications or CXTPFrameWnd
for SDI applications: class CMainFrame : public CXTPMDIFrameWnd
{
...
};
PreTranslateMessage
or OnWndMsg
make sure that you call the CXTPFrameWnd
or CXTPMDIFrameWnd
base class, for example: BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
return CXTPMDIFrameWnd::PreTranslateMessage(pMsg);
}
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode,
void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// TODO: Add your specialized code here and/or call the base class
return CXTPMDIFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
function: int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// Create Status bar.
// Important: All control bars including the Status Bar
// must be created before CommandBars....
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar
");
return -1; // fail to create
}
// Initialize the command bars
if (!InitCommandBars())
return -1;
// Get a pointer to the command bars object.
CXTPCommandBars* pCommandBars = GetCommandBars();
if(pCommandBars == NULL)
{
TRACE0("Failed to create command bars object.
");
return -1; // fail to create
}
// Add the menu bar
CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
_T("Menu Bar"), IDR_MDISAMTYPE);
if(pMenuBar == NULL)
{
TRACE0("Failed to create menu bar.
");
return -1; // fail to create
}
// Create ToolBar
CXTPToolBar* pToolBar = (CXTPToolBar*)
pCommandBars->Add(_T("Standard"), xtpBarTop);
if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar
");
return -1;
}
// Set Office 2003 Theme
CXTPPaintManager::SetTheme(xtpThemeOffice2003);
return 0;
}
Now we have an MDI application with an Offiice 2003 interface...it’s that Easy!
MDI Sample Application...