FindWindowEx - panel issues I think

  • Thread starter Thread starter kru
  • Start date Start date
K

kru

Hi All,

I've been trying to get FindWindowEx to work to locate a button, and
am stumped on the following:

The structure of the external app is as so from Spy++:

- "Main Window" - ThunderRT6FrmDC
- "" - ThunderRT6Frame (outer panel)
- "" - ThunderRT6Frame (inner panel)
- "&Feedback" - ThunderRT6CommandButton (button within
2 panels)

This is my code so far:

Dim parentHnd as New IntPtr = FindWindow("ThunderRT6FormDC", "Main
Window")
Dim bigcontainerHnd As IntPtr = FindWindowEx(parentHnd, IntPtr.Zero,
"ThunderRT6Frame", "")
Dim smlcontainerHnd As IntPtr = FindWindowEx(bigcontainerHnd,
IntPtr.Zero, "ThunderRT6Frame", "")
Dim feedbackBtnHnd = FindWindowEx(smlcontainerHnd, IntPtr.Zero,
"ThunderRT6CommandButton", "&Feedback")

I can get handle results for the parentHnd and also the first panel
bigcontainerHnd however get 0's for the smalcontainerHnd and the
feedbackBtnHnd, can anyone see what I'm doing wrong in the above code?

Many thanks,
Kru
 
kru said:
Hi All,

I've been trying to get FindWindowEx to work to locate a button, and
am stumped on the following:

The structure of the external app is as so from Spy++:

- "Main Window" - ThunderRT6FrmDC
- "" - ThunderRT6Frame (outer panel)
- "" - ThunderRT6Frame (inner panel)
- "&Feedback" - ThunderRT6CommandButton (button within
2 panels)

This is my code so far:

Dim parentHnd as New IntPtr = FindWindow("ThunderRT6FormDC", "Main
Window")
Dim bigcontainerHnd As IntPtr = FindWindowEx(parentHnd, IntPtr.Zero,
"ThunderRT6Frame", "")
Dim smlcontainerHnd As IntPtr = FindWindowEx(bigcontainerHnd,
IntPtr.Zero, "ThunderRT6Frame", "")
Dim feedbackBtnHnd = FindWindowEx(smlcontainerHnd, IntPtr.Zero,
"ThunderRT6CommandButton", "&Feedback")

Not the real code, is it? Can't compile it. Nevertheless, after changing
it...
I can get handle results for the parentHnd and also the first panel
bigcontainerHnd however get 0's for the smalcontainerHnd and the
feedbackBtnHnd, can anyone see what I'm doing wrong in the above
code?

....it works here. I created a VB6 application using this control structure,
and I get 4 valid handles. Are you sure the Caption is really "" for the
frames? Maybe it's a blank?


Armin
 
Hi All,

I've been trying to get FindWindowEx to work to locate a button, and
am stumped on the following:

The structure of the external app is as so from Spy++:

- "Main Window" - ThunderRT6FrmDC
- "" - ThunderRT6Frame (outer panel)
- "" - ThunderRT6Frame (inner panel)
- "&Feedback" - ThunderRT6CommandButton (button within
2 panels)

This is my code so far:

Dim parentHnd as New IntPtr = FindWindow("ThunderRT6FormDC", "Main
Window")
Dim bigcontainerHnd As IntPtr = FindWindowEx(parentHnd, IntPtr.Zero,
"ThunderRT6Frame", "")
Dim smlcontainerHnd As IntPtr = FindWindowEx(bigcontainerHnd,
IntPtr.Zero, "ThunderRT6Frame", "")
Dim feedbackBtnHnd = FindWindowEx(smlcontainerHnd, IntPtr.Zero,
"ThunderRT6CommandButton", "&Feedback")

I can get handle results for the parentHnd and also the first panel
bigcontainerHnd however get 0's for the smalcontainerHnd and the
feedbackBtnHnd, can anyone see what I'm doing wrong in the above code?

Many thanks,
Kru

You may want to revise and take a look at pinvoke.net:

http://www.pinvoke.net/default.aspx/user32/FindWindowEx.html
 
Not the real code, is it? Can't compile it. Nevertheless, after changing
it...


...it works here. I created a VB6 application using this control structure,
and I get 4 valid handles. Are you sure the Caption is really "" for the
frames? Maybe it's a blank?

Armin

Hi Armin thanks for the reply.

Yep that was a portion of the real code, following that code I just
used msgbox's to check for handles. This is part of a VB.NET
application I'm modifying.

Using the Spy++ tree structure it shows the captions as being "",
however I think it showed nothing when I used the target tool (not at
work currently). When I get in tomorrow I will give vbstringnull a try
though I'm not sure if it will make a difference but worth a shot.

Thanks again
 
Hi Armin thanks for the reply.

Yep that was a portion of the real code, following that code I just
used msgbox's to check for handles. This is part of a VB.NET
application I'm modifying.

Using the Spy++ tree structure it shows the captions as being "",
however I think it showed nothing when I used the target tool (not at
work currently). When I get in tomorrow I will give vbstringnull a try
though I'm not sure if it will make a difference but worth a shot.

Thanks again- Hide quoted text -

- Show quoted text -

I've tried using vbNullString in the 4th argument and it hasn't
worked. I think you are correct with the captions being blank however
I'm still getting no handle result for the second inner panel.

My declarations:

Private Declare Auto Function FindWindow Lib "user32" (ByVal
lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Auto Function FindWindowEx Lib "user32" (ByVal
hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal
lpsz2 As String) As IntPtr


This is my exact code placed within a button click:

Dim parentHnd As IntPtr = FindWindow("ThunderRT6FormDC", "Main
Window")
Dim bigcontainerHnd As IntPtr = FindWindowEx(parentHnd,
IntPtr.Zero, "ThunderRT6Frame", vbNullString)
Dim smlcontainerHnd As IntPtr = FindWindowEx(bigcontainerHnd,
IntPtr.Zero, "ThunderRT6Frame", vbNullString)
Dim feedbackBtnHnd As IntPtr = FindWindowEx(smlcontainerHnd,
IntPtr.Zero, "ThunderRT6CommandButton", "&Feedback")

MsgBox(parentHnd) - returns a non 0
MsgBox(bigcontainerHnd) - returns a non 0
MsgBox(smlcontainerHnd) - returns 0
MsgBox(feedbackBtnHnd) - reutrns 0

If anyone else has any ideas on what I'm doing incorrectly let me know
please, thank you kindly.

- Kru
 
Thanks kimi, the only difference from the code at pinvoke and mine
appears to be the last argument IntPtr.Zero, I'll try IntPtr.Zero
instead when I get to work however I think I have tried that also.

Thanks for the response & best of luck this season!- Hide quoted text -

- Show quoted text -

No luck with IntPtr.Zero either for the 4th argument for FindWindowEx
hmm
 
Back
Top