-1

Due to the issue rised after i used WX_EX_COMPOSITED i was forced to turn it off since it wasn't compatible with listview with report type set.

Disabling desktop composition causes flickering on Tab Control

Now whenever i resize the TAB control along with resizing the main dialog in response to any one of the messages WM_SIZE,WM_SIZING,WM_WINDOWPOSCHANGED messages

invoke GetClientRect,hWnd,addr CLRECT
LEA EAX, CLRECT
invoke MoveWindow,MainTabHandle,NULL,NULL,[EAX].RECT.right,[EAX].RECT.bottom,TRUE

There is a lot of flickering going with the TAB control.

I have already turned off WM_ERASEBKGND message by returning true to the default window procedure.

.elseif uMsg == WM_ERASEBKGND
            MOV EAX,1
            RET

and handling WM_PRINT message on my own using this article that i have read from Microsoft.

https://msdn.microsoft.com/en-us/library/ms969905.aspx

WM_PRINT message handler

invoke BeginPaint,hWnd,addr PS
invoke Paint,hWnd,addr PS
invoke EndPaint,hWnd,addr PS ;PS is just a LOCAL PAINTSTRUCT structure used for painting

Paint procedure after i ported it from C++ to MASM

Paint Proc hWnd:DWORD,  pPAINTSTRUCT:PPAINTSTRUCT
LOCAL rc:RECT ;
LOCAL hdcMem:HDC ;
LOCAL hBITMAP:HANDLE
LOCAL hbmMem:HANDLE
LOCAL hbmOld:HANDLE

LOCAL hbrBkGnd:HBRUSH ;
LOCAL hfntOld:HFONT ;


invoke GetClientRect,hWnd,addr rc
MOV EAX,pPAINTSTRUCT
invoke CreateCompatibleDC,[EAX].PAINTSTRUCT.hdc
MOV hdcMem ,EAX
MOV EAX,pPAINTSTRUCT

invoke CreateCompatibleBitmap,[EAX].PAINTSTRUCT.hdc,rc.right,rc.bottom
MOV hbmMem,EAX
invoke SelectObject,hdcMem,hbmMem
MOV hbmOld,EAX
invoke GetSysColor,COLOR_WINDOW
invoke CreateSolidBrush,EAX
MOV hbrBkGnd,EAX
invoke FillRect,hdcMem,addr rc,hbrBkGnd
invoke DeleteObject,hbrBkGnd

 .if hfnt
    invoke SelectObject,hdcMem,hfnt
    MOV hfntOld,EAX
 .endif
    


invoke SetBkMode,hdcMem,TRANSPARENT
invoke GetSysColor,COLOR_WINDOWTEXT
invoke SetTextColor,hdcMem,EAX


invoke DrawText,hdcMem,addr szCaption,-1,addr rc,DT_CENTER

 
    invoke SelectObject,hdcMem,hfntOld

         
MOV EAX,pPAINTSTRUCT
LEA EBX,rc
MOV EDX,[EBX].RECT.right
SUB EDX,[EBX].RECT.left

MOV ECX,[EBX].RECT.bottom
SUB ECX,[EBX].RECT.top

invoke BitBlt,[EAX].PAINTSTRUCT.hdc,rc.left,rc.top,EDX,ECX,hdcMem,0, 0,SRCCOPY
invoke SelectObject,hdcMem, hbmOld

invoke DeleteObject,hbmMem;
invoke DeleteDC,hdcMem;

The Paint function seems to work fine since if i omit the call to it, there is a drawing issue when resizing to extend the width of the main dialog the new area is just black. But if i call paint then the new area after resize is drawn correctly. But there is huge amount of flickering.

I have 3 dialog boxes one is the main dialog invoked through DialogBoxParam API

And the other 2 are just modeless dialog boxes(with no caption and it's Style is set to DS_SYSMODAL) these dialog boxes will be attached to the TAB control through CreateDialogParam API call each one has it's own unique DlgProc.

Now what should i do to avoid control resizing flickering? should i do sub-classing to the control that i want to resize? and disable WM_ERASEBKGND for each control individually?

Is disabling the WM_ERASEBKGND message need to be done only in the main dialog or for all modeless dialogboxes as well?

Any one could help about this matter?

Community
  • 1
  • 1
RCECoder
  • 247
  • 1
  • 5
  • 15
  • I have found a way around it by using the WS_EX_COMPOSITED flag on the tab control instead of on the dialog box itself and use the WS_CLIPCHILDREN on the main dialog. This fixed the flickering issue when resizing the tab. However now the child controls aren't rendering properly and they are disappearing after resizing the tab. On WM_SIZING message i am using MoveWindow api on the tab control with bRepaint set to true how would i make the child controls draw properly without being lost after resizing? – RCECoder Oct 18 '17 at 04:25

1 Answers1

0

Issue is fixed by using SetParent on Listview and the parent set is the main dialog instead of the sub dialog and when switching between tabs to click other tab than listview tab i basically used SetParent again to return the parent of listview to the sub dialog so the code still hide it with ShowWindow. Now the Listview always show on top. No flickering at all even though the WM_ERASEBKGND is not disabled. Now i can have WS_EX_COMPOSITED flag sit on listview, Tab control and Main dialog without the problem of invisible frames of listview in report type. I think the main issue is because the double buffering using bottom-to-top drawing method.

RCECoder
  • 247
  • 1
  • 5
  • 15
  • Is this still a separate question from your previous https://stackoverflow.com/questions/46760792/disabling-desktop-composition-causes-flickering-on-tab-control, or should this be closed as a duplicate? (I don't do Windows GUIs, so I didn't try to really read or understand either question or answer, I just see they look quite similar.) Thanks for sharing the solutions to your problems on SO; I'm just trying to keep the place neat and tidy :) – Peter Cordes Oct 21 '17 at 02:44
  • Hi friend. You can close either question. Is similar yes sorry. – RCECoder Oct 21 '17 at 03:27
  • Don't worry about it, sometimes you think something's a separate issue and it turns out not to be. – Peter Cordes Oct 21 '17 at 03:29