Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the hwnd of a textbox located in a Tab Control

Status
Not open for further replies.

Draknor39

IS-IT--Management
Jan 18, 2004
24
US
I've used the following line sucessfully to retrieve the hwnd of a form where my control is located.

hwnd = ctl.Parent.hwnd

However, this line is not working if the control is located within a Tab Control. Does anyone have any ideas on how I can retrieve the hwnd value for instances where the control is in a Tab Control?

Thanks in advance.
 
Why do you think it is not working?
The code looks fine, and as far as I am aware, being on a tab will not affect the hWnd of a control.
However, when it is not visible, perhaps your subsequent API calls fail.

Does the .hWnd return a value, or 0?

What exactly fails?

 
In Access there is no property of a control called hwnd.
There is some code here that will get you the hwnd, but as it says, you can do very little with it once you've got it.
What do you need it for? What are you trying to do?

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
I should have been more specific. hwnd is a pointer to the handle of the form. I've been using the above code for sometime in my API Classes that require the value.

Whenever I use the code on a control that is embedded in a tab control it returns 0 instead of the expected long value. To workaround this I've done 1 of 2 different unelegant things. 1) I've manually passed the Me. to the class. That works fine, just not my preferred way. I've also created a function to see if the particular form in question is loaded, and if it is to manually set the reference using Forms!FormName.hwnd That also works, but is not very flexible for a class I'm going to distribute.

Basically what I really want to know is, is there a way I can check to see if the control is on a tab control and if it is how can I determine the tab controls parent using only a reference to the control.

I know I can determine if the control is on a tab control by using this line.

if(ctl.parent.controltype = 124) then
'This control is on a Tab Control

But I don't know where to go from there.

Again, thanks for your help in advance!
 
Try:
ctl.parent.parent
or
ctl.parent.control.parent

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top