|
-
Jul 13th, 2006, 08:50 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] [2005] can't get handle with FindWindowEx
*EDIT*
ok i figured out what was causing the problem but maybe someone could still explain to me why. i took out the Auto in the declaration then it works  so why does that matter???
**********************************
i'm using the FindWindowEx as the following
VB Code:
Public Declare Auto Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As IntPtr, _
ByVal hWnd2 As IntPtr, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As IntPtr
I know the classname and the caption of the window i'm trying to get and i'm using the following code, but it's returning zero. accroding to what i saw on different site this should work for getting the window's handle. so my question is what am i doing wrong???
VB Code:
HSEstimateMainWinHWnd = WinAPI.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "ThunderRT6MDIForm", _
"Hendrick Manufacturing Order Estimating System")
Last edited by vbdotnetboy; Jul 13th, 2006 at 09:17 AM.
Reason: confused
-
Jul 13th, 2006, 09:26 AM
#2
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
-
Jul 13th, 2006, 09:27 AM
#3
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
Why an API to get the handle?
VB Code:
Dim Notepad As Process() = Process.GetProcessesByName("notepad")
Dim NotepadPID As Integer = Notepad(0).Id
Dim NotepadHandle As IntPtr = Notepad(0).Handle
This gives the PID and the Handle of a process. Actually you can find the two things for each instance, e.g. when 2 or more notepads are opened. GetProcessesByName returns an array with the procs with the same name.
This is not really an answer to your question, I just thought you can use this instead of APIs.
Regards
-
Jul 13th, 2006, 09:28 AM
#4
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
he isn't looking for a notepad instance though.. he is looking for a VB6 form instance with a specific caption.
-
Jul 13th, 2006, 09:29 AM
#5
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
vbdotnetboy: if you leave out auto, the default is ansi, so using ansi, or leaving it out completely will do the same thing.
You should read in the MSDN help about the difference between auto and ansi and you will see why it didn't work using auto.
-
Jul 13th, 2006, 09:31 AM
#6
Thread Starter
Frenzied Member
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
 Originally Posted by kleinma
vbdotnetboy: if you leave out auto, the default is ansi, so using ansi, or leaving it out completely will do the same thing.
You should read in the MSDN help about the difference between auto and ansi and you will see why it didn't work using auto.
ok thanx kleinma... i knew i had to be something real easy that i was missing... but thanx for responding and helping me clear things up
-
Jul 13th, 2006, 09:36 AM
#7
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
 Originally Posted by kleinma
he isn't looking for a notepad instance though.. he is looking for a VB6 form instance with a specific caption.
Ah oks then. If there are two forms with the same caption, will this return the handle of the firstly opened or the secondly opened? Or will it be a random choice?
Thx.
-
Jul 13th, 2006, 09:40 AM
#8
Thread Starter
Frenzied Member
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
should be the first one in the stack... because it's going to start at desktop level and work it's way down until it finds a match.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|