And here is my example (VBS), I wish get some advice .
Option Explicit
'************************************
'* Sample GUI only with API calls *
'* Need DynamicWrapper component *
'* syntax Win NT et > *
'* highflybird March 2011 *
'************************************
' Window Messages
private Const WM_CREATE = &H1
private Const WM_DESTROY = &H2
private Const WM_MOVE = &H3
private Const WM_SIZE = &H5
private Const WM_ACTIVATE = &H6
private const WM_PAINT = &HF
private const WM_CLOSE = &H10
private const WM_QUIT = &H12
' other
Private Const DT_CENTER = &H1
Private Const DT_VCENTER = &H4
Private Const DT_SINGLELINE = &H20
Private Const CW_USEDEFAULT = &H80000000
' Create a object instance and Register some API functions
Dim DX
Set DX = CreateObject("DynamicWrapperX")
With DX
.Register "user32.dll","CreateWindowEx","i=lsslllllllll","r=l"
.Register "user32.dll","GetMessage","i=llll","r=l"
.Register "user32.dll","DispatchMessage","i=p","r=l"
.Register "user32.dll","TranslateMessage","i=p","r=l"
.Register "user32.dll","PostQuitMessage","i=l"
.Register "user32.dll","GetWindowLong","i=ll","r=l"
.Register "user32.dll","SendMessage","i=llll","r=l"
.Register "user32.dll","DefWindowProc","i=hlll","r=l"
.Register "user32.dll","SetWindowLong","i=lll","r=l"
.Register "user32.dll","GetWindowLong","i=ll","r=l"
.Register "user32.dll","SetLayeredWindowAttributes","i=hlbl","r=l"
.Register "user32.dll","BeginPaint","i=lp","r=l"
.Register "user32.dll","EndPaint","i=lp","r=l"
.Register "user32.dll","GetClientRect","i=lp","r=l"
.Register "user32.dll","DrawText","i=lslpl","r=l"
.Register "user32.dll","FillRect","i=lpl","r=l"
.Register "user32.dll","GetDC","i=l","r=l"
.Register "user32.dll","ShowWindow","i=ll","r=l"
.Register "user32.dll","UpdateWindow","i=l","r=l"
.Register "user32.dll","ReleaseDC","i=ll","r=l"
.Register "kernel32","LoadLibrary" ,"i=s" ,"r=l"
.Register "kernel32","FreeLibrary" ,"i=l" ,"r=l"
.Register "kernel32","GetProcAddress","i=ls","r=l"
.Register "MSVCR70.dll","malloc","i=l","r=l"
.Register "MSVCR70.dll","calloc","i=ll","r=l"
.Register "MSVCR70.dll","free","i=l"
.Register "gdi32.dll","CreateSolidBrush","i=l","r=l"
.Register "gdi32.dll","GetStockObject","i=l","r=l"
.Register "gdi32.dll","DeleteObject","i=l","r=l"
End With
Dim MSG
Dim ps
Dim rec
Dim FillArea
' alloc memory for pointers
MSG = DX.malloc (28) 'get a pointer for Message Struct
ps = DX.malloc(30) 'get a pointer for Paint Struct
rec = DX.malloc(16) 'get a pointer for RECT struct
FillArea = DX.calloc(4,4)
' Create a dialog
Dim hwnd
hwnd = DX.CreateWindowEx (256,"#32770","DynTest",349110272,CW_USEDEFAULT,CW_USEDEFAULT,400,300,0,0,0,0)
' Change some attributes of this window
Dim Ref
Dim pFunc
Dim ret
Dim hDC
Set Ref = GetRef("WndProc") 'Get the address of Callback function
pFunc = DX.RegisterCallback(Ref, "i=hlll", "r=l") 'the pointer of callback
ret = DX.SetWindowLong (hwnd,-4,pFunc)
ret = DX.SetWindowLong (hwnd,-20,524544) 'add a layer attribute
ret = DX.SetLayeredWindowAttributes (hwnd,0,192,2) 'transparent window
Call DX.GetClientRect(hwnd,rec) 'Get client rectangle
hDC = DX.GetDC(hwnd) 'Get a device context
Call DX.ShowWindow(hwnd,1)
Call DX.UpdateWindow(hwnd)
Call Form_Paint(DX,hDC,rec,FillArea)
' Deal with all kind of message
While DX.GetMessage (MSG,0,0,0)
DX.TranslateMessage (MSG)
DX.DispatchMessage (MSG)
Wend
' Release the device context and free memory
ret = DX.ReleaseDC(hwnd,hDC)
DX.free(MSG)
DX.free(ps)
DX.free(rec)
DX.free(FillArea) '
Set DX = nothing
Call MsgBox("Successful!",,"API in VBS")
' Callback function
Function WndProc(hwnd,umsg,wParam,lParam)
Select Case umsg
Case WM_DESTROY:
Call DX.PostQuitMessage(0)
Case WM_PAINT:
hDC= DX.BeginPaint(hwnd,ps)
Call DX.GetClientRect(hwnd,rec)
Call Form_Paint(DX,hDC,rec,FillArea)
Call DX.DrawText(hDC, "Hi,flying bird!", -1, rec, DT_SINGLELINE Or DT_CENTER Or DT_VCENTER)
Call DX.EndPaint(hwnd,ps)
Case Else:
End Select
WndProc = DX.DefWindowProc(hwnd,umsg,wParam,lParam)
End Function
' 用渐变背景绘制窗口
' A gradient window
Private Sub Form_Paint(DX,hDC,rec,FillArea)
Dim Color
Dim hBrush
Dim RetVal
Dim StepSize
Dim X
Dim ret
Dim bottom
bottom = DX.NumGet(rec,12)
StepSize = CLng(1 + bottom / 64)
Color = 255
RetVal = DX.NumPut(0,FillArea ,0)
RetVal = DX.NumGet(rec,8)
RetVal = DX.NumPut(RetVal,FillArea ,8)
RetVal = DX.NumPut(0,FillArea,4)
RetVal = DX.NumPut(StepSize,FillArea,12)
For X = 0 To 63
hBrush = DX.CreateSolidBrush(RGB(0, 255 - Color, Color))
RetVal = DX.FillRect(hDC, FillArea, hBrush)
RetVal = DX.DeleteObject(hBrush)
Color = Color - 4
If Color < 0 Then Color = 0
bottom = DX.NumGet(FillArea,12)
RetVal = DX.NumPut(bottom,FillArea,4)
RetVal = DX.NumPut(bottom+StepSize,FillArea,12)
Next
End Sub