• 可以供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

  • 相关阅读:
    国内网页登录onedrive
    MySQL查询语法
    python 优矿自动化交易
    Python爬取代理ip
    Python获取中国证券报最新资讯
    python推荐淘宝物美价廉商品
    python PIL比较图片像素
    使用pyinstaller打包Python应用,生成EXE执行文件
    Python可视化----------matplotlib.pylot
    panda库------对数据进行操作---合并,转换,拼接
  • 原文地址:https://www.cnblogs.com/findumars/p/4851314.html
Copyright © 2020-2023  润新知