flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved] How to create tree view list?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
zvn



Joined: 21 Oct 2024
Posts: 12
zvn 23 Oct 2024, 12:20
How to create a list like in the picture?


Description:
Filesize: 7.27 KB
Viewed: 1323 Time(s)

list.png


Post 23 Oct 2024, 12:20
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1660
Location: Toronto, Canada
AsmGuru62 23 Oct 2024, 12:38
This control already present on Windows.
You need to use CreateWindow API with the class name of "SysTreeView32".
https://learn.microsoft.com/en-us/windows/win32/controls/tree-view-control-reference
Post 23 Oct 2024, 12:38
View user's profile Send private message Send e-mail Reply with quote
zvn



Joined: 21 Oct 2024
Posts: 12
zvn 23 Oct 2024, 14:01
AsmGuru62 wrote:
This control already present on Windows.
You need to use CreateWindow API with the class name of "SysTreeView32".
https://learn.microsoft.com/en-us/windows/win32/controls/tree-view-control-reference

Thanks for your help!
Post 23 Oct 2024, 14:01
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 23 Oct 2024, 14:05
I have a rather terse example in my controls usage examples. I realize the syntax is fairly advanced - using the features of fasm2; but I am happy to help with any understanding.

Edit: Just realized you are working in 32-bit -- perhaps it is not a good example, for you.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 23 Oct 2024, 14:05
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 23 Oct 2024, 21:27
this kind of treeview should be in fasmw.
really.
and interactive because fasm is very fast and real. just a single band (with scrollbar) pointing to where the current file is and i will be very very happy.
Image

but of course, it should be platform independent. like, wind, linux... hem, not fasml? ok, then, fasmw shoul dbe ported to debian, and so on...

https://www.youtube.com/watch?v=fThinVykn-U

and be sure, '4' will never happen in this suite, never!
Post 23 Oct 2024, 21:27
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1660
Location: Toronto, Canada
AsmGuru62 24 Oct 2024, 00:33
The tree in FASM IDE would be great!
I am coding the x64 FASM IDE now for x64 development.
I wanted the tree, but then I need to update a tree when I type code into editor.
Say, I am creating a structure in code --- the tree would need a constant update, like inserting/removing data members, functions, etc.
Keeping files in a tree is nice, but you can just list files easily in a dialog.
Or, maybe update the tree by some "Refresh" button.
Or with a timer.
A lot of code for just fancy Visual Studio effect.
I have "Go To Definition" feature and I can search for occurences of an item in all files or in an active file.
However, seeing code at a glance would be nice.
Like, click on a file in tree and select "Expand All" --- showing all procedures, structures, labels in the file.
Post 24 Oct 2024, 00:33
View user's profile Send private message Send e-mail Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1020
Location: Russia
macomics 24 Oct 2024, 03:27
AsmGuru62 wrote:
I have "Go To Definition" feature and I can search for occurences of an item in all files or in an active file.
However, seeing code at a glance would be nice.
Like, click on a file in tree and select "Expand All" --- showing all procedures, structures, labels in the file.
Then it would be necessary to make an automatic substitution. {Ctrl+Space -> Popup}
Post 24 Oct 2024, 03:27
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1398
Location: Piraeus, Greece
Picnic 24 Oct 2024, 11:50
AsmGuru62 wrote:
The tree in FASM IDE would be great!

Yes i think it would be nice.

Personally, I can't work without such a feature (tree), and at the same time with several open windows and split editor view. That's why I've been using Notepad++ consistently for many years for my simple programming needs in ASM/C/BASIC.

Sorry for being off topic, zvn.

_________________
Hobby BASIC Interpreter
Post 24 Oct 2024, 11:50
View user's profile Send private message Visit poster's website Reply with quote
zvn



Joined: 21 Oct 2024
Posts: 12
zvn 05 Nov 2024, 06:39
Quote:
Sorry for being off topic, zvn.

