fIsComboOpen fails on modal window

  • Thread starter Thread starter Atlas
  • Start date Start date
Atlas said:
The method fIsComboOpen described here
http://www.mvps.org/access/api/api0052.htm, used to check a combo box
state, fails when called from a form opened with the acWindowMode set to
acDialog .....

is there a way to fix the problem?

Function fIsComboOpen(frmName As Form) As Boolean
' returns true if a combo box on the form is dropped down
' only one combo can have the focus => only one drop down
'
Static hWnd As Long
Static p1 As Long
Static p2 As Long
Static p3 As Long
Static hWndCBX_LBX As Long

hWnd = 0: hWndCBX_LBX = 0

' Start with finding the window with "ODCombo" class name
hWnd = apiFindWindow(ACC_CBX_LISTBOX_PARENT_CLASS, vbNullString)
' Parent window of ODCombo is the Access window

p1 = apiGetParent(hWnd)
p2 = apiGetParent(frmName.hWnd)

On Local Error Resume Next
p3 = apiGetParent(frmName.Parent.hWnd)

If p1 = hWndAccessApp Or _
p2 = hWndAccessApp Or _
p3 = hWndAccessApp Then


' Child window of ODCombo window is the
' drop down listbox associated with a combobox

hWndCBX_LBX = apiGetWindow(hWnd, GW_CHILD)
' another check to confirm that we're looking at the right window
If fGetClassName(hWndCBX_LBX) = ACC_CBX_LISTBOX_CLASS Then
' Finally, if this window is visible,
If apiGetWindowLong(hWnd, GWL_STYLE) And WS_VISIBLE Then
' the Combo must be open
fIsComboOpen = True
End If
End If
Else
'MsgBox apiGetParent(hWnd) & ":" & hWndAccessApp
End If
End Function
 
Back
Top