|
Question : flickering in dialog controls
|
|
Hi, i have a CDialog "CMainDlg" with a CTabCtrl. The CTabCtrl "m_tabCtrl" creates some pages with borderless dialog templates from the resources in CMainDlg::OnInitDialog(), named "m_cPg1".."m_cPg4"
I implemented automatic window-fitting of the controls by OnSize() Handler of the CMainDlg
Problem: the controls flicker strong while sizing (e.g. a CListControl on the CTabCtrl).
- please see code below - how to resize the controls without flickering ? They should be resized flicker-free while moving.(Other win apps can do that) - a simple ClistControl on the CMainDlg (without a CTabcontrol) does also flicker. - I read about a memory dc, which can be used for flicker free custom painting in OnEraseBknd() handler. But I need no extra painting (e.g. a CBitmap) that would require a dc. I only need to resize dialog controls! Do I need to use buffering technique ?
Thanks very much!
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
|
void CMainDlg::OnSize(UINT nType, int cx, int cy)
{
// comment out or leave, put at top or at end: has no visual effect!!
// CDialog::OnSize(nType, cx, cy);
// fit control windows to new size:
// (using FALSE means telling Windows that no repaint is required immediately.)
m_tabctrl.MoveWindow(10, 10, cx-20, cy-60, FALSE);
// now resize the dialog windows of the tab control, do only for visible tab
CRect r;
m_tabctrl.GetClientRect(&r);
switch(m_tabctrl.GetCurSel())
{
case 0:
m_cPg1.MoveWindow(20, 50, r.Size().cx-20, r.Size().cy-50, FALSE);
break;
case 1:
m_cPg2.MoveWindow(20, 50, r.Size().cx-20, r.Size().cy-50, FALSE);
break;
case 2:
m_cPg3.MoveWindow(20, 50, r.Size().cx-20, r.Size().cy-50, FALSE);
break;
case 3:
m_cPg4.MoveWindow(20, 50, r.Size().cx-20, r.Size().cy-50, FALSE);
break;
} // end switch
}
void CSubDlg::Onsize(UINT nType, int cx, int cy)
{
// comment out or leave, put at top or at end: has no visual effect!!
CDialog::OnSize(nType, cx, cy);
// fit clistctrl member to new size
...
m_list.MoveWindow (x2, y1, sx2, y_area, FALSE); // the list control flickers
}
|
|
|
Answer : flickering in dialog controls
|
|
Does this help
void CMainDlg::OnSize(UINT nType, int cx, int cy) { LockWindowUpdate();
// comment out or leave, put at top or at end: has no visual effect!! // CDialog::OnSize(nType, cx, cy);
// fit control windows to new size: // (using FALSE means telling Windows that no repaint is required immediately.)
m_tabctrl.MoveWindow(10, 10, cx-20, cy-60, FALSE);
// now resize the dialog windows of the tab control, do only for visible tab CRect r; m_tabctrl.GetClientRect(&r); switch(m_tabctrl.GetCurSel()) { case 0: m_cPg1.MoveWindow(20, 50, r.Size().cx-20, r.Size().cy-50, FALSE); break; case 1: m_cPg2.MoveWindow(20, 50, r.Size().cx-20, r.Size().cy-50, FALSE); break;
case 2: m_cPg3.MoveWindow(20, 50, r.Size().cx-20, r.Size().cy-50, FALSE); break;
case 3: m_cPg4.MoveWindow(20, 50, r.Size().cx-20, r.Size().cy-50, FALSE); break; } // end switch
UnlockWindowUpdate(); }
|
|
|
|