Click here to copy the following block | Public Declare 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 Any) As Long Public Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nindex As Long, ByVal dwnewlong As Long) As Long Public Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, lParam As Long) As Long Public Declare Function DefWindowProc Lib "user32.dll" Alias "DefWindowProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const WS_CHILD = &H40000000 Public Const WS_THICKFRAME = &H40000 Public Const WS_VISIBLE = &H10000000 Public Const WM_LBUTTONDOWN = &H201 Public Const WM_LBUTTONUP = &H202 Public Const GWL_WNDPROC = (-4) |
Click here to copy the following block |
Public myOldhWndProc As Long
Public Sub CreateButton(frm As Form, Caption As String, Left As Long, Top As Long, Height As Long, Width As Long, OnClick As Long, ByRef OldhWndProc As Long) Dim hWnd As Long
hWnd = CreateWindowEx(0&, "BUTTON", Caption, WS_VISIBLE Or WS_CHILD Or WS_THICKFRAME, Left, Top, Height, Width, frm.hWnd, 0&, App.hInstance, 0&) If hWnd And OnClick <> 0 Then OldhWndProc = SetWindowLong(hWnd, GWL_WNDPROC, OnClick) End If End Sub
Public Function MyWindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, lParam As Long) As Long If uMsg = WM_LBUTTONUP Then Beep End If MyWindowProc = CallWindowProc(myOldhWndProc, hWnd, uMsg, wParam, lParam) End Function |
|