|
The following is a function added to the dialog's onPaint that loads the background image. How can it not be loaded?
void CLoadPicDlg :: OnPaint ()
{
if (IsIconic ())
{
// CPaintDC dc (this); // device context for painting
// SendMessage (WM_ICONERASEBKGND, reinterpret_cast <WPARAM> (dc.GetSafeHdc ()), 0);
//// Center icon in client rectangle
// int cxIcon = GetSystemMetrics (SM_CXICON);
// int cyIcon = GetSystemMetrics (SM_CYICON);
// CRect rect;
// GetClientRect (&rect);
// int x = (rect.Width ()-cxIcon + 1) / 2;
// int y = (rect.Height ()-cyIcon + 1) / 2;
//// Draw the icon
//dc.DrawIcon(x, y, m_hIcon);
CPaintDC dc (this); // device context for painting
CRect rect;
GetClientRect (&rect); // Get the size of the form
CDC dcMem;
dcMem.CreateCompatibleDC (&dc);
CBitmap bmpBackground;
bmpBackground.LoadBitmap (IDB_BK); // Load the background image
BITMAP bitMap;
bmpBackground.GetBitmap (&bitMap);
CBitmap * pbmpOld = dcMem.SelectObject (&bmpBackground);
dc.StretchBlt (0,0, rect.Width (), rect.Height (),&dcMem, 0,0, bitMap.bmWidth,
bitMap.bmHeight, SRCCOPY); // This function pastes a bitmap to the dialog box
//// ------------ The following code adds text to the dialog box
dc.SetBkMode (TRANSPARENT);
dc.SetTextColor (RGB (0, 0, 255));
CString str;
BYTE * pIP = (BYTE *)&m_dwIP;
str.Format ("% d.% d.% d.% d:% d-% s", pIP [3], pIP [2], pIP [1], pIP [0], m_dwPort, m_strName);
dc.DrawText (_T (str),&CRect (50, 50, 450, 100), DT_SINGLELINE | DT_CENTER);
}
else
{
CDialog :: OnPaint ();
}
} |
|