
VB.NET and Windows API Calls
you could do something like in the following code. Notice the parameter
types for the Windows API declares are Integer instead of Long (as in VB6).
Maybe this was the problem you ran into ?
The following code worked for us after we brought up a notepad window with
"notepad temp.txt".
Module Module1
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function SetWindowLong Lib "user32" Alias
"SetWindowIntegerA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal
dwNewInteger As Integer) As Integer
Public Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal
hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
Sub HostInWin32Window()
Dim winHandleParent As Integer = FindWindow(Nothing, "temp.txt -
Notepad")
Dim winHandleChild As Integer = FindWindow(Nothing, "Form1")
SetParent(winHandleChild, winHandleParent)
AppActivate("temp.txt - Notepad")
End Sub
Dim Form As New Form1()
Sub Main()
Form.Show()
HostInWin32Window()
Windows.Forms.Application.Run()
End Sub
End Module
thanks,
VB Team
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Quote:
> Hi,
> i have a newbie question:
> I try to make a Windows.Form hostet by another (old) Win32 Window. In "old
> times" i had three windows Calls
> FindWindow, SetWindowLong, and SetParent, that did the job and "included"
my
> VBA-Form into the other window.
> However allthough i have imported the Functions with dllimport-Attribute
and
> the functions work without any error message, the VB.NET Form simply
> "refuses" to be but into the other window - simply nothing happens.
> Does anybody know why ? Is this possible at all that another window (in
this
> case it is a Visio custom window) is a parent to a Windows.Form window and
> form ?
> Any ideas would be appreciated.
> --
> Regards
> Senaj Lelic
> MVP Visio