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

  

posted @ 2019-03-19 18:38  edata  阅读(2873)  评论(0编辑  收藏  举报