zoukankan      html  css  js  c++  java
  • 可以供MFC调用的,QT实现的DLL(使用qt-solutions的qtwinmigrate实现)

    MFC和QT的消息循环机制不同,所以,要让QT写的DLL可以供MFC调用,要做一点特殊的处理

    1. #include <qmfcapp.h>  
    2. #include <qwinwidget.h>  
    3. #include <QtGui>  
    4.   
    5. #include <QtGui/QMessageBox>  
    6. #include <windows.h>  
    7. #include <QTextCodec>  
    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. }  

    http://blog.csdn.net/small_qch/article/details/6743803

    https://github.com/qtproject/qt-solutions/tree/master/qtwinmigrate

  • 相关阅读:
    快速创建jsp页面的方法
    Webstorm的一些常用快捷键
    eclipse 怎么在new菜单里添加JSP file选项?
    人生最重要的时候,从30岁到35岁:为生命多积累一些厚度
    android 生命周期四代码
    android WebView onJsAler onJsC…
    android java js 回调 真心好用
    linux下dlopen的使用
    android ndk jni 实例1
    android 退出程序 结束线程
  • 原文地址:https://www.cnblogs.com/findumars/p/4851314.html
Copyright © 2011-2022 走看看