Page 1 of 1
PB Special ExplorerTreeGadget() {Windows]
Posted: Wed Jul 12, 2023 6:02 pm
by RASHAD
Hi all
Hi KCC
The next should satisfy your requirement (I hope)
You can colorize any item with any colors
Enable selecting color in the next ROUND
Code: Select all
#TV_FIRST = $1100
#TVM_MAPACCIDTOHTREEITEM = (#TV_FIRST + 42)
#TVM_MAPHTREEITEMTOACCID = (#TV_FIRST + 43)
Global selitem,selitem2
Procedure winCB(hWnd, uMsg, wParam, lParam)
Protected result, row
Protected *TVCDHeader.NMTVCUSTOMDRAW
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NOTIFY
*pnmh.NMHDR = lParam
Select *pnmh\code
Case #NM_CUSTOMDRAW
*TVCDHeader.NMTVCUSTOMDRAW = lParam
Select *TVCDHeader\nmcd\dwDrawStage
Case #CDDS_PREPAINT
result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
row = *TVCDHeader\nmcd\dwItemSpec
If row = selitem Or row = selitem2
*TVCDHeader\clrTextBk = $00FF00
*TVCDHeader\clrText = $0000FF
Else
*TVCDHeader\clrTextBk = $FFFFFF
*TVCDHeader\clrText = $FF0000
EndIf
If *TVCDHeader\nmcd\uItemState & #CDIS_SELECTED
*TVCDHeader\clrTextBk = $F39502
*TVCDHeader\clrText = $FFFFFF
EndIf
result = #CDRF_DODEFAULT
EndSelect
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0, 0, 0, 400, 500, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0,0)
ExplorerTreeGadget(0, 10, 10, 380, 480, "c:\*.*", #PB_Explorer_AlwaysShowSelection)
selitem = SendMessage_(GadgetID(0), #TVM_MAPACCIDTOHTREEITEM,10,0)
selitem2 = SendMessage_(GadgetID(0), #TVM_MAPACCIDTOHTREEITEM,11,0)
SetWindowCallback(@winCB())
SetActiveGadget(0)
;InvalidateRect_(GadgetID(0),0,1)
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
Edit :Added Select item coloring
Re: PB Special ExplorerTreeGadget() {Windows]
Posted: Wed Jul 12, 2023 6:24 pm
by Kwai chang caine
Wahooouhhh !!!
What word can be say in front of this fireworks of API ???

I knew that the great RASHAD was not going to give up in the face of adversity and was going to bring him to heel this ExplorerTreeGaget of misfortune

Thanks a lot my millennium friend for create this miracle for little KCC
Three questions come to me
1/ Why i'm again forcing to enable the Xp theme ?

(You have see i have thinking to enable it this time

)
2/ Why the first drive C is in the index 8 ?

3/ How can i change color of an index expanded between 8 and 9 ?
Re: PB Special ExplorerTreeGadget() {Windows]
Posted: Wed Jul 12, 2023 7:03 pm
by AZJIO
Code: Select all
#TV_FIRST = $1100
#TVM_MAPACCIDTOHTREEITEM = (#TV_FIRST + 42)
#TVM_MAPHTREEITEMTOACCID = (#TV_FIRST + 43)
Global selitem, selitem2
Procedure winCB(hWnd, uMsg, wParam, lParam)
Protected result, row
Protected *TVCDHeader.NMTVCUSTOMDRAW
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NOTIFY
*pnmh.NMHDR = lParam
Select *pnmh\code
Case #NM_CUSTOMDRAW
*TVCDHeader.NMTVCUSTOMDRAW = lParam
Select *TVCDHeader\nmcd\dwDrawStage
Case #CDDS_PREPAINT
result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
row = *TVCDHeader\nmcd\dwItemSpec
If row = selitem
*TVCDHeader\clrTextBk = $008800
*TVCDHeader\clrText = $00FFFF
Else
*TVCDHeader\clrTextBk = $FFFFFF
*TVCDHeader\clrText = $880000
EndIf
result = #CDRF_DODEFAULT
EndSelect
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0, 0, 0, 400, 500, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0, 0)
ExplorerTreeGadget(0, 10, 10, 380, 480, "c:\*.*", #PB_Explorer_AlwaysShowSelection)
InvalidateRect_(GadgetID(0), 0, 1)
SetWindowCallback(@winCB())
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftClick
selitem = SendMessage_(GadgetID(0), #TVM_GETNEXTITEM, #TVGN_CARET, 0)
InvalidateRect_(GadgetID(0), 0, 1)
EndIf
EndSelect
EndSelect
Until Quit = 1
Re: PB Special ExplorerTreeGadget() {Windows]
Posted: Wed Jul 12, 2023 8:11 pm
by RASHAD
Hi KCC
1- For XP theme
https://learn.microsoft.com/en-us/windo ... ohtreeitem
You need XP theme when using #TVM_MAPACCIDTOHTREEITEM and\or #TVM_MAPACCIDTOHTREEITEM
See MSDN remark
2- When enumerate the gadget all items you will discover that there are 7 rounds for Windows usage only
3- I will try to add the items ID in a simple way (just give me some time

)
Re: PB Special ExplorerTreeGadget() {Windows]
Posted: Wed Jul 12, 2023 8:32 pm
by RASHAD
Previous post updated
Select item as it should be
Re: PB Special ExplorerTreeGadget() {Windows]
Posted: Thu Jul 13, 2023 12:59 am
by Fangbeast
I think we need to convince MS to add in a KCC_ API with an excitement level variable:):)
Re: PB Special ExplorerTreeGadget() {Windows]
Posted: Thu Jul 13, 2023 3:03 am
by RASHAD
Hi Fang
with an excitement level variable

Re: PB Special ExplorerTreeGadget() {Windows]
Posted: Fri Jul 14, 2023 9:34 am
by Fangbeast
RASHAD wrote: Thu Jul 13, 2023 3:03 am
Hi Fang
with an excitement level variable
/me bows to the mighty wizard, teaching the kcc apprentice is a full time job for a wizard:):)
Re: PB Special ExplorerTreeGadget() {Windows]
Posted: Fri Jul 14, 2023 5:55 pm
by Kwai chang caine
Thanks a lot for yours explanations
mAPIster wrote:You need XP theme when using #TVM_MAPACCIDTOHTREEITEM and\or #TVM_MAPACCIDTOHTREEITEM
See MSDN remark
Ok i have understand (Yes i know..it's a miracle

)
mAPIster wrote:When enumerate the gadget all items you will discover that there are 7 rounds for Windows usage only
Euuhhh !!! not really understand