Glad to serve you)

When I tried to add a tree-view control to the form, I found that in the "comctl32.inc" file, in the "Common control window classes" section, some class names differ from those used in the Microsoft manuals, for example, the tree-view element is called "TREEVIEW_CLASS", while in the manuals it is "WC_TREEVIEW".
Who is important, what is the reason for changing the class names?
Post 05 Nov 2024, 06:39
View user's profile Send private message Reply with quote
zvn



Joined: 21 Oct 2024
Posts: 12
zvn 05 Nov 2024, 06:58
Help me understand why adding an element to the tree-view in the code below does not work. I am sure that the error is in filling the TV_ITEM structure, since the elements are added, but for some reason they are empty.

Code:
format    PE GUI
include   'win32w.inc'
entry     beg

section '.code' code executable
beg:

        invoke GetModuleHandle, 0
        invoke DialogBoxParam, eax, 0, HWND_DESKTOP, DialogProc, 0
        invoke ExitProcess, 0

proc    DialogProc hwnddlg, msg, wParam, lParam
xor     eax, eax
cmp     [msg], WM_CLOSE
je      FreeDialog
cmp     [msg], WM_COMMAND
jne     ExitProc
mov eax, BN_CLICKED
shl eax, 16
add eax, 10
cmp eax, [wParam]

        mov     [tvi.mask], TVIF_TEXT
        mov     [tvi.hItem], 0
        mov     [tvi.state], 0
        mov     [tvi.stateMask], 0
        mov     [tvi.pszText], _testTree
        mov     [tvi.cchTextMax], 6
        mov     [tvi.iImage], 0
        mov     [tvi.iSelectedImage], 0
        mov     [tvi.cChildren], 0
        mov     [tvi.lParam], 0

        mov     [tvins.hParent], TVI_ROOT
        mov     [tvins.hInsertAfter], TVI_FIRST
        mov     [tvins.item], dword tvi

        invoke  SendDlgItemMessage, [hwnddlg], 1, TVM_INSERTITEM, 0, tvins
        ret
FreeDialog:
invoke  EndDialog, [hwnddlg], 0

ExitProc:
xor     eax, eax
ret
endp

section '.data' data readable writeable
tvi             TV_ITEM
tvins           TV_INSERTSTRUCT
_testTree       du      'abc',0

section 'import' import readable

  library kernel,         'kernel32.dll',\
          user,           'user32.dll'

  import kernel,\
      GetModuleHandle,    'GetModuleHandleW',\
      ExitProcess,        'ExitProcess'


  import user,\
      DialogBoxParam,     'DialogBoxParamW',\
      EndDialog,          'EndDialog',\
      SetDlgItemText,     'SetDlgItemTextW',\
      SendDlgItemMessage, 'SendDlgItemMessageW',\
      MessageBox,         'MessageBoxW',\
      LoadMenu,           'LoadMenuW',\
      SetMenu,            'SetMenu',\
      GetDlgItem,       'GetDlgItem'

section '.rsrc' resource readable

directory       RT_DIALOG, dialogs

resource        dialogs, 0, LANG_NEUTRAL, MainWindow

dialog          MainWindow, 'MainDLG', 700, 300, 100, 100, WS_VISIBLE+WS_CAPTION+WS_SYSMENU
dialogitem      WC_TREEVIEW, '', 1, 10, 10, 50, 50, WS_VISIBLE+WS_BORDER
dialogitem      'button', 'add', 2, 10, 70, 20, 20, WS_VISIBLE
enddialog    

Oh yeah, if you run this code, don't forget to change the class name in the resources: WC_TREEVIEW to TREEVIEW_CLASS!
Post 05 Nov 2024, 06:58
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1020
Location: Russia
macomics 05 Nov 2024, 09:48
zvn wrote:
When I tried to add a tree-view control to the form, I found that in the "comctl32.inc" file, in the "Common control window classes" section, some class names differ from those used in the Microsoft manuals, for example, the tree-view element is called "TREEVIEW_CLASS", while in the manuals it is "WC_TREEVIEW".
Who is important, what is the reason for changing the class names?
The name of the constant is not important within the source code. You can freely rename her whatever you want. But the value of the constant cannot be changed. Otherwise, you will not be understood.

