Hi DAW,
Currently, If the ListWidth is not set then the dbComboForm drop-down list uses the same width as the form - well that's fine unless:
1. The descriptions Or code+descriptions are longer than the form size;
2. The vertical scroll-bar appears and at times cuts off some text;
3. The control is resized by the user, where the dbComboForm reduces in width.
In all cases, the drop-down list needs to be wider than the form.
I was hoping that there would be a smarter "Auto List Width" Property in VDF17 and that I could retire my old VDF11 code to make this possible - well sort of.
Anyways, below is the code I've been using since VDF11 which does the trick.
Basically, just Set pbAutoListWidth To True
It would be nice if this was a standard feature Of dbComboForms
Code:
Class efx_dbComboForm Is a dbComboForm
Procedure Construct_Object
Forward Send Construct_Object
// Properties
{MethodType=Property Visibility=Private }
Property Integer piListWidth 0
{MethodType=Property }
Property Boolean pbAutoListWidth False
End_Procedure // Construct_Object
// this returns the width, in pixels, needed to display a string.
Function ComboGUITextWidth String sText Returns Integer
Handle hWnd hDC
Integer cx bOK
Pointer lpsText lpsPoint
String sPoint
Get Window_Handle To hWnd
Move (GetDC(hWnd)) To hDC
ZeroType tPoint To sPoint
GetAddress Of sPoint To lpsPoint
GetAddress Of sText To lpsText
Move (GetTextExtent(hDC, lpsText, Length(sText), lpsPoint)) To bOk
Move (ReleaseDC(hWnd, hDC)) To hDC
GetBuff From sPoint At tPoint.x To cx
Function_Return cx
End_Function
Procedure Activating
If (pbAutoListWidth(Self)) Set ListWidth To (piListWidth(Self))
Forward Send Activating
End_Procedure
Procedure Combo_Fill_List
Integer iItems iMax iCur
String sValue
Forward Send Combo_Fill_List
If (pbAutoListWidth(Self) and (ListWidth(Self)) <= 0) Begin
Get GuiSize to iMax
Move (Low(iMax)) to iMax
Get Combo_Item_Count to iItems
While (iItems>0)
Decrement iItems
Get Combo_Value item iItems to sValue
Get ComboGUITextWidth (Trim(sValue)) to iCur
Set piListWidth to ((iCur max iMax) max (piListWidth(Self)))
Loop
End
End_Procedure
End_Class