Displaying Pictures

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
k_mania
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Feb 15, 2013 4:34 am

Displaying Pictures

Post by k_mania » Fri Feb 15, 2013 4:39 am

Ok so I have been trying to figure this out all day, and I'm sure it will end up being very simple and something I've just overlooked but I don't really know where else to turn.

I've been working off info from tutorials and sites, mainly
http://wiki.wxwidgets.org/An_image_panel

And I have that working, the only problem is it displays the picture in a new frame. I need to put the picture in an area within an existing frame, eventually on the click of a button it will go to the next picture in an array of locations being passed to the form by my c++ code but I have that sorted out.

I just need to know how to place the picture into my existing form and display it there, rather than a separate window.

Any guidance would be appreciated.

Radek
Super wx Problem Solver
Super wx Problem Solver
Posts: 286
Joined: Sun Sep 11, 2011 7:17 am

Re: Displaying Pictures

Post by Radek » Fri Feb 15, 2013 10:13 am

There is a wxStaticBitmap class. Put the wxStaticBitmap where you want it in your frame and set an image for it. You can set the image from your code. You can change the image when you want. If you are using some kind of "GUI designer" and resource files then you can specify the image in the resource file. Sure, you can change the image later.

k_mania
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Feb 15, 2013 4:34 am

Re: Displaying Pictures

Post by k_mania » Fri Feb 15, 2013 10:37 am

I tried using that, I had problems getting it to resize properly. Also I read it should be used more for small images and icons, especially on Windows.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: Displaying Pictures

Post by Auria » Mon Feb 18, 2013 12:35 am

The wiki example you pointed to just draws into a panel. You are free to place that panel wherever you want.

Code: Select all

// make sure to call this first
            wxInitAllImageHandlers();
            
            wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
            frame = new wxFrame(NULL, wxID_ANY, wxT("Hello wxDC"), wxPoint(50,50), wxSize(800,600));
            
            // then simply create like this
            drawPane = new wxImagePanel( frame, wxT("image.jpg"), wxBITMAP_TYPE_JPEG);
            sizer->Add(drawPane, 1, wxEXPAND);
            
            frame->SetSizer(sizer);
            
            frame->Show();
            return true;
this is the part where the panel is added to the sample frame. Adapt as you need.
"Keyboard not detected. Press F1 to continue"
-- Windows

Post Reply