可以供MFC调用的,QT实现的DLL(qtwinmigrate实现)
#include <qmfcapp.h>
- #include <qwinwidget.h>
- #include <QtGui>
- #include <QtGui/QMessageBox>
- #include <windows.h>
- #include <QTextCodec>
- #include "widget.h"
- BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/ )
- {
- static bool ownApplication = FALSE;
- //加入本地语言支持
- QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
- QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
- if ( dwReason == DLL_PROCESS_ATTACH )
- {
- ownApplication = QMfcApp::pluginInstance( hInstance );
- }
- if ( dwReason == DLL_PROCESS_DETACH && ownApplication )
- {
- qApp->quit();
- delete qApp;
- }
- return TRUE;
- }
- extern "C" __declspec(dllexport) int ShowDialog( HWND parent)
- {
- QWinWidget win(parent, NULL, Qt::Window);
- win.showCentered();
- win.center();
- QHBoxLayout hbox(&win);
- Widget *widget = new Widget(&win);
- widget->setWindowFlags(Qt::Window);
- hbox.addWidget(widget);
- win.show();
- qApp->exec();
- }