可以供MFC调用的,QT实现的DLL(qtwinmigrate实现)


#include <qmfcapp.h>  

  • #include <qwinwidget.h>  
  • #include <QtGui>  
  •   
  • #include <QtGui/QMessageBox>  
  • #include <windows.h>  
  • #include <QTextCodec>  
[cpp]  view plain copy print ?
 
  1. #include "widget.h"  
  2.   
  3. BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/ )  
  4. {  
  5.     static bool ownApplication = FALSE;  
  6.     //加入本地语言支持  
  7.     QTextCodec::setCodecForTr(QTextCodec::codecForLocale());  
  8.     QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());  
  9.   
  10.     if ( dwReason == DLL_PROCESS_ATTACH )  
  11.     {  
  12.   
  13.         ownApplication = QMfcApp::pluginInstance( hInstance );  
  14.     }  
  15.     if ( dwReason == DLL_PROCESS_DETACH && ownApplication )  
  16.     {  
  17.         qApp->quit();  
  18.         delete qApp;  
  19.     }  
  20.   
  21.     return TRUE;  
  22. }  
  23.   
  24.   
  25. extern "C" __declspec(dllexport) int ShowDialog( HWND parent)  
  26. {  
  27.     QWinWidget win(parent, NULL, Qt::Window);  
  28.     win.showCentered();  
  29.     win.center();  
  30.   
  31.     QHBoxLayout hbox(&win);  
  32.     Widget *widget = new Widget(&win);  
  33.     widget->setWindowFlags(Qt::Window);  
  34.     hbox.addWidget(widget);  
  35.   
  36.     win.show();  
  37.     qApp->exec();  
  38. }  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM