Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
Private Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
Private Const WS_CAPTION = &HC00000
Private Const WS_SIZEBOX = &H40000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const SWP_NOZORDER = &H4
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOREPOSITION = &H200
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer
Private Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
Private Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Integer
Private Declare Function MoveWindow Lib "user32" Alias "MoveWindow" (ByVal hwnd As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer) As Integer
Dim skyHwnd As Integer = FindWindow("tSkMainForm.UnicodeClass", vbNullString)
Dim lStyle As Integer
Private Structure RECT
Dim Left As Integer
Dim Top As Integer
Dim Right As Integer
Dim Bottom As Integer
End Structure
Dim ret As New RECT
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
lStyle = lStyle Or WS_SYSMENU
lStyle = lStyle Or WS_CAPTION
lStyle = lStyle Or WS_SIZEBOX
lStyle = lStyle Or WS_MAXIMIZEBOX
lStyle = lStyle Or WS_MINIMIZEBOX
SetWindowLong(skyHwnd, GWL_STYLE, lStyle)
SetParent(skyHwnd, GetDesktopWindow)
MoveWindow(skyHwnd, ret.Left, ret.Top, ret.Right - ret.Left, ret.Bottom - ret.Top, 1)
ShowWindow(skyHwnd, SW_SHOW)
End Sub
Private Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
Private Const SW_RESTORE = 9
Private Const SW_SHOW = 5
Private Const SW_SHOWNOACTIVATE = 4
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
GetWindowRect(skyHwnd, ret)
lStyle = lStyle And Not WS_SYSMENU
lStyle = lStyle And Not WS_CAPTION
lStyle = lStyle And Not WS_SIZEBOX
lStyle = lStyle And Not WS_MAXIMIZEBOX
lStyle = lStyle And Not WS_MINIMIZEBOX
SetWindowLong(skyHwnd, GWL_STYLE, lStyle)
SetParent(skyHwnd, Me.Handle.ToInt32)
MoveWindow(skyHwnd, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, 1)
ShowWindow(skyHwnd, SW_SHOW)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
If Me.WindowState <> FormWindowState.Minimized Then
MoveWindow(skyHwnd, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, 1)
End If
End Sub