Code: Select all
#Include Once "windows.bi"
#include "win\commctrl.bi"
Dim As WNDCLASSEX wc
Dim Shared As String NameClass
NameClass="WinClass"
Dim As HINSTANCE Hinst=GetModuleHandle(0)
Dim Shared msg As MSG
Type ApiWindow
As Integer Var1
As Integer Var2
Declare Sub Create(WinName As string, Title As string)
Declare Function CtrlMsgFunc(WinHwnd As hwnd,uMsg as UInteger,wParam as wParam,lParam as lParam) as LRESULT
End Type
Sub ApiWindow.Create(WinName As string, Title As string)
CreateWindowEx(0,WinName,Title,_
WS_VISIBLE Or WS_OVERLAPPEDWINDOW, 10, 10, 320, 240, 0, 0, getmodulehandle(0),0)
End Sub
Function ApiWindow.CtrlMsgFunc(WinHwnd As hwnd, Msg as UInteger,wParam as wParam,lParam as lParam) as LRESULT
Select Case Msg
Case WM_CREATE
Case WM_DESTROY
PostQuitMessage(0)
End Select
return DefWindowProc(WinHwnd,Msg,wparam,lparam)
End function
Function wndproc(hwnd As HWND, msg As UInteger, wparam As WPARAM, lparam As LPARAM) As Integer
Select Case msg
Case WM_CREATE
Case WM_DESTROY
PostQuitMessage(0)
End Select
Return DefWindowProc(hwnd,msg,wparam,lparam)
End Function
With wc
.cbSize=SizeOf(WNDCLASSEX)
.style=CS_HREDRAW Or CS_VREDRAW
'''.lpfnWndProc=@wndproc ' < ================= This Work
.lpfnWndProc = @ApiWindow.CtrlMsgFunc ' < ================= This no Work, does not show the windows, only the console
.hInstance=Hinst
.hIcon=LoadIcon(0,IDI_QUESTION)
.hCursor=LoadCursor(0,IDC_ARROW)
.hbrBackground=Cast(HBRUSH,COLOR_WINDOW)
.lpszClassName=StrPtr(NameClass)
.hIconSm=.hIcon
End With
Sub AppRun
While GetMessage(@msg,0,0,0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Wend
End Sub
' --- Start Program ---
Dim Win1 As ApiWindow
win1.Create(NameClass, "My Window")
apprun