SubClassing controls

  • Thread starter David De La PEÑA
  • Start date
D

David De La PEÑA

Hi,

I'm trying to subclass a LV in an Access Form.
First I use 'fGetClientHandle' function to get a handle to the client
window, but it doesnt work it returns 0!!!


Function fGetClientHandle(frm As Form) As Long
' Returns a handle to the client window of a form
' An Access form's hWnd is actually bound to the
' recordselector "window"
'

Dim hWnd As Long
Dim tmpHwnd As Long

' get the first child window of the form
hWnd = apiGetWindow(frm.hWnd, GW_CHILD)

' iterate through all child windows of the form
Do While hWnd
' if we locate the client area whose class name is "OFormSub"
If fGetClassName(hWnd) = ACC_FORM_CLIENT_CLASS Then
' the Client window's child is a window with the class
' name of OFEDT, so just verify that we're looking at the
' right window
tmpHwnd = apiGetWindow(hWnd, GW_CHILD)

fGetClientHandle = hWnd
Exit Do

If fGetClassName(tmpHwnd) = _
ACC_FORM_CLIENT_CHILD_CLASS Then
' if we found a match, then return
' the handle and we're outta here.
fGetClientHandle = hWnd
Exit Do
End If
End If
' get a handle to the next child window
hWnd = apiGetWindow(hWnd, GW_HWNDNEXT)
Loop
End Function


Any idea?

And after that how to get an hwnd of a control set in this form? How to
iterate throught them to get it?
 
M

Michel Walsh

Hi,


Most Access controls do not have a permanent hWnd, they are ... dirt...(nice dirt, but not
really much more) on the form. Once in focus, they get a temporary hWnd, but loose it after having
lost the focus. Even for controls with a permanent hWnd (sub-forms, tab control, and ActiveX, I
think, among other controls, including the hWnd of the form itself), you can do a lot with them, as
far as painting is concerned, at least.

Hoping this information can help,
Vanderghast, Access MVP
 
S

Stephen Lebans

Michel I replied to the OP in another NG.
:)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Michel Walsh said:
Hi,


Most Access controls do not have a permanent hWnd, they are ... dirt...(nice dirt, but not
really much more) on the form. Once in focus, they get a temporary
hWnd, but loose it after having
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top