Click to See Complete Forum and Search --> : Background Picture on Dialog
WXP
May 9th, 2001, 09:42 AM
Hey !
I Created a Dialog Based App.
And i put a picture box on the background and other controls on it. The trouble is they disappear under the picture.
So i changed the TAB Order but when a window comes over my app the button disappear again !!
How is it possible to put a picture on the background without a picture box ?
OR how it is possible to have my controls over eveything ?
Thanx
Xeon
May 9th, 2001, 10:00 AM
That's no way to do things, pal! A picture box is both inefficient and darn, pal. :-D
Now, Uncle Xeon to the fire scene rescue!
First, in your OnInitDialog(), code the following and paste everything just above the 'return TRUE;' statement, but below everything else:
CBitmap bitmap;
bitmap.LoadBitmap(IDB_YOURBITMAP);
CClientDC dc(this);
CRect rcRect;
GetClientRect(rcRect);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.SelectObject(&bitmap);
dc.BitBlt(0,0,rcRect.Width(), rcRect.Height(),&memDC,0,0,SRCCOPY);
Now, that's all to it! But preferably, u should add a windows message handler call WM_ERASEBKGND and add the code above to it. Now, don't treat me to a buffet though. :-D That's too grand! :-D
WXP
May 9th, 2001, 10:09 AM
It's not working Xeon.. sorry..
My Dialog do not have my pic on the background.. not even a pixel !
anyother idea ?
BOOL CGPIBMultimeterDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// Some of my code...
CBitmap bitmap;
bitmap.LoadBitmap(IDB_INTERFACE_BITMAP);
CClientDC dc(this);
CRect rcRect;
GetClientRect(rcRect);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.SelectObject(&bitmap);
dc.BitBlt(0,0,rcRect.Width(), rcRect.Height(),&memDC,0,0,SRCCOPY);
return TRUE; // return TRUE unless you set the focus to a control
}
Weiye
May 9th, 2001, 10:15 AM
You can do your displaying of bitmap inside you dialog's OnDraw(...) function.
Chen Weiye
------------------------------------------------------------------------------
When pursuing your dream, don't forget to enjoy your life...
------------------------------------------------------------------------------
Gerd Mayer
May 9th, 2001, 10:19 AM
class CGPIBMultimeterDlg : public CDialog
//....
//{{AFX_MSG(CGPIBMultimeterDlg )
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
//....
BEGIN_MESSAGE_MAP(CGPIBMultimeterDlg, CDialog)
//{{AFX_MSG_MAP(CMedStatix)
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CGPIBMultimeterDlg::OnEraseBkGnd(CDC* pDC)
{
CBitmap bitmap;
bitmap.LoadBitmap(IDB_INTERFACE_BITMAP);
CRect rcRect;
GetClientRect(rcRect);
CDC memDC;
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&bitmap);
dc.BitBlt(0,0,rcRect.Width(),
rcRect.Height(),&memDC,0,0,SRCCOPY);
return TRUE; // Don't call base class
}
That's the way
But another hint;-)
You should make
the CBitmap bitmap;
as a member of your dialog and load the bitmap only one time in the OnInitDialog
Regards,
Gerd
Gerd
WXP
May 9th, 2001, 10:20 AM
thanx it worked
Xeon
May 9th, 2001, 10:26 AM
Do u have the bitmap imported into your resources?
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.