小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

應用程序遷移至Xtreme Toolkit pro

 Frank_Chia 2009-07-26
 
應用程序遷移至Xtreme Toolkit pro
2009-01-19 15:49:43
 
專業(yè)版中的很多組件,比如toolbars,menubars和docking windows等與標準版有很大的
不同。這是因為新的架構(gòu)作了相當大的改變,提供了很多新的增強的特色。
本遷移向?qū)г噲D揭示這些異同以提供幫助,使你在遷移標準版的程序到專業(yè)版上時
更容易一些。

以下是這篇文章的所涉及的主題:
準備你的程序
開始
command bar的初始化
menubar的創(chuàng)建
toolbar的創(chuàng)建
dock window的創(chuàng)建
添加對toolbar和menu的定制
添加智能菜單
為應用程序添加一個theme

準備你的應用程序

首先你要做的是改變你的StdAfx.h文件中的include文件。這個文件常用來引進
所有的toolkit的類定義并把你的程序連接到toolkit。你需要打開你的StdAfx.h文件,
把#include <XTToolKit.h>改為#include <XTPToolkit.h>,例如:

#include <XTToolkitPro.h> // Xtreme Toolkit Pro components

重新命名你的基類
下來你需要改變一些基類。你得把所有出現(xiàn)的CXT…改為C…,比如在一個MDI程序中,
CXTMDIChildWnd要變成CMDIChildWnd,CXTMDIFrameWnd要變成CMDIFrameWnd。
對一個SDI程序,CXTFrameWnd要變成CFrameWnd。下面是一個所有需要改變?yōu)槠鸪醯?br>MFC命名慣例的類的列表。這是你的程序返
回到遷移時的一個好的起點。

Toolkit Class Name MFC Class Name (rename to)
CXTFrameWnd CFrameWnd
CXTMDIChildWnd CMDIChildWnd
CXTMDIFrameWnd CMDIFrameWnd
CXTOleIPFrameWnd COleIPFrameWnd
CXTControlBar CControlBar
CXTDialogBar CDialogBar
CXTReBar CReBar
CXTReBarCtrl CReBarCtrl

其他缺失的類

以下的類在Xtreme Toolkit的專業(yè)版中不再出現(xiàn)。在新的體系中,他們或是被代替或
是被廢棄。這些類中的大多數(shù)你不能再直接使用;但在這里把它們列出來作為你的參
考:

Toolkit Class Name
CXTAccelSwapOutItemList CXTCustOptions CXTPopupTearOffWnd
CXTAccelManager CXTCustomizeSheet CXTPopupColorTearOff
CXTCBarDialog CXTDockBar CXTPopupToolbarTearOff
CXTCommandsListBox CXTDockColorSelector CXTPreviewView
CXTItemData CXTDockContext CXTSplitterDock
CXTCoolMenu CXTDockWindow CXTSplitterRowDock
CXTMenu CXTFrameImpl CXTToolBar
CXTCustomToolBar CXTString CXTToolBarCtrl
CXTCustToolBarPage CXTMenuBarItem CXTPopupWndToolbar
CXTCustCommandsPage CXTMenuBar CXTToolBarPopupWndHook
CXTCustAccelerators CXTMiniDockFrameWnd CXTToolBarPopupWnd
CXTCustTools CXTNewToolbarDlg CXTToolsManager

開始

改變你的主框架的繼承關(guān)系
現(xiàn)在你的程序已經(jīng)不再涉及標準版本的東西了,我們可以開始遷移了?,F(xiàn)在你已經(jīng)
更新了你的StdAfx.h文件,在你的MainFrm.h文件中改變你的基類為CXTPMDIFrameWnd
(對MDI程序)和CXTPFrameWnd(對SDI程序):

class CMainFrame : public CXTPMDIFrameWnd
{
...
};
如果你重載了PreTranslateMessage請確保你調(diào)用了CXTPMDIFrameWnd基類,例如:
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class

return CXTPMDIFrameWnd::PreTranslateMessage(pMsg);
}
另外,如果你重載了OnCmdMsg請確保你調(diào)用了CXTPMDIFrameWnd基類,例如:

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);
}

Command bar的初始化

Command bar在使用之前必須進行初始化,而且它們必須在所有的control bar對象(
比如你的statusbar)創(chuàng)建之后再被創(chuàng)建。這是你為command bar設(shè)置theme的好地方。
在標準版中你需要調(diào)用xtAfxData.bXPMode = true;設(shè)置theme為Office XP。在專業(yè)版中
對每個組件你有theme
managers。這允許你定義你自己的theme或者選用toolkit中已定義的theme。

這是一個如何初始化controlbar的例子:
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\n");
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.\n");
return -1; // fail to create
}

// Set Office 2003 Theme
CXTPPaintManager::SetTheme(xtpThemeOfficeXP);

return 0;
}
使用coolmenu請注意:
在應用程序中不再有必要調(diào)用InstallCoolMenus初始化菜單的theme。
這由commandbar的theme manager來處理。

menubar的創(chuàng)建

你需要更改你的代碼使用pro版本的menubar。使用了標準版toolkit的程序參
考CMainFrame::OnCreate的CXTMenuBar對象。在這里m_wndMenuBar對象被創(chuàng)建,
允許??勘徽{(diào)用使menubar可以??吭诔绦虻墓ぷ鲄^(qū)。在專業(yè)版中做法有些不同,
沒必要調(diào)用允許??苛?,例如:
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\n");
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.\n");
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.\n");
return -1; // fail to create
}

// Remove the old menu bar code...
// if (!m_wndMenuBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
// | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
// !m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
// {
// TRACE0("Failed to create menubar\n");
// return -1; // fail to create
// }

// m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
// EnableDocking(CBRS_ALIGN_ANY);
// DockControlBar(&m_wndMenuBar);

return 0;
}

toolbar的創(chuàng)建

你需要更改你的代碼去使用pro版本的toolbar。相對于menubar,toolbar對象通常
在CMainFrame::OnCreate中創(chuàng)建,而且調(diào)用允許??渴箃oolbar??康匠绦虻墓ぷ鲄^(qū)。
Toolbar采用和menubar使用toolbar資源相似的創(chuàng)建方式,例如:

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\n");
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.\n");
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.\n");
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\n");
return -1;
}

// Remove the old tool bar code...
// 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\n");
// return -1; // fail to create
// }
// m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
// EnableDocking(CBRS_ALIGN_ANY);
// DockControlBar(&m_wndToolBar);

return 0;
}

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多