ADD:
Code:
format    PE GUI
include   'win32w.inc'
entry     beg

section '.code' code executable
beg:

        invoke GetModuleHandle, 0
        invoke DialogBoxParam, eax, 0, HWND_DESKTOP, DialogProc, 0
        invoke ExitProcess, 0

proc    DialogProc hwnddlg, msg, wParam, lParam
xor     eax, eax
cmp     [msg], WM_CLOSE
je      FreeDialog
cmp     [msg], WM_COMMAND
jne     ExitProc
mov eax, BN_CLICKED
shl eax, 16
add eax, 10
cmp eax, [wParam]

        mov     [tvins.hParent], TVI_ROOT
        mov     [tvins.hInsertAfter], TVI_FIRST
        mov     [tvins.item.mask], TVIF_TEXT
        mov     [tvins.item.hItem], 0
        mov     [tvins.item.state], 0
        mov     [tvins.item.stateMask], 0
        mov     [tvins.item.pszText], _testTree
        mov     [tvins.item.cchTextMax], 6
        mov     [tvins.item.iImage], 0
        mov     [tvins.item.iSelectedImage], 0
        mov     [tvins.item.cChildren], 0
        mov     [tvins.item.lParam], 0

        invoke  SendDlgItemMessage, [hwnddlg], 1, TVM_INSERTITEM, 0, tvins
        ret
FreeDialog:
invoke  EndDialog, [hwnddlg], 0

ExitProc:
xor     eax, eax
ret
endp

section '.data' data readable writeable
tvi             TV_ITEM
tvins           TV_INSERTSTRUCT
_testTree       db      'abc',0

section 'import' import readable

  library kernel,         'kernel32.dll',\
          user,           'user32.dll'

  import kernel,\
      GetModuleHandle,    'GetModuleHandleW',\
      ExitProcess,        'ExitProcess'


  import user,\
      DialogBoxParam,     'DialogBoxParamW',\
      EndDialog,          'EndDialog',\
      SetDlgItemText,     'SetDlgItemTextW',\
      SendDlgItemMessage, 'SendDlgItemMessageW',\
      MessageBox,         'MessageBoxW',\
      LoadMenu,           'LoadMenuW',\
      SetMenu,            'SetMenu',\
      GetDlgItem,       'GetDlgItem'

section '.rsrc' resource readable

directory       RT_DIALOG, dialogs

resource        dialogs, 0, LANG_NEUTRAL, MainWindow

dialog          MainWindow, 'MainDLG', 700, 300, 100, 100, WS_VISIBLE+WS_CAPTION+WS_SYSMENU
dialogitem      WC_TREEVIEW, '', 1, 10, 10, 50, 50, WS_VISIBLE+WS_BORDER
dialogitem      'button', 'add', 2, 10, 70, 20, 20, WS_VISIBLE
enddialog
    
Post 05 Nov 2024, 09:48
View user's profile Send private message Reply with quote
Hrstka



Joined: 05 May 2008
Posts: 58
Location: Czech republic
Hrstka 05 Nov 2024, 11:09
You can set cchTextMax to 0, the parameter will be ignored. For Unicode characters you must use TVM_INSERTITEMW instead of TVM_INSERTITEM
Post 05 Nov 2024, 11:09
View user's profile Send private message Reply with quote
zvn



