Access ListBox hwnd Property

  • Thread starter Thread starter Damien
  • Start date Start date
D

Damien

Access ListBoxes don't have the hwnd Property like VB ones
do. Does anyone know how to get it as I'd like to use
some API calls in my ListBox class.

Thanks


Damien
 
None of the controls have a handle. They are created and destroyed at
runtime, and ms-access simply "paints" the screen. So, each form has a
handle, but each control does not.

You might mention what you are trying to do with the listbox.
 
Not to worry Albert, I've done it the 'hard way'!
Basically I'm building up my custom ListBox class.

Thanks anyway.


Damien

Public Function ItemExists(item_name) As Boolean
'Confirm if given item exists in first column of ListBox

On Error GoTo ItemExists_Err

Dim i As Long

' Loop thru all items
For i = 0 To mListBox.ListCount - 1
If mListBox.ItemData(i) = item_name Then
ItemExists = True
Exit For
End If
Next

ItemExists_Exit:
Exit Function

ItemExists_Err:

Select Case Err
Case Else
ReportError "clsListBox", "ItemExists", "Error
testing if item exists:", True, False, "ListBox",
mListBox.Name, "Item", item_name
End Select

Resume ItemExists_Exit

End Function


''VB6
'Public Function ItemExists(item_name) As Boolean
'
' Dim lngResult As Long
'
' lngResult = SendMessageFind(mListBox.hWnd,
LB_FINDSTRING, 0, item_name)
'
' If lngResult = LB_ERR Then
' 'Item not found
' Else
' ItemExists = True
' End If
'
'End Function



Private Sub Class_Terminate()
'Set mListBox = Nothing
End Sub
 
Hi Albert,
The List and Combo controls do have permanent window handles(hWnd's) for
the Life of the form. The simplest method to find them is to use the
SetFocus API. Unfortunately there are some problems/issues with doing
this in the form's Load event. THere is code in several projects of mine
that show how to find the hWnd for these controls without having to use
the SetFocus API.
See:
http://www.lebans.com/tooltip.htm
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Hi Albert,
The List and Combo controls do have permanent window handles(hWnd's) for
the Life of the form.

That is interesting. Thanks:

I kind of thought that the handles where created as the form is used, but I
was not sure that you could reliability use them at all...
 
Back
Top