Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / How to put a background in a wxPanel

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. How to put a background in a wxPanel
#5640
Posted by: 2004-12-29 02:54:12
Hi all.

I'm a newbie in wxWidgets.
I would like to put a Bitmap image in the background of a wxPanel.

So here is the code that i put in the constructor of the wxPanel.

panelPerso::panelPerso(AppFrame *frame) :
    wxPanel((wxWindow*)frame, -1, wxDefaultPosition, wxSize(100, 700), 0, wxString("zonePerso"))
{

...
wxBitmap fondBitmap= wxBitmap("test2.bmp", wxBITMAP_TYPE_BMP);
 
wxClientDC dc(this);
PrepareDC(dc); 
dc.DrawBitmap(fondBitmap,0,0,true);

...
}

I don't have any errors but the image isn't displayed.

Can you help me ?
thx
Message2. Re: How to put a background in a wxPanel
#5680
Posted by: 2005-01-05 03:42:18
I had the same problem too.  I corrected it by defining the OnPaint event and putting the DC stuff in that event.  Windows is event driven.  So, you have to setup a paint event.  Be sure to use wxPaintDC and not wxClientDC.
Message3. Re: How to put a background in a wxPanel
#5681
Posted by: 2005-01-05 03:44:14
For an example, please see the there that starts with "newbie...."  I have include an example
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2022-8-10  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0