Re: qt4 and today screen problem: solved!
"pedrompalves" <[email protected]> Fri, 09 Sep 2005 13:23:18 -0000
| Newsgroups | gmane.comp.windows.ce.freeware |
|---|---|
| Message-ID | <[email protected]> |
I found a workaround that seems to solve the problem for all the cases
I could find.
I feel that the hack could be reduced even more, but I am happy enough
with it now. Maybe someone can give any hints on that.
> The window in question is a parentless window,
> with style set to WS_VISIBLE (0x80000000) and EX_STYLE to 0.
>
> I read somewhere about a today screen problem if your window is
> parentless and has WS_POPUP style it will always show above the
today
> screen.
> Could this be related?
I guess it was :)
I was setting the style to WS_VISIBLE (0x80000000) and EX_STYLE to 0,
AFTER the creation. My hunch is that the today screen bug trigger when
the today screen is the _OWNER_ window. So the WS_POPUP style must be
removed at creation time of the window.
Here is the workaround:
When I create the window, if is is parentless and is going to have
WS_POPUP style set, I remove it, and set it after creation.
After that, I call SetWindowLong set the correct style.
The I stumble something unexpected. In this case the style is not
updated until the window is activated a second time. I tried sending a
WM_NCACTIVATE/FALSE, to force it to be updated, and it worked, but
invalidates the workaround/triggers the original bug. So, no can do.
The solution I am using now, is when I am going to show the window,
if it is parentless, show it, show another window on top, and
immediatly closed this new window. This has the effect of triggering a
WM_ACTIVATE cycle, that correctly updates the style and gets rid of
the today screen bug! Hurray! I am so happy.
This way is better than just hiding the window and showing it again,
cause that introduces visible flicker.
creation: --------------------
...
int prevstyle = style;
if (!parentw)
style &= ~WS_POPUP;
const WCHAR *cname = (const WCHAR *)windowClassName.utf16();
id = CreateWindowEx(exsty, cname, ttitle, style, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parentw, 0, appinst, 0);
if (style != prevstyle)
{
SetWindowLong( id, GWL_STYLE, prevstyle );
UpdateWindow(id);
}
...
showing: --------------------
...
ShowWindow(q->winId(), sm);
if (!parentw)
{
// second part of create_sys hack for parentless WS_POPUP windows
// setting style after creating window only takes effect without
// the today screen problem after a WM_ACTIVATE false,
// followed by a WM_ACTIVATE true
static HWND id = 0;
extern bool qt_ignore_sys_events;
qt_ignore_sys_events = true;
if (!id)
{
HINSTANCE appinst = qWinAppInst();
WNDCLASS wc = {0};
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = appinst;
wc.lpszClassName= L"QT_HACK_WINDOW";
RegisterClass(&wc);
id = CreateWindowEx(
0, wc.lpszClassName, 0,
WS_VISIBLE | WS_EX_TOOLWINDOW, 0, 0, 0, 0,
NULL, 0, appinst, 0);
if (!id)
qDebug("hack window creation failed");
}
SetForegroundWindow(id);
ShowWindow(id, SW_HIDE);
qt_ignore_sys_events = false;
}
SetForegroundWindow(q->winId());
UpdateWindow(q->winId());
...
P.S.
If you read to this point it means my mails are still not long enough
to be boring, or are they? :)
Pedro Alves
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/W4wwlB/TM
--------------------------------------------------------------------~->