I told about somethink like this
Code:
#Compile Exe #Register None #Dim All #Include "win32api.INC" CallBack Function DlgProc Static hFont As Long Local El As Asciiz * 256, lpSize As SizeL, cxx As Long, i As Long, _ hWndCmb As Long, hdc As Long Select Case CbMsg Case %WM_INITDIALOG Control Add ComboBox, CbHndl, 100, , 5, 5, 50, 150, _ %CBS_AUTOHSCROLL Or %CBS_DROPDOWNLIST Or %WS_TABSTOP Or %WS_VSCROLL hWndCmb = GetDlgItem(CbHndl, 100) hDC = GetDC(hWndCmb) hFont = CreateFont(-15, 0, 0, 0, %FW_NORMAL, 0, 0, 0, _ %ANSI_CHARSET, %OUT_TT_PRECIS, %CLIP_DEFAULT_PRECIS, _ %DEFAULT_QUALITY, %FF_DONTCARE, "Arial") SelectObject hDC, hFont SendMessage hWndCmb, %WM_SETFONT, hFont, 0 cxx = 0 For i = 20 To 1 Step -1 El = "# " + Str$(i) + " " + String$(i, "a") + " |" GetTextExtentPoint32 hdc, El, Len(El), lpSize cxx = Max(cxx, lpSize.cx) ComboBox Add CbHndl, 100, El Next SendMessage hWndCmb, %CB_SETDROPPEDWIDTH, _ cxx + GetSystemMetrics(%SM_CXVSCROLL)+ 2 * GetSystemMetrics(%SM_CXDLGFRAME), 0 ReleaseDC hWndCmb, hDC Case %WM_DESTROY DeleteObject hFont End Select End Function Function PbMain Local hDlg As Long Dialog New 0, "", ,, 300, 200, %WS_CAPTION Or %WS_SYSMENU To hDlg Dialog Show Modal hDlg Call DlgProc End Function
Leave a comment: