I want to move a wxStaticBitmap from frame to another Dialog, how to do?  [SOLVED]

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.
lfjking
Experienced Solver
Experienced Solver
Posts: 96
Joined: Mon Nov 14, 2016 1:35 pm

I want to move a wxStaticBitmap from frame to another Dialog, how to do?

Postby lfjking » Sat Jul 14, 2018 7:11 am

I want to move a wxStaticBitmap from frame to another Dialog, how to do?

frame:

Code: Select all

///////////////////////////////////////////////////////////////////////////////
/// Class MyFrame.h
///////////////////////////////////////////////////////////////////////////////
#include "MyDialog.h"
class MyFrame : public wxFrame
{
   private:
   
   protected:
      wxScrolledWindow* m_scrolledWindow;
      wxStaticBitmap* m_bitmap;
      MyDialog*        m_dialog;
   public:
      
      MyFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
      wxAuiManager m_mgr;
      
      ~MyFrame();
   
};
/// Class MyFrame.cpp
MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
   this->SetSizeHints( wxDefaultSize, wxDefaultSize );
   m_mgr.SetManagedWindow(this);
   m_mgr.SetFlags(wxAUI_MGR_DEFAULT);
   
   m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
   m_scrolledWindow->SetScrollRate( 5, 5 );
   m_mgr.AddPane( m_scrolledWindow, wxAuiPaneInfo() .Center() .PinButton( true ).Dock().Resizable().FloatingSize( wxDefaultSize ) );
   
   wxGridSizer* gSizer;
   gSizer = new wxGridSizer( 0, 2, 0, 0 );
   
   m_bitmap = new wxStaticBitmap( m_scrolledWindow, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
   gSizer->Add( m_bitmap, 0, wxALL, 5 );
   
   
   m_scrolledWindow->SetSizer( gSizer );
   m_scrolledWindow->Layout();
   gSizer->Fit( m_scrolledWindow );
   
   m_dialog = new MyDialog(this);
   
   m_mgr.Update();
   this->Centre( wxBOTH );
}

MyFrame::~MyFrame()
{
   m_mgr.UnInit();
   
}


and the Dialog:

Code: Select all

///////////////////////////////////////////////////////////////////////////////
/// Class MyDialog.h
///////////////////////////////////////////////////////////////////////////////
class MyDialog : public wxDialog
{
   private:
   
   protected:
   
   public:
      
      MyDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); wxAuiManager m_mgr;
      
      ~MyDialog();
   
};
/// Class MyDialog.cpp
MyDialog::MyDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
   this->SetSizeHints( wxDefaultSize, wxDefaultSize );
   m_mgr.SetManagedWindow(this);
   m_mgr.SetFlags(wxAUI_MGR_DEFAULT);
   
   
   m_mgr.Update();
   this->Centre( wxBOTH );
}

MyDialog::~MyDialog()
{
   m_mgr.UnInit();
   
}



now ,how can I put the m_bitmap ( wxStaticBitmap ) from the MyFrame to the MyDialog?

User avatar
doublemax
Moderator
Moderator
Posts: 12423
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: I want to move a wxStaticBitmap from frame to another Dialog, how to do?

Postby doublemax » Sat Jul 14, 2018 8:37 am

It's not totally clear to me what you want to do. If you just want to display the same bitmap in another window, i would suggest to just create a new wxStaticBitmap based on the same bitmap. Everything else would be unnecessarily complicated.
Use the source, Luke!

lfjking
Experienced Solver
Experienced Solver
Posts: 96
Joined: Mon Nov 14, 2016 1:35 pm

Re: I want to move a wxStaticBitmap from frame to another Dialog, how to do?  [SOLVED]

Postby lfjking » Sat Jul 14, 2018 8:56 am

doublemax wrote:It's not totally clear to me what you want to do. If you just want to display the same bitmap in another window, i would suggest to just create a new wxStaticBitmap based on the same bitmap. Everything else would be unnecessarily complicated.


sorry , I use the wrong fun setParent .
I can switch normally after using Reparent
:D
thanks!


Return to “C++ Development”

Who is online

Users browsing this forum: No registered users and 14 guests