I have an important dialog with one child window - a list control. When the dialog box is resized, I resize the list control accordingly; it is basically tied to all 4 edges of the dialog box. The problem is that during calibration, there is a noticeable flicker around the edges of the list control, especially when scroll bars are present. I am new to Win32 GUI, so I donβt know how to handle this. I have seen many articles on flicker-free drawing, but they all relate to individual custom controls and none of them relate to flicker-free diaphragm in general. How can I make it work without flickering?
There are several controls in my actual dialog box, but here is an example of minimal code that reproduces the problem (IDC_LIST1 is a list control in the Report view, IDD_DIALOG2 has the WS_CLIPCHILDREN style).
#define NUM_COLUMNS 8 #define NUM_ROWS 32 RECT rcDialog2WindowOriginal; RECT rcDialog2ClientOriginal; RECT rcList1ClientOriginal; INT_PTR Dialog2_OnInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam) { GetWindowRect(hDlg, &rcDialog2WindowOriginal); GetClientRect(hDlg, &rcDialog2ClientOriginal); GetWindowRect(GetDlgItem(hDlg, IDC_LIST1), &rcList1ClientOriginal); ScreenToClient(hDlg, ((LPPOINT)&rcList1ClientOriginal)); ScreenToClient(hDlg, ((LPPOINT)&rcList1ClientOriginal) + 1); SendDlgItemMessage(hDlg, IDC_LIST1, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); TCHAR szText[32];
Update
After viewing many other Windows applications (even those written by Microsoft), each of them faces the same flickering problems. This is especially noticeable when you resize a window with a status bar and a scroll bar in the upper left corner. I think I just need to live with it.
source share