Reputation: 1332
I have a WIN32 application. Its main window is hwndMain
, one of its child is hwndView
. There is one tab control hwndTab
on hwndView
.
When I resize hwndMain
, hwndView
is resized and so is hwndTab
. It flicker a little, but not much.
I have tried to use WS_EX_COMPOSITED
style ( for hwndView
or hwndTab
), but it just gave me blank window. I tried to use WS_EX_TRANSPARENT
and it solves flicker, but when the windows is resized to be larger, the childs are updated very slow, e.g I see black region for one second, then the region is updated.
I have successfully sloved the flicker issue for TreeView
by using WS_CHIPCHILDREN
style. (See remark below). But using WS_CHIPCHILDREN
stlye for hwndView
doesn't fix the flicker issue for tab control.
I have paid attention to WM_ERASEBKGND
and Not set hbrBackground
also.
I want to use double buffer for tab control, but I can't find a tutorial for this purpose. All the tutorial I found is: In WM_PAINT
, after creating CompatibleDC
and CompatibleBitmap
, draw what you want in memdc
and.....; But I don't want to do any custom drawing in WM_PAINT
for hwndTab
. I just want to leave the tab control do this job, but shows the final result only.
Could someone show me a small example how to double buffer a tab control (if you think this will fix the flicker issue of tab control), in the language c
+ winapi
, since I don't have the knowledge of C#, Net,..etc.
Remark: For my TreeView, it is a child of a window hwndContainer
. It is created as:
win->hwndContainer = CreateWindowEx(
WS_CLIPCHILDREN,
_T("SUMATRA_PDF_TOCBOX"), NULL,
WS_CHILD,
0, 0, gGlobalPrefs.sidebarDx, 0,
win->hwndPanel, NULL,
ghinst, NULL);
Using WS_CLIPCHILDREN
fix the flicker, even if I don't use double buffer. But it is strange to put
WS_CLIPCHILDREN
in the first parameter position. If I put it after WS_CHILD, i.e
win->hwndContainer = CreateWindowEx(
NULL,
_T("SUMATRA_PDF_TOCBOX"), NULL,
WS_CHILD | WS_CLIPCHILDREN,
0, 0, gGlobalPrefs.sidebarDx, 0,
win->hwndPanel, NULL,
ghinst, NULL);
,then the flicker still occurs.
So I also tried to use the first way when I created hwndView
, but it just gave blank white window.
I am really confused with these stuff.
Here is the blank window picture when I used WS_EX_COMPOSITED
for hwndView
.
There is no such problem when I used it for hwndContainer
.
hwndView
in fact has two child: a Tab Control hwndTab
and a child which has its own double buffer and drawing. I am not sure if this cause the problem for using WS_EX_COMPOSITED
.
Upvotes: 1
Views: 1017
Reputation: 244981
You are using the WS_EX_COMPOSITED
style. When you pass WS_CLIPCHIDREN
as the first argument to the CreateWindowEx
, it's interpreting the value of WS_CLIPCHILDREN
as an extended window style. Since the value of WS_CLIPCHILDREN
is 0x02000000L
, the same as WS_EX_COMPOSITED
, you've just created a composited window.
And a composited window, according to the documentation, has all of its descendants painted in a bottom-to-top painting order using double-buffering.
I'm not sure what you mean when you say:
I have tried to use WS_EX_COMPOSITED style ( for hwndView or hwndTab), but it just gave me blank window.
You'll have to post code the reproduces this problem. But your second-to-last code snippet is producing a composited window.
Upvotes: 2