hi... i've a problem with an api-call
the class should prevent the ExtCombobox from opening the dropdown-box.
The compiler doesn't accept this code because in ChangeWndPrg the AdressOf-instruction doesn't return a long value.Code:Public Class ExtComboBox Inherits ComboBox Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, ByVal lpRect As RECT) As Long Private Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Structure rect Dim Left As Long Dim Top As Long Dim Right As Long Dim Botton As Long End Structure Private Const GWL_WNDPROC = (-4) Private Const WM_CTLCOLORLISTBOX = &H134 Private lbRect As rect Private hWndLB As Long Private OldWndPrg As Long ' Subclassing einschalten Public Sub ChangeWndPrg(ByVal hwnd As Long) OldWndPrg = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WndPrg) End Sub ' Subclassing ausschalten Public Sub ResetWndPrg(ByVal hwnd As Long) SetWindowLong(hwnd, GWL_WNDPROC, OldWndPrg) End Sub Public Function WndPrg(ByVal hwnd As Long, _ ByVal uMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long If uMsg = WM_CTLCOLORLISTBOX Then ' lParam = Handler für Listbox-Window hWndLB = lParam ' Ausmasse des Windows ermitteln, das erzeugt wird GetWindowRect(hWndLB, lbRect) ' Wir verhindern damit, dass die Listbox aufgeklappt wird ' Parameter: SW_Hidde = 0& ShowWindow(hWndLB, 0&) End If ' Alle Nachrichten an die Fensterprozedur weiterleiten Return CallWindowProc(OldWndPrg, hwnd, uMsg, wParam, lParam) End Function End Class
has andybody an idea how to solve this problem?
thanks
robert




Reply With Quote