wxButton in wxFrame Problem



  • Wie einige von euch vielleicht mitbekommen haben, habe ich ein Problem mit wxWidgets in Version 2.6.1. Und zwar hier erstmal der Code:
    base.h

    #ifndef __BASE_H
    #define __BASE_H
    
    class MainApp: public wxApp
    {
      public:
          virtual bool OnInit();
    };
    
    class MainFrame: public wxFrame
    {
      public:
          MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size);
          void OnQuit(wxCommandEvent &event);
          void OnClick_Btn01(wxCommandEvent &event);
      private:
          DECLARE_EVENT_TABLE()
    };
    
    enum
    {
       ID_Quit = 1,
       ID_Button_01 = 2
    };
    
    #endif
    

    Base.cpp

    #include <wx/wxprec.h>
    #ifndef WX_PRECOMP
       #include <wx/wx.h>
    #endif
    
    #include "base.h"
    
    IMPLEMENT_APP(MainApp)
    
    bool MainApp::OnInit()
    {
       MainFrame *win = new MainFrame(_("Frame"), wxPoint (100, 100),wxSize(450, 340));
       win->Show(TRUE);
       SetTopWindow(win);
    
       return TRUE;
    }
    
    BEGIN_EVENT_TABLE(MainFrame, wxFrame)
       EVT_BUTTON(ID_Button_01, MainFrame::OnClick_Btn01)
    END_EVENT_TABLE()
    
    MainFrame::MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
        : wxFrame((wxFrame *) NULL, -1, title, pos, size)
    {
          wxButton *Button = new wxButton(this,ID_Button_01,"Mein Button",wxPoint(10,50),wxSize(250,30));  
    }
    
    void MainFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
    {
        Close(TRUE);
    }
    void MainFrame::OnClick_Btn01(wxCommandEvent & WXUNUSED(event))
    {
        wxMessageBox("Ets2T","test",wxYES_NO,this);  
    }
    

    So nun sehr ihr erstelle ich einen Button und möchte, dass dieser die gewünschte Größe bekommt, an dieser Position. Aber der Button passt sich immer auf das gesamte Bild an, wie verhindere ich das? Am besten ohne eine weitere Komponente verwenden zu müssen.
    Danke ! 🙂



  • Schau dir mal die Funktion SetSizer() von wxWindow an.


Anmelden zum Antworten