Joined: 21 Oct 2024
Posts: 12
zvn 05 Nov 2024, 11:32
macomics, Thank you, the issue has been resolved.
Hrstka wrote:
You can set cchTextMax to 0, the parameter will be ignored. For Unicode characters you must use TVM_INSERTITEMW instead of TVM_INSERTITEM
Post 05 Nov 2024, 11:32
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 06 Nov 2024, 09:21
fasmw 1.73 error: undefined WC_TREEVIEW
dialogitem WC_TREEVIEW, '', 1, 10, 10, 50, 50, WS_VISIBLE+WS_BORDER

What is value for WC_TREEVIEW ?

I found: WC_TREEVIEW equ "SysTreeView32"
nice variant:
Code:
WC_TREEVIEW equ "SysTreeView32" 
dialogitem WC_TREEVIEW,'',1,10,10,50,50, WS_VISIBLE+WS_BORDER+TVS_LINESATROOT+TVS_HASLINES
    
Post 06 Nov 2024, 09:21
View user's profile Send private message Reply with quote
zvn



Joined: 21 Oct 2024
Posts: 12
zvn 06 Nov 2024, 16:28
Roman wrote:
fasmw 1.73 error: undefined WC_TREEVIEW
dialogitem WC_TREEVIEW, '', 1, 10, 10, 50, 50, WS_VISIBLE+WS_BORDER

What is value for WC_TREEVIEW ?

I found: WC_TREEVIEW equ "SysTreeView32"
nice variant:
Code:
WC_TREEVIEW equ "SysTreeView32" 
dialogitem WC_TREEVIEW,'',1,10,10,50,50, WS_VISIBLE+WS_BORDER+TVS_LINESATROOT+TVS_HASLINES
    

To get rid of the error, you must either change TREEVIEW_CLASS to WC_TREEVIEW in the "comctl32.inc" file, or use TREEVIEW_CLASS in the resources, or a pointer to the string "SysTreeView32"
Post 06 Nov 2024, 16:28
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1660
Location: Toronto, Canada
AsmGuru62 06 Nov 2024, 19:23
I do this for the tree:
Code:
TreeCtrlClass    du  "SysTreeView32",0
    
Post 06 Nov 2024, 19:23
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 08 Nov 2024, 12:15
Good variant.
Code:
format    PE GUI
include 'c:\fasmw17316\include\Win32w.inc'

entry     beg

section '.code' code executable
beg:

        invoke GetModuleHandle, 0
        invoke DialogBoxParam, eax, 0, HWND_DESKTOP, DialogProc, 0
        invoke ExitProcess, 0

proc    DialogProc hwnddlg, msg, wParam, lParam
xor     eax, eax
cmp     [msg], WM_CLOSE
je      FreeDialog
cmp     [msg], WM_COMMAND
jne     ExitProc
mov eax, BN_CLICKED
shl eax, 16
add eax, 2 ;this is IDE button
cmp eax, [wParam]
jnz   ExitProc
        mov     [tvins.hParent], 0;TVI_ROOT or 0
        mov     [tvins.hInsertAfter], TVI_ROOT ;TVI_FIRST
        mov     [tvins.item.mask], TVIF_TEXT;+TVIF_CHILDREN
        mov     [tvins.item.hItem], 0
        mov     [tvins.item.state], 0
        mov     [tvins.item.stateMask], 0
        mov     [tvins.item.pszText], _testTree
        mov     [tvins.item.cchTextMax], 12 ;number symbols from text
        mov     [tvins.item.iImage], 0
        mov     [tvins.item.iSelectedImage], 0
        mov     [tvins.item.cChildren], 0
        mov     [tvins.item.lParam], 0

        invoke  SendDlgItemMessage, [hwnddlg], 1, TVM_INSERTITEM, 0, tvins
        mov  [tvins.hParent],eax   ;this is needed!
        
                mov  [tvins.hInsertAfter],TVI_LAST
                mov  [tvins.item.pszText],tv1Txt2
        invoke  SendDlgItemMessage, [hwnddlg], 1, TVM_INSERTITEM, 0, tvins
    
        invoke  SendDlgItemMessage, [hwnddlg], 1, TVM_INSERTITEM, 0, tvins
        inc byte [_testTree+5]
        ret
FreeDialog:
invoke  EndDialog, [hwnddlg], 0

ExitProc:
xor     eax, eax
ret
endp

section '.data' data readable writeable
tvi             TV_ITEM
tvins           TV_INSERTSTRUCT
_testTree       db      'abc000',0
tv1Txt2         db 'childrn',0

section 'import' import readable

  library kernel,         'kernel32.dll',\
          user,           'user32.dll'

  import kernel,\
      GetModuleHandle,    'GetModuleHandleW',\
      ExitProcess,        'ExitProcess'


  import user,\
      DialogBoxParam,     'DialogBoxParamW',\
      EndDialog,          'EndDialog',\
      SetDlgItemText,     'SetDlgItemTextW',\
      SendDlgItemMessage, 'SendDlgItemMessageW',\
      MessageBox,         'MessageBoxW',\
      LoadMenu,           'LoadMenuW',\
      SetMenu,            'SetMenu',\
      GetDlgItem,       'GetDlgItem'

section '.rsrc' resource readable
WC_TREEVIEW   equ   "SysTreeView32"
directory       RT_DIALOG, dialogs

resource        dialogs, 0, LANG_NEUTRAL, MainWindow

dialog          MainWindow, 'MainDLG', 700, 300, 200, 200, WS_VISIBLE+WS_CAPTION+WS_SYSMENU
dialogitem      WC_TREEVIEW, '', 1, 10, 10, 80*2, 50*2, WS_VISIBLE+WS_BORDER+TVS_LINESATROOT+TVS_HASLINES+TVS_SHOWSELALWAYS+TVS_EDITLABELS+TVS_HASBUTTONS
dialogitem      'button', 'add', 2, 10, 70*2, 20, 20, WS_VISIBLE
enddialog
    


Description:
Filesize: 14.59 KB
Viewed: 687 Time(s)

treelist.jpg


Post 08 Nov 2024, 12:15
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 11 Nov 2024, 14:11
I try get text from treeview But not get any text.
tv TV_ITEM
mov [tv.pszText],mybuffer
mov [tv.cchTextMax],20

And do SendMessage
Post 11 Nov 2024, 14:11
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 11 Nov 2024, 15:27
I done this !
Code:
tvi             TV_ITEM
mov [tvi.mask],TVIF_TEXT
mov [tvi.cchTextMax], 50 ;maximum name size bytes
mov [tvi.pszText],textBuffer


invoke GetDlgItem,[hwnddlg],1

push eax
invoke SendMessage,eax,TVM_GETNEXTITEM,TVGN_FIRSTVISIBLE, 0
mov [tvi.hItem],eax
pop eax
invoke SendMessage,eax,TVM_GETITEMA, 0, tvi

invoke MessageBox,0,textBuffer,0,0
    

We need do loop(for all names) and do TVM_GETNEXTITEM & TVGN_NEXTVISIBLE to jump next name.
Then we get all names from treeView
Post 11 Nov 2024, 15:27
View user's profile Send private message Reply with quote
zvn



Joined: 21 Oct 2024
Posts: 12
zvn 12 Nov 2024, 14:18
Hello friends!
I am writing a MW_NOTIFY message handler for the TVN_SELCHANGED notification of the Tree-view control in the dialog window procedure.
I encountered a problem getting the value of the hdr.code parameter of the NM_TREEVIEW structure.
The description states that the TVN_SELCHANGED notification passes the address of the NM_TREEVIEW structure in the lParam parameter, which includes the MHDR structure.
In fact, the lParam parameter contains the stack address, which in turn points to another address, using which with an offset of 8 (equal to the value of NM_TREEVIEW.hdr.code) I get an access violation error.
How can I access a member of the structure whose address is passed in the lParam parameter?
Maybe someone has encountered this problem?
Maybe there is some solution?
Post 12 Nov 2024, 14:18
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.