Have you tried to add the style WS_EX_NOACTIVATE on creation ?
Prevent the window from stealing focus.
Hello
Maybe someone has solved a similar problem already.
I create a dialog box without a frame, assign the WS_EX_LAYERED style,
and move it over the main window within certain boundaries, and then destroy it.
The problem is that this transparent window steals focus from my main window and it looks bad.
I've used all the ways I know to lock the focus, but it only partially works.
Here is the sample code.
BOOL DialogTransparent::OnInitDialog()
{
CDialog::OnInitDialog();
CDialog::ModifyStyleEx(0, WS_EX_LAYERED | WS_EX_TRANSPARENT, SWP_FRAMECHANGED);
CDialog::SetLayeredWindowAttributes(0, 120, LWA_ALPHA);
return FALSE;// Return FALSE in the transparent window class when creating
}
//In the main window //
DialogTransparent m_transparent;
m_transparent.CreateIndirect(pBuffer);
m_transparent.SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
m_transparent.SendMessageW(WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);//there's a loss of focus
So I managed not to take focus away from the main window when creating a transparent window.
SetWindowPos also does not steal focus.
But after dragging the main window blinks.
How to prevent this.
2 answers
Sort by: Most helpful
-
-
Вадим Подгорный 41 Reputation points
2022-06-28T13:36:15.587+00:00 Castorix31 Can I see your window move code?