Just out of curiosity, I have tried to draw "live" another frame inside a frame. I could not get it done, the window decorations are not being drawn properly. I may/must have made a mistake somewhere in the code, assuming Windows 10 is not to "blame".
Code: Select all
#include <wx/wx.h>
class OtherFrame : public wxFrame
{
public:
OtherFrame() : wxFrame(NULL, wxID_ANY, "Other Frame", wxDefaultPosition, wxSize(300,300))
{
wxTextCtrl* text = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
text->SetValue("Hello world");
}
};
class MainFrame : public wxFrame
{
public:
MainFrame() : wxFrame(NULL, wxID_ANY, "Test", wxDefaultPosition, wxSize(600,600), wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE)
{
m_otherFrame = new OtherFrame();
m_otherFrame->Show();
m_otherFrame->Bind(wxEVT_DESTROY, &MainFrame::OnOtherFrameDestroyed, this);
m_timer.SetOwner(this);
m_timer.Start(1000);
Bind(wxEVT_TIMER, &MainFrame::OnTimer, this);
Bind(wxEVT_PAINT, &MainFrame::OnPaint, this);
}
private:
wxTimer m_timer;
OtherFrame* m_otherFrame;
void OnPaint(wxPaintEvent&)
{
wxPaintDC dc(this);
dc.Clear();
if ( m_otherFrame && m_otherFrame->IsShown() )
{
wxWindowDC wdc(m_otherFrame);
dc.Blit(wxPoint(0,0), wdc.GetSize(), &wdc, wxPoint(0,0));
dc.SetPen(*wxRED_PEN);
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(wxPoint(0,0), wdc.GetSize());
}
}
void OnTimer(wxTimerEvent&)
{
Refresh();
Update();
}
void OnOtherFrameDestroyed(wxWindowDestroyEvent&)
{
m_otherFrame = NULL;
Refresh();
Update();
}
};
class MyApp : public wxApp
{
public:
virtual bool OnInit()
{
(new MainFrame())->Show();
return true;
}
}; wxIMPLEMENT_APP(MyApp);
Edit: FWIW, I have tried wxFormBuilder and CodeLite's wxCrafter (on Windows 10): Neither draws native window decorations (frame title etc.). wxRendererNative does not provide methods to draw (all) window decorations either.