1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
'-Begin-----------------------------------------------------------------
'-External functions--------------------------------------------------
Private WinAPI Function FindWindow Lib "user32.dll" _
Alias "FindWindowW" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private WinAPI Function GetWindowLong Lib "user32.dll" _
Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private WinAPI Function CreateWindowEx Lib "user32.dll" _
Alias "CreateWindowExA" (ByVal dwExStyle As Long, _
ByVal lpClassName As String, ByVal lpWindowName As String, _
ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hWndParent As Long, ByVal hMenu As Long, _
ByVal hInstance As Long, lpParam As Long) As Long
Private WinAPI Function UpdateWindow Lib "user32.dll" _
(ByVal hwnd As Long) As Long
'-Constants-----------------------------------------------------------
Private Const GWL_HINSTANCE As Long = -6
'-Function Control----------------------------------------------------
Private Function Control(ClassName As String, _
WindowName As String, Style As Long, X As Integer, Y As Integer, _
Width As Integer, Height As Integer, hWndParent As Long, _
hMenu As Long, hInstance As Long, ExtStyle As Long) As Long
Dim VarPtr As New VarPtr()
VarPtr.Init()
Dim ClientCreateStruct As Long = _
VarPtr.CreateVar("ClientCreateStruct", "Array", 8)
Control = CreateWindowEx(ExtStyle, ClassName, WindowName, _
Style, X, Y, Width, Height, hWndParent, hMenu, hInstance, _
ClientCreateStruct)
VarPtr.UnInit()
End Function
'-Main----------------------------------------------------------------
Public Sub Command1_Click()
Dim hWnd As Long = FindWindow(Null, "Jabaco Form")
If hWnd Then
Dim hInstance As Long = GetWindowLong(hWnd, GWL_HINSTANCE)
If hInstance Then
Dim hCtrl = Control("STATIC", "Test", &H50000001, 0, 100, _
300, 15, hWnd, 0, hInstance, 0)
UpdateWindow(hWnd)
End If
End If
End Sub
'-End-------------------------------------------------------------------
|