How to Create an Application that has Office Style
2007-07-25 15:25
363 查看
step 1:
#include <XTToolkitPro.h>
step 2:
change your base class to be CXTPMDIFrameWnd for MDI applications or CXTPFrameWnd for SDI applications:
class CMainFrame : public CXTPFrameWnd
{
...
};
step 3:
If you plan to override either PreTranslateMessage or OnWndMsg make sure that you call the CXTPFrameWnd or CXTPMDIFrameWnd base class, for example:
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
return CXTPFrameWnd::PreTranslateMessage(pMsg);
}
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode,void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
return CXTPFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
step 4:
Add the following code to the int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) function:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CXTPFrameWnd::OnCreate(lpCreateStruct) == -1)
{
return -1;
}
if (!m_wndStatusBar.Create(this) ||!m_wndStatusBar.SetIndicators(indicators,sizeof(indicators)/sizeo(UINT)))
{
TRACE0("Failed to create status bar/n");
return -1;
}
if (!InitCommandBars())
{
return -1;
}
CXTPCommandBars* pCommandBars = GetCommandBars();
if(pCommandBars == NULL)
{
TRACE0("Failed to create command bars object./n");
return -1;
}
CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);
if(pMenuBar == NULL)
{
TRACE0("Failed to create menu bar./n");
return -1;
}
CXTPToolBar* pToolBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"),xtpBarTop);
if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar/n");
return -1;
}
// Set Office 2003 Theme
CXTPPaintManager::SetTheme(xtpThemeOffice2003);
return 0;
}
#include <XTToolkitPro.h>
step 2:
change your base class to be CXTPMDIFrameWnd for MDI applications or CXTPFrameWnd for SDI applications:
class CMainFrame : public CXTPFrameWnd
{
...
};
step 3:
If you plan to override either PreTranslateMessage or OnWndMsg make sure that you call the CXTPFrameWnd or CXTPMDIFrameWnd base class, for example:
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
return CXTPFrameWnd::PreTranslateMessage(pMsg);
}
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode,void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
return CXTPFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
step 4:
Add the following code to the int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) function:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CXTPFrameWnd::OnCreate(lpCreateStruct) == -1)
{
return -1;
}
if (!m_wndStatusBar.Create(this) ||!m_wndStatusBar.SetIndicators(indicators,sizeof(indicators)/sizeo(UINT)))
{
TRACE0("Failed to create status bar/n");
return -1;
}
if (!InitCommandBars())
{
return -1;
}
CXTPCommandBars* pCommandBars = GetCommandBars();
if(pCommandBars == NULL)
{
TRACE0("Failed to create command bars object./n");
return -1;
}
CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);
if(pMenuBar == NULL)
{
TRACE0("Failed to create menu bar./n");
return -1;
}
CXTPToolBar* pToolBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"),xtpBarTop);
if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar/n");
return -1;
}
// Set Office 2003 Theme
CXTPPaintManager::SetTheme(xtpThemeOffice2003);
return 0;
}
相关文章推荐
- javascript - C++, Qt, QtWebKit: How to create an html rendering window so that your application would get callbacks from JS calls? - Stack Overflow
- How To Detect If an Application Has Stopped Responding
- How to get the MouseEvent coordinates for an element that has CSS3 Transform?
- How To Detect If an Application Has Stopped Responding
- How To Detect If an Application Has Stopped Responding
- How to get the MouseEvent coordinates for an element that has CSS3 Transform?
- How to get the MouseEvent coordinates for an element that has CSS3 Transform?
- How To Create an IE-Only Stylesheet
- How To Detect If an Application Has Stopped Responding
- How can I create an Android application in Android Studio that uses the Google Maps Api v2?
- How To Create an IE-Only Stylesheet
- How to create an EMF model from a Java application ?
- How do I apply a style to all buttons of an Android application
- How To Create an ASP.NET Application from Multiple Projects for Team Development
- How to write an application that supports the Fast User Switching feature by using Visual Basic .NET or Visual Basic
- How to Create an Report Style
- A requirement that almost every single application has is "I want to scale up an ImageView proportio
- How to restore an element that has been deleted in CCRC?
- How to create jigsaw puzzle from an image using javascript(拼图引擎)
- How to load a dll resource dialog box at an application Dialog box (怎么在一个应用程序对话框动态加载DLL里的资源对话框)