objectARX創建 PaletteSet 停靠面板示例


 objectARX創建 PaletteSet 停靠面板示例

圖文By edata ,轉載注明出處 http://www.cnblogs.com/edata

部分代碼參考張帆《AutoCAD ObjectARX(VC)開發基礎與實例教程》

 

 

 

 

 以下是源碼部分

//001.修改msxml為msxml6
//- Import the MSXML functionality
#import "msxml6.dll" named_guids
//using namespace MSXML ;
//002.#define MSXML 為 MSXML2
#define MSXML MSXML2

  

//-----------------------------------------------------------------------------
//- Used to add a dialog resource
int CMyPalette1::OnCreate (LPCREATESTRUCT lpCreateStruct) {
	if ( CAdUiPalette::OnCreate (lpCreateStruct) == -1 )
		return (-1) ;
	//- Create it and set the parent as the dockctrl bar
	//003 資源覆蓋,顯示ClildDlg.ShowWindow
	CAcModuleResourceOverride myResource;
	mChildDlg.Create (IDD_MYPALETTE1, this) ;
	
	CRect rect ;
	GetWindowRect (&rect) ;
	//- Move the window over so we can see the control lines
	mChildDlg.ShowWindow(SW_SHOW);
	mChildDlg.MoveWindow (0, 0, rect.Width (), rect.Height (), TRUE) ;
	return (0) ;
}

  

//- Called by AutoCAD to steal focus from the palette
bool CMyPalette1::CanFrameworkTakeFocus () {
	//- Not simply calling IsFloating() (a BOOL) avoids warning C4800
	//return (GetPaletteSet ()->IsFloating () == TRUE ? true : false) ;
	//004 設置切換焦點 無論是否停靠均能正常切換焦點
	return true ;
}

  

//005.添加面板
#include "MyPaletteSet.h"
#include "MyPalette1.h"
#include "MyPalette2.h"

//-----------------------------------------------------------------------------

//006. 定義面板集全局變量
CMyPaletteSet *g_pPaletteSet=NULL;
CMyPalette1 *g_pPalette1=NULL;
CMyPalette2 *g_pPalette2=NULL;

  

//008. 銷毀選項板
		if (g_pPaletteSet != NULL)
		{					
			g_pPaletteSet->DestroyWindow();
			delete g_pPaletteSet;
			g_pPaletteSet = NULL;				
		}

  

//007 創建面板集
		if (!g_pPaletteSet)
		{
			// 創建palette set
			g_pPaletteSet = new CMyPaletteSet;
			CRect rect(0, 0, 90, 400);		// 初始大小
			g_pPaletteSet->Create(TEXT("自定義選項板"),
				WS_OVERLAPPED | WS_DLGFRAME, 
				rect, 
				acedGetAcadFrame(), 
				PSS_EDIT_NAME | 
				PSS_PROPERTIES_MENU | 
				PSS_AUTO_ROLLUP |
				PSS_CLOSE_BUTTON
				);
			// 選項板1
			g_pPalette1 = new CMyPalette1();  // 自定義的選項板
			g_pPalette1->Create(WS_CHILD | WS_VISIBLE, TEXT("選項板1"), g_pPaletteSet, PS_EDIT_NAME);			
			g_pPaletteSet->AddPalette(g_pPalette1);// 添加到選項板集合
			// 選項板2
			g_pPalette2 = new CMyPalette2();	// 自定義的選項板
			g_pPalette2->Create(WS_CHILD | WS_VISIBLE, TEXT("選項板2"), g_pPaletteSet, PS_EDIT_NAME);			
			g_pPaletteSet->AddPalette(g_pPalette2);
			// 顯示選項板集合
			g_pPaletteSet->EnableDocking(CBRS_ALIGN_ANY);			
			g_pPaletteSet->RestoreControlBar();
		}
		acedGetAcadFrame()->ShowControlBar(g_pPaletteSet, TRUE, FALSE);
		// 設置透明度
		if (g_pPaletteSet->GetOpacity() != 100)
		{
			g_pPaletteSet->SetOpacity(100);
		}
		//設置面板停靠后的最小寬度 ARX2012開始新增函數 
		AdUiSetDockBarMinWidth(90);

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM