Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving an object's handle

Status
Not open for further replies.

VB400

Programmer
Sep 8, 1999
359
US
From a class object, is there a way to retrieve the handle of the specific instance that is running? For example, I have a class module called clsABC. In another part of the application I do the following:<br>
<br>
set x = New clsABC<br>
<br>
I would like to be able to retrieve the handle of this new instance of clsABC.<br>
<br>
There is an API called GetHandleInformation but I can't seem to find any documentation on it (only C++ references but not VB) and I don't kno how to use it.<br>
<br>
Can anyone help!
 
I have this code in a folder not sure if it will do want you want.<br>
----------------------<br>
Declare Function FindWindow& Lib &quot;user32&quot; Alias &quot;FindWindowA&quot; (ByVal _<br>
lpClassName As String, ByVal lpWindowName As String)<br>
Declare Function SetWindowPos& Lib &quot;user32&quot; (ByVal hwnd As Long, ByVal _<br>
hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, _<br>
ByVal cy As Long, ByVal wFlags As Long)<br>
<br>
Global Const HWND_TOPMOST = -1<br>
Global Const SWP_SHOWWINDOW = &H40<br>
<br>
Sub Test()<br>
If FindWindow(&quot;OpusApp&quot;, vbNullString) = 0 Then<br>
Shell &quot;WinWord&quot;, vbNormalFocus: DoEvents<br>
End If<br>
<br>
Do<br>
Loop Until FindWindow(&quot;OpusApp&quot;, vbNullString) &lt;&gt; 0<br>
<br>
hwnd& = FindWindow(&quot;OpusApp&quot;, vbNullString)<br>
nReturn = SetWindowPos(hwnd&, HWND_TOPMOST, 0, 0, 640, 480, _<br>
SWP_SHOWWINDOW)<br>
End Sub <br>
-------------<br>
My guess is replace OpusApp withyour app name<br>
<br>

 
Thanks Doug,<br>
<br>
I don't think that I can use this code as it pertains to retrieving a handle for a window. In my case, the handle I'm trying to retrieve is for a &quot;Business Object&quot; type class (i.e. no UI is displayed).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top