Results 1 to 2 of 2

Thread: Visual designer generated code - TreeView

  1. #1
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55

    Question Visual designer generated code - TreeView

    Hi,

    This is VD generated code for a simple window with a treeview,
    line 94 , UDT are not defined, thus not working, and this code way of doing differs from the treeview sample bundled with thinbasic.

    What was intended with TV_INSERTSTRUCT and TV_ITEM ?
    What method would you counsel between VD generated code and bundled sample ?

    file : vd-test-treeview.zip

    '------------------------------------------------------------------------------
    'thinAir Visual Designer
    '------------------------------------------------------------------------------
    ' Project: Visual Designer generated code
    ' File:    Your file name
    ' Created: On 11-02-2018 at 10:05:30
    '------------------------------------------------------------------------------
    
    '---Needed thinBasic modules
    USES "UI"
    
    '---Controls IDs---
    Begin ControlID
    	%IDC_TREEVIEW_1
    End ControlID
    
    
    
    '------------------------------------------------------------------------------
    ' Main thinBasic function
    '------------------------------------------------------------------------------
    Function TBMain() As Long
    
    	MainWindow_Create(%HWND_DESKTOP)
    
    End Function
    
    '------------------------------------------------------------------------------
    ' Create main Window
    '------------------------------------------------------------------------------
    Function MainWindow_Create(ByVal hParent As Long) As Long
    
    	Local hDlg     As Long
    	Local hFont    As Long
    	Local lStyle   As Long
    	Local lStyleEx As Long
    	lStyle = _                          
    	        %WS_DLGFRAME          | _   
    	        %WS_CAPTION           | _   
    	        %WS_SYSMENU           | _   
    	        %WS_OVERLAPPEDWINDOW  | _   
    	        %WS_CLIPCHILDREN      | _   
    	        %WS_CLIPSIBLINGS      | _   
    	        %DS_CENTER                  
    	lStyleEx = 0                        
    
    	Dialog New Pixels, hParent, "Form1", -1, -1, 468, 225, lStyle, lStyleEx, TO hDlg
    
    	hFont = Font_Create("MS Sans Serif", 8)
    	Dialog Send hDlg, %WM_SETFONT, hFont, 0
    
    
    
    	CONTROL ADD "SysTreeView32", hDlg, %IDC_TREEVIEW_1, "TreeView1", 40, 16, 192, 184, %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR %WS_VISIBLE OR %TVS_HASBUTTONS OR %TVS_HASLINES OR %TVS_LINESATROOT, %WS_EX_CLIENTEDGE
    
    	SampleTreeView(hDlg, %IDC_TREEVIEW_1, 3)
    
    	Dialog Show Modal hDlg, CALL MainWindow_Proc
    
    	Win_DeleteObject hFont
    
    End Function
    
    '------------------------------------------------------------------------------
    ' Main WIndow CallBack handler
    '------------------------------------------------------------------------------
    CallBack Function MainWindow_Proc() As Long
    
    	LOCAL pNMHDR   AS NMHDR PTR
    
    	LOCAL PageNo   AS LONG     
    
    	LOCAL hFontTab AS LONG     
    
    	SELECT CASE (CBMSG)
    
    	    CASE %WM_INITDIALOG
    	    CASE %WM_COMMAND
    	        SELECT CASE LOWRD(CBWPARAM)
    	            CASE %IDOK
    	            CASE %IDCANCEL
    	        END SELECT
    
    	    CASE %WM_NOTIFY
    	    CASE %WM_DESTROY
    	End Select
    End Function
    
    '--------------------------------------------------------------------------------
    ' ** Sample code **
    '--------------------------------------------------------------------------------
    FUNCTION SampleTreeViewInsertItem(BYVAL hTree AS LONG,BYVAL hParent AS LONG, sItem AS STRING) AS LONG
    
    	LOCAL tTVInsert AS TV_INSERTSTRUCT, tTVItem AS TV_ITEM
    
    	IF hParent THEN
    	    tTVItem.mask        = %TVIF_CHILDREN OR %TVIF_HANDLE
    	    tTVItem.hItem       = hParent
    	    tTVItem.cchildren   = 1
    	    TreeView_SetItem hTree, tTVItem 
    	END IF
    
    	tTVInsert.hParent                   = hParent 
    	tTVInsert.Item.Item.mask            = %TVIF_TEXT
    	tTVInsert.Item.Item.pszText         = STRPTR(sItem)
    	tTVInsert.Item.Item.cchTextMax      = LEN(sItem)
    
    	FUNCTION = TreeView_InsertItem(hTree, tTVInsert)
    
    END FUNCTION
    
    '------------------------------------------------------------------------------
    ' 
    '------------------------------------------------------------------------------
    FUNCTION SampleTreeView(BYVAL hDlg AS LONG,BYVAL lID AS LONG,BYVAL lCount AS LONG) AS LONG
    
    	LOCAL hRoot AS LONG,hParent AS LONG,i AS LONG
    	LOCAL j AS LONG,k AS LONG, hCtl AS LONG
    
    	CONTROL HANDLE hDlg, lID TO hCtl
    
    	FOR i = 1 TO lCount
    	    hRoot = SampleTreeViewInsertItem(hCtl, %NULL, "Root" + FORMAT$(i))
    	    FOR j = 1 TO lCount
    	        hParent = SampleTreeViewInsertItem(hCtl, hRoot, "Item" + FORMAT$(j))
    	        FOR k = 1 TO lCount
    	            CALL SampleTreeViewInsertItem(hCtl, hParent, "SubItem" + _ 
    	                FORMAT$(j) + "." + FORMAT$(k)) 
    	        NEXT k
    	    NEXT j
    	NEXT i
    
    END FUNCTION
    
    Last edited by DirectuX; 02-11-2018 at 11:39. Reason: added file
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    Thanks, great catch.
    This oblige me to rewrite some code in Visual designer and UI module.

    Fixed, I will release soon a new version.
    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

Similar Threads

  1. thinBasic Visual Designer Code Generator
    By ErosOlmi in forum thinBasic vaporware
    Replies: 17
    Last Post: 24-11-2018, 11:17
  2. Visual designer generated code - ProgressBar
    By DirectuX in forum thinAir General
    Replies: 1
    Last Post: 02-11-2018, 15:28
  3. Firefly Visual designer
    By Michael Clease in forum Development
    Replies: 0
    Last Post: 30-07-2009, 10:28
  4. Replies: 8
    Last Post: 07-03-2009, 00:46
  5. How to use the treeview in 1.7.0.0?
    By Michael Hartlef in forum UI (User Interface)
    Replies: 4
    Last Post: 04-10-2008, 10:16

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

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