Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 408069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:39:23+00:00 2026-05-12T17:39:23+00:00

I have a Custom control derived from wxControl,inside a dialog with a vertical sizer

  • 0

I have a Custom control derived from wxControl,inside a dialog with a vertical sizer

wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
Knob* newKnob = new Knob(panel,wxID_ANY,wxDefaultPosition,wxSize(40,40));
topSizer->Add(newKnob,0,wxALL|wxALIGN_CENTER);
panel->SetSizer(topSizer);
topSizer->Fit(panel);

//panel is a wxPanel inside the dialog

But for some reason ,the custom controls’ size is set at (80,100).If i resize the dialog beyond that size its aligned to center as i specified.

EDIT:
Am using wx 2.8.9 on windows Vista with visual studio 2005.

What could be missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:39:24+00:00Added an answer on May 12, 2026 at 5:39 pm

    You didn’t provide any information about the wxWidgets version or your platform / compiler, so I will answer for wxWidgets 2.8 and MSW.

    The size you specify is not necessarily used for the control, since the best size for different platforms may well be different. Even on Windows the size will usually depend on the default GUI font. So there are various methods in wxWidgets that let windows specify their minimum, best or maximum size. If you have special requirements you may need to override some of them.

    For your problem it looks like you want to have the control have a smaller size than the default best size of wxControl:

    wxSize wxControl::DoGetBestSize() const
    {
        return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT);
    }
    

    (taken from src/msw/control.cpp) with the values

    #define DEFAULT_ITEM_WIDTH  100
    #define DEFAULT_ITEM_HEIGHT 80
    

    (taken from include/wx/msw/private.h).

    If you override DoGetBestSize() to return your intended size it should work.

    Edit:

    You comment that you cannot override DoGetBestSize() since it is not virtual in wxControl. It is though, because it is introduced in wxWindow:

    // get the size which best suits the window: for a control, it would be
    // the minimal size which doesn't truncate the control, for a panel - the
    // same size as it would have after a call to Fit()
    virtual wxSize DoGetBestSize() const;
    

    (taken from include/wx/window.h). wxWindow is a parent class of wxControl, so the method is indeed virtual and you can of course override it. Many controls do in fact, as a grep in the sources will show you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 219k
  • Answers 219k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer xml.tag! 'latest-id', "latest ID with hiphen." May 12, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer For your first question, it depends on which headers you… May 12, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer In a language like PHP—which is largely interpreted at runtime—I… May 12, 2026 at 11:41 pm

Related Questions

Lets pretend that for some reason I want to create a custom control that
I have read over this which sort of gives an explanation of when you'd
This is my first foray into custom controls, and it's not going well. I
I have a custom control that is derived from TabItem , and I want

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.