[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 :confused::confused: 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??? :confused:
VB Code:
HSEstimateMainWinHWnd = WinAPI.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "ThunderRT6MDIForm", _
"Hendrick Manufacturing Order Estimating System")
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
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
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.
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.
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
Quote:
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
Re: [RESOLVED] [2005] can't get handle with FindWindowEx
Quote:
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.
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.