// // Created by HW on 2023/07/27. // // You may need to build the project (run Qt uic code generator) to get "ui_MainScreen.h" resolved #include "mainscreen.h" #include "ui_MainScreen.h" #include "netio.h" #include #include MainScreen::MainScreen(QWidget *parent) : QWidget(parent), ui(new Ui::MainScreen) { ui->setupUi(this); layout = nullptr; layout_left = nullptr; broswer = nullptr; } MainScreen::~MainScreen() { delete ui; } void MainScreen::clickButton1(QString text, QString url) { LRESULT *result=new LRESULT; try { mbFireWindowsMessage(mbView, mbGetHostHWND(mbView), WM_DESTROY, 0, 0, result); delete result; } catch(std::exception e){ delete result; } if (text == "΢ÐŶ࿪") { if (layout == nullptr) { layout = new QHBoxLayout; button = new QPushButton; button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#FFFFFF"); //Plus Math icon by Icons8 QString dir = QApplication::applicationDirPath(); icon = new QIcon(dir + "/images/add.png"); button->setIcon(*icon); connect(button, &QPushButton::click, this, &MainScreen::startWeChat); layout->addWidget(button, 1); if (broswer == nullptr) { broswer = new QWidget; } layout->addWidget(broswer,4); this->setLayout(layout); mbView = mbCreateWebWindow(MB_WINDOW_TYPE_CONTROL, (HWND)broswer->winId(), 0, 0, broswer->width(), broswer->height()); mbShowWindow(mbView, TRUE); mbLoadURL(mbView, url.toStdString().c_str()); mbRunMessageLoop(); mbUninit(); } else { mbView = mbCreateWebWindow(MB_WINDOW_TYPE_CONTROL, (HWND)broswer->winId(), 0, 0, broswer->width(), broswer->height()); mbShowWindow(mbView, TRUE); mbLoadURL(mbView, url.toStdString().c_str()); mbRunMessageLoop(); mbUninit(); } } else { if (broswer == nullptr) { broswer = new QWidget; } setLayout(nullptr); broswer->setGeometry(0, 0, width(), height()); mbView = mbCreateWebWindow(MB_WINDOW_TYPE_CONTROL, (HWND)broswer->winId(), 0, 0, broswer->width(), broswer->height()); mbShowWindow(mbView, TRUE); mbLoadURL(mbView, url.toStdString().c_str()); mbRunMessageLoop(); mbUninit(); } } void MainScreen::startWeChat() { ShellExecute(GetDesktopWindow(), L"open", L"wxdk.exe", L"", QApplication::applicationDirPath().toStdWString().c_str(), SW_SHOW); }