| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Background Picture on Dialog
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 |
|
#2
|
||||
|
||||
|
Re: Background Picture on Dialog
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
__________________
"Hell is calling for you!" - Rufus, from Valkyrie Profile 2 : Silmeria "I'm getting tired of you devils.....finishing strike......Final Blast!" - Arngrim, from Valkyrie Profile 2 : Silmeria |
|
#3
|
|||
|
|||
|
Re: Background Picture on Dialog
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 } |
|
#4
|
|||
|
|||
|
Re: Background Picture on Dialog
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... ------------------------------------------------------------------------------
__________________
Chen Weiye ----------------------------------------------------------------------------- When pursuing your dream, don't forget to enjoy your life ----------------------------------------------------------------------------- |
|
#5
|
|||
|
|||
|
Re: Background Picture on Dialog
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 |
|
#6
|
|||
|
|||
|
Re: Background Picture on Dialog
thanx it worked
|
|
#7
|
||||
|
||||
|
Re: Background Picture on Dialog
Do u have the bitmap imported into your resources?
__________________
"Hell is calling for you!" - Rufus, from Valkyrie Profile 2 : Silmeria "I'm getting tired of you devils.....finishing strike......Final Blast!" - Arngrim, from Valkyrie Profile 2 : Silmeria |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|