Aurel, it can also be done without classes.
'micro.inc by Aurel
'Last Modified:
'2012.july,29
'myWin variables have a "m" prefix for them
'Parameters/Arguements have an "a" prefix for arguement
#lookahead
Type WNDCLASS
'cbSize as long
Style as long
lpfnwndproc as long
cbClsextra as long
cbWndExtra as long
hInstance as long
hIcon as long
' hIconSm AS long
hCursor as long
hbrBackground as long
lpszMenuName as long
lpszClassName as long
End Type
Type LARGE_INTEGER
lowpart AS INT
highpart AS INT
End Type
Type PointApi
x as long
y as long
End Type
Type MSG
hwnd as long
message as long
wParam as long
lParam as long
time as long
pt as PointApi
End Type
Type RECT
Left as Long
Top as Long
Right as Long
Bottom as Long
End Type
% CS_DBLCLKS = 0x8
% CS_OWNDC = 32
% SW_SHOW = 5
% PM_REMOVE = 1
% PM_NOREMOVE = 0
% IDI_APPLICATION = 32512
% IDC_ARROW = 32512
% WM_SETICON = &H80
% WM_KILLFOCUS = 0x8
% WM_CREATE = 1
% WM_DESTROY = 2
% WM_PAINT = 15
% WM_QUIT = 18
% WM_SIZE = 5
% WM_MOVE = 3
% WM_CHAR = 258
% WM_KEYLAST = &H108
% WM_KEYFIRST = &H100
% WM_KEYDOWN = 256
% WM_MOUSEMOVE = 512
% WM_MBUTTONDOWN = 519
% WM_LBUTTONDOWN = 513
% WM_RBUTTONDOWN = 516
% WM_LBUTTONUP = 514
% WM_RBUTTONUP = 517
% WM_MBUTTONUP = 520
% WM_TIMER = 275
% WM_WINDOWPOSCHANGED = &H47
% WM_NOTIFY = 0x004E
% WM_SETFONT = &H30
% WM_COMMAND = 0x111
% BN_CLICKED = 0
% WM_PARENTNOTIFY = 0x210
% WM_SETTEXT = &HC
% WM_GETTEXT = 0xD
% WS_CLIPSIBLINGS = 0x4000000
% WS_CLIPCHILDREN = 0x2000000
% WS_SYSMENU = 524288
% WS_THICKFRAME = 0x40000
% WS_CAPTION = 0xC00000
% WS_OVERLAPPED = 0x0
% WS_MINMAXSIZE =
% WS_POPUP = 0x80000000
% WS_DLGFRAME = 0x400000
% WS_MAXIMIZE = &H1000000
% WS_MINIMIZEBOX = &H20000
% WS_MAXIMIZEBOX = 0x10000
% WS_BORDER = &H800000
% WS_CHILD = 0x40000000
% WS_VISIBLE = 0x10000000
% WS_VSCROLL = 0x200000
% WS_HSCROLL = 0x100000
'minmaxsize-> overlappedwindow
% WS_MINMAXSIZE =(WS_OVERLAPPED Or WS_VISIBLE Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
Dim kernel32,user32,gdi32,riched32
kernel32 = LoadLibrary "kernel32.dll"
user32 = LoadLibrary "user32.dll"
gdi32 = LoadLibrary "gdi32.dll"
riched32 = LoadLibrary "riched32.dll"
Bind kernel32
(
GetCommandLine GetCommandLineA
GetModuleHandle GetModuleHandleA
ExitProcess ExitProcess
sleep Sleep
Beep Beep
)
Bind user32
(
LoadIcon LoadIconA
LoadCursor LoadCursorA
RegisterClass RegisterClassA
RegisterClassEx RegisterClassExA
MessageBox MessageBoxA
SendMessage SendMessageA
GetMessage GetMessageA
PeekMessage PeekMessageA
TranslateMessage TranslateMessage
DispatchMessage DispatchMessageA
PostQuitMessage PostQuitMessage
PostMessage PostMessageA
CreateWindowEx CreateWindowExA
ShowWindow ShowWindow
UpdateWindow UpdateWindow
DefWindowProc DefWindowProcA
InvalidateRect InvalidateRect
ValidateRect ValidateRect
GetSystemMetrics GetSystemMetrics
ReleaseDC ReleaseDC
GetDC GetDC
BeginPaint BeginPaint
EndPaint EndPaint
ShowCursor ShowCursor
GetAsyncKeyState GetAsyncKeyState
)
Bind gdi32
(
GetStockObject GetStockObject
CreateSolidBrush CreateSolidBrush
SetBkMode SetBkMode
SetBkColor SetBkColor
)
declare sub input()
'define Msg,Class & ClassEx //////////////////////////////////
Dim wm as MSG
Dim rc as RECT
Dim wcx as WndClass
'--------------------------------------------------------------------
Type TWINDOW
sys aw
sys ah
string aCaption
sys mWidth
sys mHeight
sys mLeft
sys mTop
string mCaption
string mClassName
sys mhInstance
sys mStyle
sys mHwnd
sys mIsActive
sys mIsRunning
sys mMsg
End Type
'--------------------------------------------------------------------
TWINDOW win
static tWindow, win
tWindow = @this
win = @WindowProc#sys#sys#sys#sys
'---------------------------------------------------------------------
FUNCTION WindowProc( sys mhwnd, uMsg, wParam, lParam ) as sys callback
' RETURN DefWindowProc hWnd, uMsg, wParam, lParam
Return CALL Win(tWindow,mhWnd, uMsg, wParam, lParam )
END FUNCTION
'-------------------------------------------------------------------
Function MakeWindow(
sys aw=800,
sys ah=600,
string aCaption = "Oxygen Window"
)
win.mWidth = aw
win.mHeight = ah
win.mLeft = 0
win.mTop = 0
win.mCaption = aCaption
win.mClassName = "OxygenWindow"
win.mhInstance = GetModuleHandle 0
'
WNDCLASS winClass
winClass.style = CS_OWNDC | CS_DBLCLKS
winClass.lpfnWndProc = &WindowProc
winClass.cbClsExtra = 0
winClass.cbWndExtra = 0
winClass.hInstance = win.mhInstance
winClass.hIcon = LoadIcon 0, IDI_APPLICATION
winClass.hCursor = LoadCursor 0, IDC_ARROW
winClass.hbrBackground = 0
winClass.lpszMenuName = 0
winClass.lpszClassName = win.mClassName
if not RegisterClass(winClass) then
'error
MessageBox 0, "RegisterClass", "ERROR", 32
return 0
end if
win.mStyle = WS_MINMAXSIZE
'win.mWindowRect <= 0, 0, win.mWidth, win.mHeight
win.mhWnd = CreateWindowEx( 0,
win.mClassName,
"Oxygen Window", 'win.mCaption,
WS_MINMAXSIZE, 'win.mStyle,
win.mLeft,
win.mTop,
win.mWidth ,
win.mHeight,
0,
0,
win.mhInstance,
0
)
if not win.mhWnd then
'Error
MessageBox NULL, "CreateWindowEx:", "ERROR",32
return 0
end if
win.mIsActive = 1
win.mIsRunning = 1
ShowWindow win.mhWnd, SW_SHOW
UpdateWindow win.mhWnd
return win.mhWnd
end function
sub MessageLoop()
while win.mIsRunning
' win.mMenuCommand = NULL
while PeekMessage win.mMSG, NULL, 0, 0, PM_REMOVE
TranslateMessage win.mMSG
DispatchMessage win.mMSG
wend
input()
wend
end sub
#include "micro.inc"
MakeWindow (800, 600, "Simple Window")
MessageLoop()
sub input()
select &wm
case 0
exit sub
case WM_DESTROY
PostQuitMessage 0
end select
end sub
'window.inc by Kent Sarikaya
'Last Modified:
'2012.07.27 KS
'myWin variables have a "m" prefix for them
'Parameters/Arguements have an "a" prefix for arguement
include "MinWin.inc"
declare sub OnClose(sys hwnd)
type tWindow
sys mTop, mLeft, mWidth, mHeight
string mCaption, mClassName
sys mMenuCommand
sys mMouseX, mMouseY, mMouseButton, mKeydown
sys mChangeSize, mIsActive, mIsRunning
sys mKeys[256]
sys mhInstance, mhDC, mhWnd
RECT mWindowRect
MSG mMSG
sys mExStyle, mStyle
end type
dim win as tWindow
function WindowProc(sys hwnd, uMsg, wParam, lParam ) as sys callback
select uMsg
'onClose------------
case WM_DESTROY
IF hwnd<>0
OnClose(hwnd)
END IF
return 0
'-----------------
end select
'default.............................................
return DefWindowProc hWnd, uMsg, wParam, lParam
'....................................................
end function
function MakeWindow(sys aWidth, aHeight, string aCaption) as sys
win.mWidth = aWidth
win.mHeight = aHeight
win.mLeft = 0
win.mTop = 0
win.mCaption = 0 'aCaption
win.mClassName = strptr "OxygenWindow"
win.mWindowRect.left = win.mLeft
win.mWindowRect.right = win.mWidth
win.mWindowRect.top = win.mTop
win.mWindowRect.bottom = win.mHeight
win.mhInstance = GetModuleHandle 0
'
WNDCLASS winClass
winClass.style = CS_HREDRAW | CS_VREDRAW
winClass.lpfnWndProc = @WindowProc
winClass.cbClsExtra = 0
winClass.cbWndExtra = 0
winClass.hInstance = win.mhInstance
winClass.hIcon = LoadIcon 0, IDI_WINLOGO
winClass.hCursor = LoadCursor 0, IDC_ARROW
winClass.hbrBackground = GetStockObject WHITE_BRUSH 'NULL
winClass.lpszMenuName = 0
winClass.lpszClassName = StrPtr "win"
RegisterClass &winClass
win.mStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
win.mWindowRect <= 0, 0, win.mWidth, win.mHeight
win.mhWnd = CreateWindowEx 0,"win"," Peter",WS_OVERLAPPEDWINDOW,0,0,640,480,0,0,win.mhInstance,0
win.mIsActive = 1
win.mIsRunning = 1
ShowWindow win.mhWnd, SW_SHOW
UpdateWindow win.mhWnd
return win.mhWnd
end function
sub MessageLoop()
MSG wm
'while win.mIsRunning
'win.mMenuCommand = 0
if @wm > 0
'input()
while GetMessage(&wm, 0, 0, 0)<>0
TranslateMessage &wm
DispatchMessage &wm
wend
end if
end sub
function GetWidth() as sys
return win.mWidth
end function
function GetHeight() as sys
return win.mHeight
end function
function KeyEvent() as sys 'read once and clear
return win.mKeydown
win.mKeydown = 0 '<-- That is nonsens here!
end function
function MenuDown( WORD ID ) as sys
if win.mMenuCommand = ID then return 1
end function
function KeyDown( sys ucKey ) as sys
if win.mKeys[ucKey] then return 1
end function
function KeyUp( sys ucKey ) as sys
if win.mKeys[ucKey] = 0 then return 1
end function
function MouseDown( sys button ) as sys
if win.mMouseButton and button then return 1
end function
function MouseUp( sys button ) as sys
if ( win.mMouseButton xor -1 ) and button then return 1
end function
'test window.o2bas
'by Kent Sarikaya 2012 July
'modifyed by Peter Wirlauber
'and modifyed by Aurel
include "window.inc"
! Beep Lib "kernel32.dll" (sys dwFreq, dwDuration) As sys
sys win
win = MakeWindow 800, 600, "Test OnClose()"
MessageLoop()
SUB OnClose(win)
Beep 1200,100
print "Thanks..."
Return PostQuitMessage 0
END SUB
Ok this version is lean, mean and clean and setup to handle anything you want Aurel.
Function WndProc(byval hWnd as long,byval wMsg as long, byval wParam as long,byval lparam as long) as long callback
SELECT wMsg
'----------------------------
CASE WM_DESTROY
PostQuitMessage 0
'------------------------------------------
case WM_SIZE
GetSize(win,x,y,w,h)
MoveWindow(richedit1,160,80,(w-rw/2)+64,(h-56)-32 ,1)
MoveWindow(edit1,160,54,(w-rw/2)+64,23 ,1)
'-------------------------------------------------------------
CASE WM_COMMAND
controlID = LoWord(wParam) 'get control ID
notifyCode = HiWord(wParam) 'get notification message
Select controlID
CASE b0ID
If notifycode=0
SendMessage richedit1,WM_SETTEXT,0,""
End If
CASE b1ID
If notifycode=0
doOpen()
End If
CASE b2ID
If notifycode=0
UpdateWindow(win)
SetControlText()
End If
CASE b3ID
If notifycode=0
LoadFromFile()
End If
CASE b4ID
If notifycode=0
GetLineCount()
End If
CASE b5ID
If notifycode=0
GetCSize()
End If
End Select
'-----------------------------------------------------
END SELECT
function TForm.WindowProc(hDlg as hwnd,Msg as uint,wParam as wparam,lParam as lparam) as integer
dim as TWinControl ptr WinControl = iif(CreationData, CreationData, GetWinControl(hDlg))
dim as TMessage message = type(hDlg,Msg,wParam,lParam,0,WinControl)
if WinControl then
WinControl->ProcessMessage(message)
cast(TForm ptr,WinControl)->ProcessMessage(message)
return message.result
end if
return message.result
end function
function TForm.ClientWindowProc(hDlg as hwnd,Msg as uint,wParam as wparam,lParam as lparam) as integer
dim as TWinControl ptr WinControl = iif(CreationData, CreationData, GetWinControl(hDlg))
dim as TMessage message = type(hDlg,Msg,wParam,lParam,0,WinControl)
if WinControl then
WinControl->ProcessMessage(message)
dim as WndClassEx wc
wc.cbSize = sizeof(wc)
if GetClassInfoEx(0,"MDIClIENT",@wc) then
message.result = CallWindowProc(wc.lpfnWndProc,message.Handle,message.Msg,message.wParam,message.lParam)
end if
return message.result
end if
return message.result
end function
Can you tell me what it is supposed to do
'This project needs one form
' Also set StartupObject to 'Sub Main'
' original from VB6
Type WNDCLASS
style As Long
lpfnwndproc As Long
cbClsextra As Long
cbWndExtra2 As Long
hInstance As Long
hIcon As Long
hCursor As Long
hbrBackground As Long
lpszMenuName As String
lpszClassName As String
End Type
Type POINTAPI
x As Long
y As Long
End Type
Type Msg
hWnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
' Class styles
Public Const CS_VREDRAW = &H1
Public Const CS_HREDRAW = &H2
Public Const CS_KEYCVTWINDOW = &H4
Public Const CS_DBLCLKS = &H8
Public Const CS_OWNDC = &H20
Public Const CS_CLASSDC = &H40
Public Const CS_PARENTDC = &H80
Public Const CS_NOKEYCVT = &H100
Public Const CS_NOCLOSE = &H200
Public Const CS_SAVEBITS = &H800
Public Const CS_BYTEALIGNCLIENT = &H1000
Public Const CS_BYTEALIGNWINDOW = &H2000
Public Const CS_PUBLICCLASS = &H4000
' Window styles
Public Const WS_OVERLAPPED = &H0&
Public Const WS_POPUP = &H80000000
Public Const WS_CHILD = &H40000000
Public Const WS_MINIMIZE = &H20000000
Public Const WS_VISIBLE = &H10000000
Public Const WS_DISABLED = &H8000000
Public Const WS_CLIPSIBLINGS = &H4000000
Public Const WS_CLIPCHILDREN = &H2000000
Public Const WS_MAXIMIZE = &H1000000
Public Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME
Public Const WS_BORDER = &H800000
Public Const WS_DLGFRAME = &H400000
Public Const WS_VSCROLL = &H200000
Public Const WS_HSCROLL = &H100000
Public Const WS_SYSMENU = &H80000
Public Const WS_THICKFRAME = &H40000
Public Const WS_GROUP = &H20000
Public Const WS_TABSTOP = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_TILED = WS_OVERLAPPED
Public Const WS_ICONIC = WS_MINIMIZE
Public Const WS_SIZEBOX = WS_THICKFRAME
Public Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
Public Const WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
Public Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
Public Const WS_CHILDWINDOW = (WS_CHILD)
' ExWindowStyles
Public Const WS_EX_DLGMODALFRAME = &H1&
Public Const WS_EX_NOPARENTNOTIFY = &H4&
Public Const WS_EX_TOPMOST = &H8&
Public Const WS_EX_ACCEPTFILES = &H10&
Public Const WS_EX_TRANSPARENT = &H20&
' Color constants
Public Const COLOR_SCROLLBAR = 0
Public Const COLOR_BACKGROUND = 1
Public Const COLOR_ACTIVECAPTION = 2
Public Const COLOR_INACTIVECAPTION = 3
Public Const COLOR_MENU = 4
Public Const COLOR_WINDOW = 5
Public Const COLOR_WINDOWFRAME = 6
Public Const COLOR_MENUTEXT = 7
Public Const COLOR_WINDOWTEXT = 8
Public Const COLOR_CAPTIONTEXT = 9
Public Const COLOR_ACTIVEBORDER = 10
Public Const COLOR_INACTIVEBORDER = 11
Public Const COLOR_APPWORKSPACE = 12
Public Const COLOR_HIGHLIGHT = 13
Public Const COLOR_HIGHLIGHTTEXT = 14
Public Const COLOR_BTNFACE = 15
Public Const COLOR_BTNSHADOW = 16
Public Const COLOR_GRAYTEXT = 17
Public Const COLOR_BTNTEXT = 18
Public Const COLOR_INACTIVECAPTIONTEXT = 19
Public Const COLOR_BTNHIGHLIGHT = 20
' Window messages
Public Const WM_NULL = &H0
Public Const WM_CREATE = &H1
Public Const WM_DESTROY = &H2
Public Const WM_MOVE = &H3
Public Const WM_SIZE = &H5
' ShowWindow commands
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_NORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
Public Const SW_SHOWDEFAULT = 10
Public Const SW_MAX = 10
' Standard ID's of cursors
Public Const IDC_ARROW = 32512&
Public Const IDC_IBEAM = 32513&
Public Const IDC_WAIT = 32514&
Public Const IDC_CROSS = 32515&
Public Const IDC_UPARROW = 32516&
Public Const IDC_SIZE = 32640&
Public Const IDC_ICON = 32641&
Public Const IDC_SIZENWSE = 32642&
Public Const IDC_SIZENESW = 32643&
Public Const IDC_SIZEWE = 32644&
Public Const IDC_SIZENS = 32645&
Public Const IDC_SIZEALL = 32646&
Public Const IDC_NO = 32648&
Public Const IDC_APPSTARTING = 32650&
Public Const GWL_WNDPROC = -4
'---- Declarations
Declare Function RegisterClass Lib "user32" Alias "RegisterClassA" (wc As WNDCLASS) As Long
Declare Function UnregisterClass Lib "user32" Alias "UnregisterClassA" (ByVal lpClassName As String, ByVal hInstance As Long) As Long
Declare Function CreateWindowEx Lib "user32" 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
Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Sub PostQuitMessage Lib "user32" (ByVal nExitCode As Long)
Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function TranslateMessage Lib "user32" (lpMsg As Msg) As Long
Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As Msg) As Long
Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
Declare Function DefMDIChildProc Lib "user32" Alias "DefMDIChildProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
' Define information of the window (pointed to by hWnd)
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim wndcls As WNDCLASS
'look forward
#lookahead
Dim hwnd2 As Long, hwnd3 As Long, old_proc As Long, new_proc As Long
Public Sub Main()
Dim lngTemp As Long
' Register class
If MyRegisterClass Then
' Window created?
If MyCreateWindow Then
' Change the button's procedures
' Point to new address
new_proc = GetMyWndProc(@ButtonProc)
old_proc = SetWindowLong(hwnd2, GWL_WNDPROC, new_proc)
' Message loop
MyMessageLoop
End If
' Unregister Class
MyUnregisterClass
End If
End Sub
Function MyRegisterClass()as bool
' WNDCLASS-structure
'Dim wndcls As WNDCLASS ' original code
wndcls.style = CS_HREDRAW | CS_VREDRAW
wndcls.lpfnwndproc = GetMyWndProc(@MyWndProc)
wndcls.cbClsextra = 0
wndcls.cbWndExtra2 = 0
wndcls.hInstance = App.hInstance
wndcls.hIcon = 0
wndcls.hCursor = LoadCursor(0, IDC_ARROW)
wndcls.hbrBackground = COLOR_WINDOW
wndcls.lpszMenuName = 0
wndcls.lpszClassName = "myWindowClass"
' Register class
MyRegisterClass = RegisterClass(&wndcls)
Function = MyRegisterClass
End Function
Sub MyUnregisterClass()
UnregisterClass "myWindowClass", App.hInstance
End Sub
Function MyCreateWindow() As Bool
Dim hWnd As Long
' Create the window
hWnd = CreateWindowEx(0, "myWindowClass", "My Window", WS_OVERLAPPEDWINDOW, 0, 0, 400, 300, 0, 0, App.hInstance, ByVal 0&)
' The Button and Textbox are child windows
hwnd2 = CreateWindowEx(0, "Button", "My button", WS_CHILD, 50, 55, 100, 25, hWnd, 0, App.hInstance,0)
hwnd3 = CreateWindowEx(0, "edit", "My textbox", WS_CHILD, 50, 25, 100, 25, hWnd, 0, App.hInstance, 0)
If hWnd <> 0 Then ShowWindow hWnd, SW_SHOWNORMAL
' Show them
ShowWindow hwnd2, SW_SHOWNORMAL
ShowWindow hwnd3, SW_SHOWNORMAL
' Go back
MyCreateWindow = (hWnd <> 0)
End Function
Function MyWndProc(ByVal hWnd As Long, ByVal message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case message
Case WM_DESTROY
' Destroy window
PostQuitMessage (0)
End Select
' calls the default window procedure
MyWndProc = DefWindowProc(hWnd, message, wParam, lParam)
End Function
Function GetMyWndProc(ByVal lWndProc As Long) As Long
GetMyWndProc = lWndProc
End Function
Sub MyMessageLoop()
Dim aMsg As Msg
Do While GetMessage(aMsg, 0, 0, 0)
DispatchMessage aMsg
Loop
End Sub
Function ButtonProc(ByVal hWnd As Long, ByVal message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim x As Integer
If (message = 533) Then
x = MsgBox("You clicked on the button", vbOKOnly)
End If
' calls the window procedure
ButtonProc = CallWindowProc(old_proc, hWnd, message, wParam, lParam)
End Function