49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
|
#include "qminiblink.h"
|
||
|
#pragma comment (lib,"Comctl32.lib")
|
||
|
|
||
|
QMiniBlink::QMiniBlink(QWidget *broswer,QWidget *parent)
|
||
|
: QWidget(parent){
|
||
|
this->broswer = broswer;
|
||
|
//QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
|
||
|
//setSizePolicy(sizePolicy);
|
||
|
}
|
||
|
void QMiniBlink::init() {
|
||
|
ui.setupUi(this);
|
||
|
wkeInit();
|
||
|
wkeView = wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, (HWND)this->winId(), 0, 0, this->width(), this->height());
|
||
|
wkeSetNavigationToNewWindowEnable(wkeView, false);
|
||
|
wkeShowWindow(wkeView, TRUE);
|
||
|
SetParent(wkeGetWindowHandle(wkeView), (HWND)this->winId());
|
||
|
SetWindowSubclass((HWND)this->winId(), subClassProc, 0, (DWORD_PTR)this);
|
||
|
wkeRunMessageLoop();
|
||
|
}
|
||
|
QMiniBlink::~QMiniBlink(){}
|
||
|
void QMiniBlink::destroy() {
|
||
|
wkeDestroyWebView(wkeView);
|
||
|
}
|
||
|
|
||
|
void QMiniBlink::switchUrl(QString url) {
|
||
|
wkeLoadURL(wkeView, url.toStdString().c_str());
|
||
|
}
|
||
|
LRESULT CALLBACK QMiniBlink::subClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
||
|
{
|
||
|
QMiniBlink *obj = (QMiniBlink *)dwRefData;
|
||
|
if (obj == nullptr)
|
||
|
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||
|
switch (uMsg) {
|
||
|
case WM_SIZE:
|
||
|
obj->autojustWebViewSize();
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||
|
}
|
||
|
void QMiniBlink::autojustWebViewSize()
|
||
|
{
|
||
|
RECT rect;
|
||
|
GetWindowRect((HWND)this->winId(), &rect);
|
||
|
wkeMoveWindow(wkeView, 0, 0, rect.right - rect.left, rect.bottom - rect.top);
|
||
|
|
||
|
}
|