Connecting Tech Pros Worldwide Help | Site Map

Getting the hwnd property of a control

mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 614
#1: Oct 8 '09
Is it possible to get the hwnd property (ie: long number) of a control on a form.

For instance I would like to get the hwnd property of a text box that has focus. I can get the form hwnd property but I need an actual control on the form.

Can this be done in VBA and if so can someone show me an example syntax.

cheers,
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 614
#2: Oct 8 '09

re: Getting the hwnd property of a control


Actually I may have found a solution thanks to Dev Ashish the Access Guru.

This may be my solution.

He explains why it cannot be done directly in VBA but a nice work around.

I will let you know if this works so nobody wastes time responding to this post.

cheers,
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,672
#3: Oct 8 '09

re: Getting the hwnd property of a control


It depends on what you want to do with it. I expect the facilities are limited, but it's the best you'll get. If you can't do what you need with this, then I doubt there'll be a way.
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,212
#4: Oct 9 '09

re: Getting the hwnd property of a control


Quote:

Originally Posted by mshmyob View Post

Actually I may have found a solution thanks to Dev Ashish the Access Guru.

This may be my solution.

He explains why it cannot be done directly in VBA but a nice work around.

I will let you know if this works so nobody wastes time responding to this post.

cheers,

Just for curiosity, mshmyob, what in the world are you going to do with the hWnd for an Access Control?
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#5: Oct 9 '09

re: Getting the hwnd property of a control


Hi, mshmyob.

I guess the following tool could be helpful in your research.
Winspector - Ultimate Windows Message Spy
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 614
#6: Oct 9 '09

re: Getting the hwnd property of a control


Quote:

Originally Posted by ADezii View Post

Just for curiosity, mshmyob, what in the world are you going to do with the hWnd for an Access Control?

Top Secret :).

If you must know it is to give ChipR a solution for his memo field scroll bar position problem.

I currently have it almost working using API's. I am just testing and fine tuning it now and will upload it to ChipR when I am finished.

I have it changing the scrollbox position whenever regaining focus to his memo field. Now all I need to do is actually reposition the data in the control.

But since I am a complete novice when it comes to API's it is taking me time but I am learning alot.

cheers,
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 614
#7: Oct 9 '09

re: Getting the hwnd property of a control


Quote:

Originally Posted by FishVal View Post

Hi, mshmyob.

I guess the following tool could be helpful in your research.
Winspector - Ultimate Windows Message Spy

Thanks Fish. The getfocus API works like a charm for me but I will look into this tool to see if I can learn anything from it.

cheers,
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,672
#8: Oct 9 '09

re: Getting the hwnd property of a control


Quote:

Originally Posted by mshmyob View Post

Top Secret :).

If you must know it is to give ChipR a solution for his memo field scroll bar position problem.

LOL. Good for you Mshmyob :)
mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 614
#9: Oct 10 '09

re: Getting the hwnd property of a control


You can see why I wanted this info here. Post #9.

cheers,
Reply