On my current project, I have one dialog with a combobox that contains many items. When run the combox box list goes the entire height of the screen -- clipping off the last item in the list. I search the forum, and tried to limit the height of the CB like so:
FF_CONTROL_GETSIZE HWND_DOWNTIME_DTREASON, lWidth, lHeight
SETWINDOWPOS HWND_DOWNTIME_DTREASON, 0, 0, 0, lWidth, (lHeight / 2), %SWP_NOMOVE OR %SWP_SHOWWINDOW OR %SWP_NOZORDER
But that seems to have no effect. I've tried both %CBS_DROPDOWN and %CBS_DROPDOWNLIST, as well as changing %CBS_NOINTREGALHEIGHT. I've also noticed that in the properties of the control, FireFly keeps resetting "Height" to 35 after a compile (or almost any other change to the form)
What else can I try?
Correction -- setting NOINTREGALHEIGHT trims the size, but does it too much.. With tat setting, the display is about 5 lines (16 point font, 'cuase we're using touch screens).
Hi Bud,
ComboBoxes are a strange animal. The height of the control is dictated by the selected font. From my tests, you can control the height of the dropdown list by setting the CBS_NOINTEGRALHEIGHT and then adjusting the height in the CBN_DROPDOWN.
'------------------------------------------------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ 'optional user defined Long value
) As Long
Local y As Long
For y = 1 To 100
FF_ComboBox_AddString HWND_FORM1_COMBO1, "MyString" & Str$(y)
Next
End Function
'------------------------------------------------------------------------------------------------------------------------
Function FORM1_COMBO1_CBN_DROPDOWN ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idComboBox As Dword _ ' identifier of combobox
) As Long
Local nWidth As Long
Local nHeight As Long
Local rc As Rect
GetWindowRect HWND_FORM1_COMBO1, rc
nWidth = rc.nRight - rc.nLeft
nHeight = (rc.nBottom - rc.nTop) / 2
SetWindowPos HWND_FORM1_COMBO1, 0, 0, 0, nWidth, nHeight, %SWP_NOZORDER Or %SWP_NOMOVE
End Function
Grrr. This is maddening; I added the code to the "_DROPDOWN" routine and it seems to have no effect. I tried different divisors (rc.nBottom - rc.nTop) /3, /4, etc), with no appreciable difference in the list.
I may search around of a custom control for this. The app is run on touch screens; it would be cool if the vertical scroll bar was much wider.
That is strange. My tests seemed to work. Make sure that you set the CBS_NOINTEGRALHEIGHT style for the combobox. Maybe you're also manipulating the combobox in the Form's CUSTOM event handler?
Try creating a sample project with just my code above to see if you can at least see the behaviour that I'm seeing.
Weird.
I have come to the conclusion that windows has a mind of it's own. GetWindowRec and SetWindowPos are what I need to solve the problem at hand, but the behavior took a while to figure out
I made a new project with just the code you posted. I confirmed that NOT checking CBS_INTREGALHEIGHT results is a way long drop-down. I re-checked that setting, then ran the program. The area of the drop-down list was shortened, and of course the number of lines displayed was a function of that area. I tried changing how nHeight was computed (/2, /3, /4,) and the area did not change. Then I got silly, and tried (* 2). Now the drop-down area was only 1 line high! Using (* 10) made the drop down area much bigger, but not as big as when CBS_NOINTREGALHEIGHT wasn't set.
Then, I experimented with hard-coding the value (100, 200, 300, 400, etc), and the drop-down area changed pretty much as expected. For my project, I can live with hard-coding the value; the behavior just strikes me as strange