其他分享
首页 > 其他分享> > CAD ObjectARX二次开发之MFC对话框调用

CAD ObjectARX二次开发之MFC对话框调用

作者:互联网

一、创建工程

参考步骤:https://www.cnblogs.com/chenshuangjian/p/16450346.html

注意:创建工程是注意勾选MFC support。

image

二、添加MFC对话框资源

1、鼠标右击,添加资源

image

2、创建Dialog界面

image

image

3、从工具箱拖拽控件到界面

image

4、课在资源视图中查看窗体资源

image

三、引用资源

1、鼠标右键,添加类,选择MFC Support Class Wizard

image

2、填写类型,选择继承基类,上一步骤添加的窗体资源ID

image

四、编码调用窗体

1、添加窗体类头文件,编写窗体调用代码

// (C) Copyright 2002-2007 by Autodesk, Inc. 
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted, 
// provided that the above copyright notice appears in all copies and 
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting 
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to 
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//

//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
#include "ArxMFCDialog.h"

//-----------------------------------------------------------------------------
#define szRDS _RXST("Arx")

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CDemo_LoadMFCDialogApp : public AcRxArxApp {

public:
	CDemo_LoadMFCDialogApp () : AcRxArxApp () {}

	virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
		// TODO: Load dependencies here

		// You *must* call On_kInitAppMsg here
		AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
		
		// TODO: Add your initialization code here

		return (retCode) ;
	}

	virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
		// TODO: Add your code here

		// You *must* call On_kUnloadAppMsg here
		AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;

		// TODO: Unload dependencies here

		return (retCode) ;
	}

	virtual void RegisterServerComponents () {
	}


	// - ArxDemo_LoadMFCDialog._MyCommand1 command (do not rename)
	static void ArxDemo_LoadMFCDialog_MyCommand1(void)
	{
		// Add your code for command ArxDemo_LoadMFCDialog._MyCommand1 here
		//必须添加,防止资源调用冲突
		CAcModuleResourceOverride resOverrid;
		//自定义MFC界面
		ArxMFCDialog dialog;
		//以模态方式加载
		if(dialog.DoModal() == IDOK){

		}
	}
} ;

//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CDemo_LoadMFCDialogApp)

ACED_ARXCOMMAND_ENTRY_AUTO(CDemo_LoadMFCDialogApp, ArxDemo_LoadMFCDialog, _MyCommand1, MyCommand1, ACRX_CMD_TRANSPARENT, NULL)

2、编译测试

image

标签:MyCommand1,MFC,对话框,void,here,窗体,二次开发,-------------------------------------------
来源: https://www.cnblogs.com/chenshuangjian/p/16450443.html