@Eros Olmi
Hi,
How do i use the Window type in Wndproc function ? This is how i store my current Window type. This is working perfectly. No error.
Dim PtrMe As Long = VarPtr(Me
SetWindowLong(Me.WinHandle, -21, PtrMe) '// Varptr(Me) inside the function is not working
But I cannot use SetWindowLongPtr. What will be the reason ? Here is the function declarations.
Declare Function GetWindowLong Lib "User32.dll" Alias "GetWindowLongW"(ByVal hWnd As DWord, ByVal nIndex as Integer) As Long
Declare Function SetWindowLong Lib "User32.dll" Alias "SetWindowLongW"(ByVal hWnd As DWord,
ByVal nIndex as Integer,
ByRef dwNewLong As Long ) As Long
Declare Function GetWindowLongPtr Lib "User32.dll" Alias "GetWindowLongPtrW"(ByVal hWnd As DWord, ByVal nIndex as Integer) As Long
Declare Function SetWindowLongPtr Lib "User32.dll" Alias "SetWindowLongPtrW"(ByVal hWnd As DWord,
ByVal nIndex as Integer,
ByRef dwNewLong As Long ) As Long
And the main thing, I am able to get the Window type in WndProc with this code.
Dim win As TWindow = GetWindowLong(hwnd, -21)
But this is not the actual pointer. See this scenario
Step 1 - I create a tWindow type The default value of text property is "Window_01"
Step 2 - I change the text property of TWindow type with a member function, - win.SetTitle("bla bla")
Step 3 - I create the window with CreateWindowEx and use the SetWindowLong function to keep the TWindow pointer.
Step 4 - I retrieve the window type inside the WndProc function with GetWindowLong function.
Step 5 - On WM_LBUTTONDOWN, I try to print out the TWindow type's text property. But output is ""Window_01". Not "bla bla"
That means, the pointer i set using SetWindowLong and the pointer i get with GetWindowLong are different. How to fix this ?
I have a strong feeling that ThinBasic needs a List data type to hold not only the primitive data types like Integer, String, but also UDTs. A list, in which we dont need to use redim. And We now have a function to get a variables pointer with "Varptr". But we need a function to get the variable from that pointer.
Edit :
Basically, this is what i am trying to do.
#Include ".\ThinUi\*"
Dim win As TWindow '// Declare a new Window class
win.SetTitle("തിൻബേസിക്ക്") '// Set new title
win.SetSize(1000, 500) '// Set new size
win.Create() '// Create the actual window
'// Connect the mouse down event to user defined function. (NOT WORKING)
win.AddHandler(win.MouseDown, CodePtr(OnMouseClick))
'// user defined function. I want to add two parameters for this.
Function OnMouseClick() As Long
Printl("Window clicked")
End Function
'// Display the window
win.Display()
Bookmarks