both the init and the paint:
Code:
BOOL CFloatingDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowPos(NULL,
0, 0,
960, 540,
SWP_NOMOVE | SWP_NOZORDER);
return TRUE; // return TRUE unless you set the focus to a control
}
void CFloatingDlg::OnPaint()
{
// CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
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;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
}
else
{
// our paint DC
CPaintDC dc(this);
// load up our bitmap into bmME
CBitmap cbmME;
// for resources use:
// cbmME.LoadBitmap(IDB_BITMAP_ME);
// for files use this:
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, "preview.bmp", IMAGE_BITMAP,
960, 540, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if (hBmp == NULL)
{
TRACE0("::LoadImage('preview.bmp') failed");
return;
}//if
cbmME.Attach(hBmp);
// draw to dialog
CRect framerect;
this->GetWindowRect(framerect);
ScreenToClient(framerect);
// create a memory DC
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
// select the bitmap into the memory dc
CBitmap *old = dcMem.SelectObject(&cbmME);
// get the raw bitmap for access to its attributes
BITMAP bm;
cbmME.GetBitmap(&bm);
// blit it
dc.BitBlt(framerect.left, framerect.top,
bm.bmWidth, bm.bmHeight,
&dcMem, 0, 0, SRCCOPY);
dcMem.SelectObject(old);
::DeleteObject(hBmp);
CDialog::OnPaint();
}
}
note that I changed your code so that it was no longer attaching the bitmap to the static frame, but to the dialog itself. Maybe this is the problem? (I was just noticing your use of cbmMe which is not defined in my code)... hmm.... looking at it, I have no idea what cbmME is.