MSW wxControl::SetInitialSize

14 views
Skip to first unread message

Manolo

unread,
Nov 9, 2012, 3:09:16 PM11/9/12
to wx-...@googlegroups.com
Hi

wxComboBox::Create() makes SetInitialSize() to be called twice: one at the end
of wxControl::MSWCreateControl() and again at the end of
wxChoice::CreateAndInit().

The problem I find is that when DoGetBestSize() is called the first time,
Windows returns
wrong values for the size of the control. The second time, values are right.
I seems to me that MSWCreateControl() must return before Windows gets the right
values.

I suggest removing SetInitialSize() from wxControl::MSWCreateControl(),
and keeping each call from derived controls.

TIA
Manolo

Vadim Zeitlin

unread,
Nov 9, 2012, 3:39:04 PM11/9/12
to wx-...@googlegroups.com
On Fri, 09 Nov 2012 21:09:16 +0100 Manolo wrote:

M> wxComboBox::Create() makes SetInitialSize() to be called twice: one at
M> the end of wxControl::MSWCreateControl() and again at the end of
M> wxChoice::CreateAndInit().

This is indeed inefficient.

M> The problem I find is that when DoGetBestSize() is called the first
M> time, Windows returns wrong values for the size of the control.

Is it really Windows? I think DoGetBestSize() returns minimal size simply
because there are no items in the control yet.

M> I seems to me that MSWCreateControl() must return before Windows gets
M> the right values.

I really don't think so.

M> I suggest removing SetInitialSize() from wxControl::MSWCreateControl(),
M> and keeping each call from derived controls.

The trouble is that some other classes don't call SetInitialSize() (e.g.
wxStaticLine to give a trivial example), so just removing it would break
things. So unless the current code has some more serious problems than
"just" unnecessarily repositioning the control twice (which is, to be fair,
bad enough) I'd prefer to not touch it. Otherwise we'd need to review all
code calling MSWCreateControl() and add SetInitialSize() calls if
necessary.

Regards,
VZ

Manolo

unread,
Nov 9, 2012, 3:44:29 PM11/9/12
to wx-...@googlegroups.com
> M> The problem I find is that when DoGetBestSize() is called the first
> M> time, Windows returns wrong values for the size of the control.
>
> Is it really Windows? I think DoGetBestSize() returns minimal size simply
> because there are no items in the control yet.
I see this wrong values using COMBOBOXINFO inside DoGetSizeFromTextSize().

> M> I suggest removing SetInitialSize() from wxControl::MSWCreateControl(),
> M> and keeping each call from derived controls.
>
> The trouble is that some other classes don't call SetInitialSize() (e.g.
> wxStaticLine to give a trivial example), so just removing it would break
> things. So unless the current code has some more serious problems than
> "just" unnecessarily repositioning the control twice (which is, to be fair,
> bad enough) I'd prefer to not touch it. Otherwise we'd need to review all
> code calling MSWCreateControl() and add SetInitialSize() calls if
> necessary.
The only problem I've noticed is the one you've said.

TIA
Manolo

Reply all
Reply to author
Forward
0 new messages