Link to home
Start Free TrialLog in
Avatar of avinash_sahay
avinash_sahay

asked on

Enumerating controls in a VB form in another application

I have a visual basic exe (say abc.exe) that, when launched, shows a form with various contains. Some are window controls and some are not (e.g. label).
I know the window handle  of the form. Is it possible for me to write a code in Vb (or any other language) so that I can get all the controls in the form of abc.exe?

The complete code is not required. Just some idea of how to proceed will suffice.

I do not have the access to the source code of abc.exe.

Thank you,
Avinash
Avatar of anv
anv

hi  avinash_sahay

as per me , this cannot be done...
Avatar of avinash_sahay

ASKER

I also thought the same. Then, I felt that somebody may have an idea. There is a VB application not written by me. Given any point, I have to get the details of the control at that point in the application. If the control is a window control, then it is easy. I can call the api WindowFromPoint to get the control's handle. But the application contains lots of windowless controls, e.g., labels and some third party controls. How to identify those. Msaa (Microsoft Active Accessibility) does not help.
I cannot use the answer to the PAQ. This is because that solution says how to get all window child controls. But I need to know how to get windowless controls. Or, else I need to identify a VB control at a point even if the VB control is windowless (e.g. label) and is in some other application.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
It seems that the solution will work for me. The application contains windowless controls of various types, not just label. But if I get the answer to how to get labels, I hope I will be able to do some modification, if required, to get other controls. I will try the code that you have mentioned and get back soon.
Thanks,
Avinash
I did test the code and was able to get it to work.

I'm sure the author spent much time using trial and error to get this work as such low level things are undocumented.

Good Luck,

Idle_Mind
It works on a sample vb application but not on the exe on which I want it to work.
When
lPtr = InStrB(1, abBuffer, StrConv(VBObjectIDString, vbFromUnicode)) - 1

is executed, it returns lPtr = -1

I am not able to understand why.
I have NO idea how this code works.

Idle_Mind
What you have given is something that I did not know. I will try to find out why it is failing for this exe.
I was wondering if it could somehow be possible to get the form object itself.