直接上代码
jsValue functionCallBack(jsExecState es, jsValue object, jsValue* args, int argCount) {
jsData* jsData = jsGetData(es, object);
char* funName= jsData->typeName;
if (strcmp("enterFullScreen",funName)==0) {
HWND hDesk;
RECT rc;
hDesk = GetDesktopWindow();
GetWindowRect(GetDesktopWindow(), &rc);
HWND hwnd = wkeGetHostHWND(m_webview);
GetWindowRect(hwnd, &mainWindowRect);
SetWindowLong(hwnd, GWL_STYLE, WS_BORDER);
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, rc.right, rc.bottom, SWP_SHOWWINDOW);
}else if (strcmp("exitFullScreen", funName)==0) {
HWND hwnd = wkeGetHostHWND(m_webview);
SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
SetWindowPos(hwnd, HWND_NOTOPMOST, mainWindowRect.left, mainWindowRect.top, mainWindowRect.right - mainWindowRect.left, mainWindowRect.bottom - mainWindowRect.top, SWP_SHOWWINDOW);
}
else if (strcmp("quit",funName)==0) {
jsValue params = jsArg(es, 0);
wkeDestroyWebWindow(m_webview);
}
return jsUndefined();
}
jsValue buildFunction(jsExecState es,char * name) {
jsData * data = new jsData();
memcpy(data->typeName, name,strlen(name));
data->callAsFunction = functionCallBack;
jsValue func = jsFunction(es, data);
return func;
}
/处理全屏显示/
jsValue bindClient(jsExecState es, void* param)
{
jsValue client = jsEmptyObject(es);
jsSet(es, client, "version", jsString(es, "1.0.0"));
jsSet(es, client, "copyRight", jsString(es, "版权所有禁止任何个人破解和未授权使用"));
jsSet(es, client, "enterFullScreen", buildFunction(es, "enterFullScreen"));
jsSet(es, client, "exitFullScreen", buildFunction(es, "exitFullScreen"));
jsSet(es, client, "quit", buildFunction(es,"quit"));
jsSet(es, client, "open", buildFunction(es, "open"));
return client;
}
然后使用下列代码绑定到miniblink
wkeJsBindGetter("Client", bindClient, &m_webview);