Common controls are not properly painted when I resize window

后端 未结 1 672
故里飘歌
故里飘歌 2021-01-18 06:52

INTRODUCTION:

I am creating tab control with child dialog boxes as pages.

I have Visual Styles enabled via #pragma comment. I ha

相关标签:
1条回答
  • 2021-01-18 07:22

    Your tab dialogs are below the tab control in the Z order. This causes crazy overdraw issues on first resizing. After adding the tab dialogs as childs to your main window, call SetWindowPos(tab, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE) to move them to the top of the Z order.

    Had this exact issue; took me days to figure it out. I created a simple application in Visual Studio:

    1. manifest reference to ComCtrl v 6
    2. InitCommonControlsEx()
    3. a dialog with a tab control
    4. a sub-dialog for the tab content (sibling to the tab)
    5. in the sub-dialog, a radio button and a static
    6. no fancy handling of WM_PRINTCLIENT or anything alike
    7. just EnableThemeDialogTexture() in WM_INITDIALOG of the sub-dialog

    I went to check it on XP and … it worked perfect and looked beautiful, apart from flickering.

    I added WS_CLIPCHILDREN and suddenly was able to reproduce your screenshots perfectly. I was first thinking this was the cause.

    I kept pushing and added WS_COMPOSITED to prevent flickering, and the tab window suddenly was gone – entirely covered by the tab’s background. Now I realized the Z order was at fault.

    Child windows are always created at the bottom of the Z order, i.e. below your tab control. Your code never moves them upwards. The tabs only ever displayed by pure luck/overdraw, producing the artifacts you observe. Fix the Z order and there will be no more artifacts.

    0 讨论(0)
提交回复
热议问题