How to eliminate flickering when using ShowWindow()


  I need to show a series of dialog boxes.  I use ShowWindow() to hide a dialog box before showing the next one. However, i notice significant flickering and slow refreshing ( coz i can see glimpses of background applications) when i use this function .

Eg from Dialog Box 1 to Dialog Box 2


   Any suggestions to the code or other methods to use??

Who is Participating?
mahnoConnect With a Mentor Commented:
U can increase speed by following way:

Add to class for Dlg2:

class CClassName : public CDialog {
  //add class member
  CDialog *m_pParentDlg;  
  //add metdod
  void SetParentDlg(CDialog *pParentDlg);


//Add string to constructor
void CClassName::CClassName() {
  //Initialize m_pParentDlg
  m_pParentDlg = NULL;

void CClassName::SetParentDlg(CDialog *pParentDlg) {
  m_pParentDlg = pParentDlg;

void CClassName::OnShowWindow(BOOL bShow, UINT nStatus) {
      CDialog::OnShowWindow(bShow, nStatus);
  if ((bShow == TRUE) && (m_pParentDlg != NULL))
    m_pParentDlg ->ShowWindow(SW_HIDE);

//Add this for OnClose, OnOk, etc.
void CClassName::OnClose() {
  if (m_pParentDlg != NULL)
    m_pParentDlg ->ShowWindow(SW_SHOW);

Hope this helps,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.