Results 1 to 2 of 2

Thread: Nested UDT structures passed as param to API function

  1. #1
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10

    Nested UDT structures passed as param to API function

    Next thinBasic 1.7.0.0 preview will have a feature requested some time ago: passing nested UDT structure to API functions as parameter.
    It is more difficult to describe than to show

    Imagine one of the following API:
    [code=thinbasic]

    Declare Function GetCursorPos Lib "USER32.DLL" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
    Declare Function GetClientRect Lib "USER32.DLL" Alias "GetClientRect" (ByVal hwnd As Dword, lpRect As RECT) As Long

    [/code]
    Both expect a structure parameter variable passed BYREF.
    But what if your POINTAPI or RECT variable are inside a personalized UDT (maybe 2/3 level deeper)? For example like the following UDT:
    [code=thinbasic]type MyType
    '---....
    MyPT As POINTAPI
    MyRC As RECT
    '---....
    end type
    '...
    DIM MyVAR as MyType
    DIM hWnd as LONG
    [/code]

    Since now you had to put in place some trick like getting the pointer to MyVAR.MyPT using VARPTR and then pass that pointer to the API function.

    In next thinBasic 1.7.0.0 you will just simply:
    [code=thinbasic]
    GetCursorPos MyVAR.MyPT
    '...
    GetClientRect hWnd, MyVAR.MyRC[/code]

    thinBasic will now do homeworks on this

    Hope you like it.
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736

    Re: Nested UDT structures passed as param to API function

    Hi Eros,

    good! I really like it!


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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