Reputation: 223
I am developing an application on C++ using raw WinAPI, that uses CEF 3 for showing UI. The problem is that this UI is nested in a popup window (with no title bar and Close/Minimize buttons). So I want to make some client area to act like a caption, that user can drag and move window.
The easiest solution is subclassing CEF windows and "preprocessing" WM_NCHITTEST message, passing it to parent window (returning HTTRANSPARENT), and in parent window manage window-moving messages (return HTCAPTION on WM_NCHITTEST, do some stuff on WM_MOVE, WM_PAINT and other messages). This works if I manually do CEF message loop calling CefDoMessageLoopWork, but this takes all CPU resources.
Using multithreaded CEF message loop would be a solution, but this technique doesn't work.
So, the question is: how can I make clien area act like a caption using multithreaded CEF message loop as it uses a lot less resources?
Upvotes: 1
Views: 1894
Reputation: 223
Managed to resolve my problem. Initial message loop was something like this
if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
GetMessage( &msg, NULL, 0, 0 );
TranlateMessage( &msg );
DispatchMessage( &msg );
}
else
{
CefDoMessageLoopWork();
}
however it seems to be ok to call CefDoMessageLoopWork() just before main message processing, something like this:
if(GetMessage(&msg, NULL, 0, 0) > 0)
{
CefDoMessageLoopWork();
TranslateMessage(&msg);
DispatchMessage(&msg);
}
In this case CPU usage is OK;
Upvotes: 1