Re: Combobox height
- From: "David Youngblood" <dwy@xxxxxxxxx>
- Date: Mon, 24 Jul 2006 23:55:41 -0500
"Michael C" <nospam@xxxxxxxxxx> wrote in message
news:uSFVep5rGHA.4296@xxxxxxxxxxxxxxxxxxxxxxx
<James@xxxxxxx> wrote in message
news:fleac2laudc77snh31mn0b2a0bj8g01s7u@xxxxxxxxxx
For a long time I have been using the following code to control a
comboboxes drop don height
the problem is that itdoes not work of the combobox s in a frame How
come and is there a way arond it
You didn't really try very hard to solve this. A bit of simple debugging
should have had the answer for you in no time. The reason is that
Combo.Parent always returns the form so you're changing the scalemode of the
form not the frame. This immediately struck me as a really bad idea anyway
and doing it correctly fixed the problem. The reason this is a bad idea is
doing this sort of coding it is very easy for your form to get stuck in the
wrong scale mode and for everything to go haywire.
Public Sub SetComboHeight(ByVal Combo As ComboBox, ByVal Height As Long)
Dim L As Long, T As Long, W As Long
L = ScaleX(Combo.Left, Combo.Parent.ScaleMode, vbPixels)
T = ScaleX(Combo.Top, Combo.Parent.ScaleMode, vbPixels)
W = ScaleX(Combo.Width, Combo.Parent.ScaleMode, vbPixels)
MoveWindow Combo.hwnd, L, T, W, Height, 1
End Sub
Other changes I would suggest is to pass the combo box in ByVal and Height
in ByVal, don't bother with the return type if you're not using it and to
get rid of the use of With, it made your code pretty unreadable.
Isn't the coordinate system for a frame control always in twips?
So instead of Combo.Parent.ScaleMode, use vbTwips in the scale conversions.
David
.
- Follow-Ups:
- Re: Combobox height
- From: Michael C
- Re: Combobox height
- References:
- Combobox height
- From: James
- Re: Combobox height
- From: Michael C
- Combobox height
- Prev by Date: Re: printing using tabs
- Next by Date: Re: Can Dir handle different file types?
- Previous by thread: Re: Combobox height
- Next by thread: Re: Combobox height
- Index(es):
Relevant Pages
|