Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: CreateWindowEx is resulting Zero.

  1. #11
    Member
    Join Date
    Aug 2015
    Location
    Keralam, India
    Posts
    118
    Rep Power
    17
    @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()
    
    Last edited by kcvinu; 09-04-2021 at 00:55.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •