博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MFC和Qt分别使用Qt生成的Dll。
阅读量:4045 次
发布时间:2019-05-24

本文共 2524 字,大约阅读时间需要 8 分钟。

MFC和Qt分别使用Qt生成的Dll。

1、2017年8月3日17:56:33。

#ifndef QTDLGDLL#define QTDLGDLL#ifdef QTDLGDLL_LIBRARY//#include 
//# define QTDLGDLL_API Q_DECL_EXPORT#define QTDLGDLL_API __declspec(dllexport)#else#define QTDLGDLL_API __declspec(dllimport)#endif#define WIND_TYPE_NO 0#define WIND_TYPE_QT 1#define WIND_TYPE_WINDOWS 2typedef unsigned __int64 paduint64; /* 64 bit unsigned */typedef struct CPadSolderSpec { //面积. paduint64 m_uArea; //高度. unsigned long m_uHeight;} CPadSolderSpec;//struct CPadSolderSpec;#ifdef __cplusplusextern "C" {#endif QTDLGDLL_API int __cdecl OpenPadSettingDialogByMFC(void * ParentWind, CPadSolderSpec * pSpec); QTDLGDLL_API int __cdecl OpenPadSettingDialogByQt(void * ParentWind,CPadSolderSpec * pSpec);#ifdef __cplusplus}#endif#endif

#include "QtDlgDll.h"#include "PadSettingDialog.h"#include 
#include
#include
bool g_bRun = false;int OpenPadSettingDialogByMFC(void * ParentWind, CPadSolderSpec * pSpec){ if (g_bRun) { return 0; } g_bRun = true; if (NULL == ParentWind) { return 0; } HWND hParentWnd = (HWND)ParentWind; HWND hSaveParentWnd = hParentWnd; Qt::HANDLE ThreadIdBefore = QThread::currentThreadId(); int argc = 0; char *argv[1] = {NULL}; QApplication a(argc, argv); Qt::HANDLE ThreadIdAfter = QThread::currentThreadId(); //模态对话框. CPadSettingDialog aDlg(NULL, pSpec); aDlg.setModal(true); //disable掉父窗口 hParentWnd = hSaveParentWnd; while (hParentWnd != NULL) { EnableWindow(hParentWnd, FALSE); hParentWnd = GetParent(hParentWnd); } aDlg.show(); a.exec(); //aDlg.exec(); //恢复父窗口的enable状态 hParentWnd = hSaveParentWnd; while (hParentWnd != NULL) { EnableWindow(hParentWnd, TRUE); hParentWnd = GetParent(hParentWnd); } g_bRun = false; return 1;}int OpenPadSettingDialogByQt(void * ParentWind, CPadSolderSpec * pSpec){ QWidget *parent = (QWidget *)ParentWind; //模态对话框. CPadSettingDialog aDlg(parent, pSpec); aDlg.exec(); return 1;}
MFC:

CPadSolderSpec aSpec;void CtestMFCDlg::OnBnClickedOk(){	DWORD id1 = ::GetCurrentThreadId();	_TCHAR sId1[100];	_i64tot_s(id1, sId1,100,16);	this->MessageBox(sId1, sId1, MB_ICONINFORMATION);	OpenPadSettingDialogByMFC(m_hWnd,&aSpec);	DWORD id2 = ::GetCurrentThreadId();	_TCHAR sId2[100];	_i64tot_s(id2, sId2, 100, 16);	this->MessageBox(sId2, sId2, MB_ICONINFORMATION);	int a = 1;	a++;	// TODO: 在此添加控件通知处理程序代码	//CDialogEx::OnOK();}
Qt:

CPadSolderSpec aSpec;void MainWindow::on_pushButton3_clicked(){	OpenPadSettingDialogByQt(NULL,&aSpec);	//OpenPadSettingDialogByQt(this, &aSpec);	return;

转载地址:http://dswci.baihongyu.com/

你可能感兴趣的文章
VUE-Vue.js之$refs,父组件访问、修改子组件中 的数据
查看>>
Vue-子组件改变父级组件的信息
查看>>
Python自动化之pytest常用插件
查看>>
Python自动化之pytest框架使用详解
查看>>
【正则表达式】以个人的理解帮助大家认识正则表达式
查看>>
性能调优之iostat命令详解
查看>>
性能调优之iftop命令详解
查看>>
非关系型数据库(nosql)介绍
查看>>
移动端自动化测试-Windows-Android-Appium环境搭建
查看>>
Xpath使用方法
查看>>
移动端自动化测试-Mac-IOS-Appium环境搭建
查看>>
Selenium之前世今生
查看>>
Selenium-WebDriverApi接口详解
查看>>
Selenium-ActionChains Api接口详解
查看>>
Selenium-Switch与SelectApi接口详解
查看>>
Selenium-Css Selector使用方法
查看>>
Linux常用统计命令之wc
查看>>
测试必会之 Linux 三剑客之 sed
查看>>
Socket请求XML客户端程序
查看>>
Java中数字转大写货币(支持到千亿)
查看>>