【发布时间】:2014-06-18 18:55:20
【问题描述】:
我不知道这个话题的主题是否有意义。 我已经尝试过使用 CEF3 进行一些工作。 我刚开始使用 C++,我很难过。对此感到抱歉。
最初的目标是使弹出窗口全屏,如本主题所述:http://www.magpcss.org/ceforum/viewtopic.php?f=10&t=11706
我也认为这是一种更好的方法:http://magpcss.org/ceforum/viewtopic.php?f=6&t=10772。但是,没有足够的解释。 您认为需要在下面的 sn-p 中添加什么内容才能使浏览器在基于 WINAPI 的窗口中运行。
#include <windows.h>
// Source taken here: http://www.winprog.org/tutorial/simple_window.html
const char g_szClassName[] = "MultiscreenProject";
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
//Full-screen mode
RECT desktop;
// Get a handle to the desktop window
const HWND hDesktop = GetDesktopWindow();
// Get the size of screen to the variable desktop
GetWindowRect(hDesktop, &desktop);
// The top left corner will have coordinates (0,0)
// and the bottom right corner will have coordinates
// (horizontal, vertical)
int horizontal = desktop.right;
int vertical = desktop.bottom;
//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if( !RegisterClassEx(&wc) ) {
MessageBox( NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK );
return 0;
}
hwnd = CreateWindowEx(
0,
g_szClassName,
"Multiscreen Project",
WS_POPUP,
CW_USEDEFAULT, CW_USEDEFAULT, horizontal, vertical,
NULL, NULL, hInstance, NULL
);
if( hwnd == NULL ){
MessageBox( NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK );
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Step 3: The Message Loop
while( GetMessage(&Msg, NULL, 0, 0) > 0 ) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
非常感谢。
【问题讨论】:
-
这个问题我看了好几遍了,还是不明白问题出在哪里。您想了解您发布的代码是如何工作的吗?或者您确实希望有人帮助您修复代码?如果是后者,代码具体有什么问题?它在做什么,而您想要它做什么?
-
我正在寻求有关如何将 CEF3 与 WINAPI 绑定的建议。如果可能的话,Chromium 浏览器会以这种方式在 WINAPI 的窗口上运行。
-
您检查过 CefClient/CefSimple 项目吗?也许我理解错了,但他们不是使用 WINAPI 从本机 Win32 应用程序运行 Cef 吗?
-
@CodyGray 我可以得到你的许可,将它作为一种“标准操作程序”复制粘贴到 SO 上吗? :)
-
@Sharadh 当然。你可能也喜欢this extension :-)
标签: winapi window chromium-embedded