# CodeGuru Technical FAQs > CodeGuru Individual FAQs >  MFC Dialog: How to start your dialog application in hidden mode?

## Sonu Kapoor

*Q:* How to start your dialog application in hidden mode?

*A:* If you put the function 'ShowWindow(SW_HIDE)' in your 'OnInitDialog()', it won't have any effect, because 'OnInitDialog()' always finishes with calling 'ShowWindow(SW_SHOW)'. But there is a workaround for that. Create a 'BOOL' member variable into your dialog class and set it to 'FALSE' in the constructor.



```
class CYourDialog : public CDialog
{
  ...

private:
  BOOL m_visible;
};


CYourDialog::CYourDialog(CWnd* pParent /*=NULL*/)
  : CDialog(CYourDialog::IDD, pParent)
{
  //...
  m_visible = FALSE;
}
```

Now override the 'WM_WINDOWPOSCHANGING' message handler. Your code should look something like this to hide the dialog:



```
void CYourDialog::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) 
{
  if(!m_visible)
  {
    lpwndpos->flags &= ~SWP_SHOWWINDOW;
  }

  CDialog::OnWindowPosChanging(lpwndpos);
}
```

To make the dialog again visible, use the following code:



```
//...
m_visible = TRUE;
ShowWindow(SW_SHOW);
//...
```

----------

