Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SysTreeView32
#1
IS THIS POSSIBLE?

COLUMN A COLUMN B



-NAMES
+ANNE
-JAMES
ADDRESS
TEL. 886121325
+PETER
#2
You need to create smart dialog, add TreeView32 control and set its style (not through Styles dialog).

This example shows how to create data array, add tree view items, process notification messages, and get selected item index when dialog is closed.

Macro:
Code:
Copy      Help
#compile "common_controls_api"

;declare type for item data
type MYTVITEMDATA str'label str'data htvitem !issubitem
;this array will hold all items
ARRAY(MYTVITEMDATA)- t_a
t_a.create(3)
t_a[0].label="folder"
t_a[1].label="item 1"; t_a[1].data="a[]b[]c"; t_a[1].issubitem=1
t_a[2].label="item 2"; t_a[2].data="d[]e[]f"; t_a[2].issubitem=1
;show dialog
str controls = "4 5"
str e4Tex e5Ind
if(!ShowDialog("dialog_with_tree_view" &dialog_with_tree_view &controls)) ret
;index of selected item is
int i=val(e5Ind)
out i
out t_a[i].label

Function dialog_with_tree_view:
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 223 135 "Form"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 SysTreeView32 0x54010027 0x204 6 4 96 48 ""
;4 Edit 0x54231044 0x204 108 4 112 48 "Tex"
;5 Edit 0x54032000 0x200 188 80 32 14 "Ind"
;END DIALOG
;DIALOG EDITOR: "" 0x2010601 "" ""


ret
;messages
ARRAY(MYTVITEMDATA)- t_a
int i htv hpar
sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,
,;populate tree view with t_a array data
,if(t_a.len)
,,htv=id(3 hDlg)
,,for i 0 t_a.len
,,,if(t_a[i].issubitem)
,,,,t_a[i].htvitem=TvAdd(htv hpar t_a[i].label i)
,,,else
,,,,t_a[i].htvitem=TvAdd(htv 0 t_a[i].label i); hpar=t_a[i].htvitem
,,SendMessage htv TVM_SELECTITEM TVGN_CARET t_a[0].htvitem
,ret 1
,
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
int ctrlid=wParam&0xFFFF; message=wParam>>16
sel wParam
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 3
,sel nh.code
,,case TVN_SELCHANGED
,,NMTREEVIEW* ntv=+nh
,,i=ntv.itemNew.lParam
,,SetDlgItemInt(hDlg 5 i 0)
,,t_a[i].data.setwintext(id(4 hDlg))

To paste this in QM, use menu Edit -> Other formats -> Paste escaped.
#3
Thanks a lot.
#4
i keep getting this error

Quote:Error in TvAdd: unknown identifier.
and it highlights this in function TvAdd
Quote:TVINSERTSTRUCT
#5
I forgot this:

Code:
Copy      Help
#compile "common_controls_api"


Forum Jump:


Users browsing this thread: 1 Guest(s)