Note, the code has 2 message processing systems.......
Function ApiWindow.CtrlMsgFunc
Function wndproc
....I test with one or the other.
////////////////////////////////////////////
Form.bi
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 short _Left = 100 ' valor por defecto
As short _Top = 100
As short _Width = 320
As short _Height = 240
Declare Sub Create(WinName As string, Title As string)
Declare Sub onClick() ' <--------------------------------------------
Declare Static Function CtrlMsgFunc(WinHwnd As handle,uMsg as UInteger,wParam as wParam,lParam as lParam) as LRESULT
End Type
Sub ApiWindow.onClick()
Print "-- ApiWindow.Click() --"
End Sub
Function ApiWindow.CtrlMsgFunc(WinHwnd As handle,Msg as UInteger,wParam as wParam,lParam as lParam) as LRESULT
Select Case Msg
Case WM_CREATE
Case WM_DESTROY
PostQuitMessage(0)
Case WM_LBUTTONDOWN
' < ------------ Here I want to fire the Onclick event
'ApiWindow.onClick() ' < ------------ Not Work
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)
Case WM_LBUTTONDOWN
' < ------------ Here I want to fire the Onclick event
'ApiWindow.onClick() ' < ------------ Not Work
End Select
Return DefWindowProc(hwnd,msg,wparam,lparam)
End Function
With wc
.cbSize=SizeOf(WNDCLASSEX)
.style=CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc=@wndproc ' < ------------ i can use this ......
''' .lpfnWndProc = @ApiWindow.CtrlMsgFunc ' < ------------ or this ......
.hInstance=Hinst
.hIcon=LoadIcon(0,IDI_QUESTION)
.hCursor=LoadCursor(0,IDC_ARROW)
.hbrBackground=Cast(HBRUSH,COLOR_WINDOW)
.lpszClassName=StrPtr(NameClass)
.hIconSm=.hIcon
End With
If RegisterClassEx(@wc)=0 Then
Print "Register error, press any key"
Sleep
End
Endif
Sub AppRun
While GetMessage(@msg,0,0,0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Wend
End sub
Sub ApiWindow.Create(WinName As string, Title As string)
CreateWindowEx(0,WinName,Title,WS_VISIBLE Or WS_OVERLAPPEDWINDOW, _
_left, _top, _Width, _Height, 0, 0, getmodulehandle(0),0)
End Sub
Code: Select all
#include "windows.bi"
#include "win\commctrl.bi"
InitCommonControls
#Include "Form.bi"
Dim Shared Form1 As ApiWindow
Sub MiFormSub()
Print "MiFormSub"
End sub
Form1.Create(NameClass, "Window 1")
'Form1.onClick = @MiFormSub ' < -------------- Error 3 - Expected End of Line....
AppRun