Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.


Specifies whether CWnd is minimized (iconic).

BOOL IsIconic( ) const;

Nonzero if CWnd is minimized; otherwise 0.

void CAboutDlg::OnPaint()
   // This code, normally emitted by the Application Wizard for a dialog- 
   // based project for the dialog's WM_PAINT handler, runs only if the  
   // window is iconic. The window erases the icon's area, then 
   // paints the icon referenced by m_hIcon. 
   if (IsIconic())
      CPaintDC dc(this); // device context for painting

      SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0);

      // Center icon in client rectangle 
      int cxIcon = GetSystemMetrics(SM_CXICON);
      int cyIcon = GetSystemMetrics(SM_CYICON);
      CRect rect;
      int x = (rect.Width() - cxIcon + 1) / 2;
      int y = (rect.Height() - cyIcon + 1) / 2;

      // Draw the icon
      dc.DrawIcon(x, y, m_hIcon);

Header: afxwin.h

Community Additions

© 2015 Microsoft