but if you say that...t's is right

The most important it's on all the machines of the world it's the same behavior
mAPIster wrote:Previous post updated
Select item as it should be
I have not understand that too
When i run your code, the drive "C:" is already expanded
Then...if i want change the color of the "Canoscan" folder...how can i do because it is between 9 and 10
Fangbeast wrote:I think we need to convince MS to add in a KCC_ API with an excitement level variable:):)
Yes..you have right
Fangbeast wrote:/me bows to the mighty wizard, teaching the kcc apprentice is a full time job for a wizard:):)
You have again right, I have lost count of the number of nice members "Sparkie, Netmaestro, Srod, Celtic, etc ..." who have abandoned this quest

Re: PB Special ExplorerTreeGadget() {Windows]
Posted: Fri Jul 14, 2023 7:26 pm
by RASHAD
Hi KCC
1- Make sure that the target folder is visible (CanoScan)
2- Execute
RUN
Code: Select all
#TV_FIRST = $1100
#TVM_MAPACCIDTOHTREEITEM = (#TV_FIRST + 42)
#TVM_MAPHTREEITEMTOACCID = (#TV_FIRST + 43)
Global selitem,selitem2,selitem3
Procedure.s GetItemText(TV_H)
text.s = Space(#MAX_PATH)
pitem.TV_ITEM
pitem\mask = #TVIF_TEXT
pitem\hItem = SendMessage_(TV_H, #TVM_GETNEXTITEM, #TVGN_CARET,0)
pitem\pszText = @text
pitem\cchTextMax = #MAX_PATH
If (pitem\hItem)
SendMessage_(TV_H, #TVM_GETITEM, 0, @pitem)
ProcedureReturn PeekS(pitem\pszText)
EndIf
EndProcedure
Procedure winCB(hWnd, uMsg, wParam, lParam)
Protected result, row
Protected *TVCDHeader.NMTVCUSTOMDRAW
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NOTIFY
*pnmh.NMHDR = lParam
Select *pnmh\code
Case #NM_CUSTOMDRAW
*TVCDHeader.NMTVCUSTOMDRAW = lParam
Select *TVCDHeader\nmcd\dwDrawStage
Case #CDDS_PREPAINT
result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
If *TVCDHeader\nmcd\uItemState & #CDIS_SELECTED
*TVCDHeader\clrTextBk = $F39502
*TVCDHeader\clrText = $FFFFFF
Else
row = *TVCDHeader\nmcd\dwItemSpec
If row = selitem Or row = selitem2 Or row = selitem3
*TVCDHeader\clrTextBk = $00FF00
*TVCDHeader\clrText = $0000FF
Else
*TVCDHeader\clrTextBk = $FFFFFF
*TVCDHeader\clrText = $FF0000
EndIf
EndIf
result = #CDRF_DODEFAULT
EndSelect
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0, 0, 0, 400, 500, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0,0)
ExplorerTreeGadget(0, 10, 10, 380, 450, "C:\*.*", #PB_Explorer_AlwaysShowSelection)
ButtonGadget(1,10,470,80,24,"RUN")
selitem = SendMessage_(GadgetID(0), #TVM_MAPACCIDTOHTREEITEM,10,0)
selitem2 = SendMessage_(GadgetID(0), #TVM_MAPACCIDTOHTREEITEM,11,0)
SetWindowCallback(@winCB())
InvalidateRect_(GadgetID(0),0,1)
list_Count = SendMessage_(GadgetID(0), #TVM_GETCOUNT,0,0)
itemH = SendMessage_(GadgetID(0), #TVM_GETNEXTITEM, #TVGN_FIRSTVISIBLE,0)
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
HideGadget(0,1)
list_Count = SendMessage_(GadgetID(0), #TVM_GETCOUNT,0,0)
For n = 0 To list_Count
mselitem = SendMessage_(GadgetID(0), #TVM_MAPACCIDTOHTREEITEM,n,0)
If Not mselitem
list_Count + 1
EndIf
If mselitem
SendMessage_(GadgetID(0), #TVM_SELECTITEM,#TVGN_CARET,mselitem)
If GetItemText(GadgetID(0)) = "CanoScan"
selitem3 = mselitem
EndIf
EndIf
Next
SendMessage_(GadgetID(0), #TVM_SELECTITEM,#TVGN_CARET,itemH)
HideGadget(0,0)
EndSelect
EndSelect
Until Quit = 1