Click to See Complete Forum and Search --> : hWnd handle of an active email object
apabros
Aug 13th, 2001, 09:34 PM
Is there anyone there who knows how to extract the window handle of an opened email object using VB6 and was created by VB6 in the 1st place. The e-mail object is in the background obviously. Can the body or subject object of an email has its own object window handle?
SoftwareMaker
Aug 14th, 2001, 12:46 AM
Win32 API provides quite a few functions to find out the Handle of a Window. It all depends on how you want to find THAT handle of the window
Below are 2 ways :
1 - Finds the Window Handle by your app sending in the Windows Caption of the Window you want and hWndWindow will return THAT window's Handle
2 - Returns the Handle of the Window which your Mouse Pointer happends to be on.
///////////////////////////////////////////////////////////////////////////
1) Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim strTitle As String
strTitle = InputBox$("Enter the Title of the Window you want to change")
hWndWindow = FindWindow(vbNullString, strTitle)
MsgBox "Handle is " & hWndWindow
2) Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
'Get Position of the Mouse
GetCursorPos Point
'WindowsFromPoint Returns the Handle of the Window Under the Mouse
WinhWnd = WindowFromPoint(Point.X, Point.Y)
txtHandle = WinhWnd
apabros
Aug 14th, 2001, 07:53 PM
Thank you for replying but there is a problem:
Solution 2 will not work:
The word document runs in the background. The email object is also created in the background. The population of the word bookmarks is done with VB6. It the same for when an e-mail is created.
For solution 1:
How do you send the window caption? Use GetWindow?
Can this API call be used to get the window handle of the EMAIL body? If it is then what is the class name of the email body? Can you suggest a good site that explains a lot about Outlook objects? I guess MSDN is a good start.
Thank you heaps.
SoftwareMaker
Aug 14th, 2001, 08:49 PM
Hi I dont know much about Outlook Objects...Outlook Express objects, however, belong to that of the Internet Browser.
As of Solution 1, you just have to enter the Caption of the Window to get the Handle...etc "Microsoft Outlook". You do not need to know the classname...just send in a vbnullstring
Let me know your email address...and I will send you a copy of a project of mine that I created to mess around with Win Handles. Take a look at the source codes and see if it helps
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.