//Center icon in the client rectangle Int cxIcon=GetSystemMetrics (SM_CXICON); Int cyIcon=GetSystemMetrics (SM_CYICON); CRect the rect. GetClientRect (& amp; The rect); Int x=(the rect. Width () - cxIcon + 1)/2; Int y=(the rect. Height () - cyIcon + 1)/2;
//Draw the icon Dc. DrawIcon (x, y, m_hIcon); } The else { CDialog: : OnPaint (); }
The CDC * pDC=GetDC ();/////////////black back The CDC MemDC;//define a first display device object CBitmap MemBitmap;//define a bitmap object
//then establish a compatible with screen display memory display device MemDC. CreateCompatibleDC (NULL); //can't drawing at this moment, because there is no place to paint ^_^ //below to create a compatible with screen display bitmap, as to the size of the bitmap, can use the size of the window MemBitmap. CreateCompatibleBitmap (pDC, 400400);
//will be chosen bitmap into memory display device in the //only the memory for the bitmap display device is drawing, painting on the specified bitmap CBitmap * pOldBit=MemDC. SelectObject (& amp; MemBitmap);
//use the background color first bitmap clean, here I was using a white background as a //you can also use you should use the color of the MemDC. FillSolidRect (0,0,400,400 BLACK_BRUSH);
//the drawing after completion of cleaning MemBitmap. DeleteObject (); MemDC. DeleteDC ();
}
//The system calls this to obtain The cursor to display while The user drags //the minimized window. HCURSOR CMy555Dlg: : OnQueryDragIcon () { Return (HCURSOR) m_hIcon; }