WxClientDC and wxBitmap problem
Alex Bligh
alex at alex.org.uk
Wed Aug 9 11:13:35 PDT 2006
jgomez,
You need to paint the window in an EVT_PAINT function. Not merely
in the constructor (which will only be called once). There is no
need to refresh it. You want to load your bitmap ONCE from the png
into a member variable, not an automatic.
Alex
jgomez at net2u.es wrote:
> Hi
>
> I'm developing a class that extends from wxWindow class.I want to drawan
> image to the window client area (i want to develop something like a
> clickable wxBitmap).The problem is that the image dosnt draw in the
> window.
>
> Here is the code :
>
> MyClass::MyClass(wxWindow* parent, wxWindowID id, const wxPoint& pos =
> wxDefaultPosition,const wxSize& size = wxDefaultSize)
> :wxWindow(parent,id,pos,size,0,"")
> {
> // insert your code here
> wxImage::AddHandler( new wxPNGHandler );
> wxImage img;
> img.LoadFile(_T("img/switch.png"), wxBITMAP_TYPE_PNG);
> wxBitmap i(img);
>
> wxClientDC dc( this );
> PrepareDC( dc );
> wxMemoryDC memDC;
> memDC.SelectObject(i);
> dc.Blit(0,0, i.GetWidth(), i.GetHeight(),&memDC, 0, 0, wxCOPY, false);
> this->Refresh();
> }
>
> And the invocation :
>
> p=new MyClass(this,-1,wxPoint(10,10),wxSize(50,50));
>
> Could somebody see any error?.
>
> Thanks a lot.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>
More information about the wx-users
mailing list