[Win7] ExplorerTreeGadget, Where My picture?

Just starting out? Need help? Post your questions and find answers here.
User avatar
oryaaaaa
Addict
Addict
Posts: 825
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

[Win7] ExplorerTreeGadget, Where My picture?

Post by oryaaaaa »

I wrote this code, WinXP run OK, however Win7 don't display My Document to My Picture, My Video, My Music, and etc.
Could you tell me about solution?

Advanced Path Requester ( Multi Path Requester ) Tips
http://forum.purebasic.com/english/view ... 12&t=48990

Thank you
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: [Win7] ExplorerTreeGadget, Where My picture?

Post by em_uk »

My Documents is at the bottom of the list.
----

R Tape loading error, 0:1
User avatar
oryaaaaa
Addict
Addict
Posts: 825
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Re: [Win7] ExplorerTreeGadget, Where My picture?

Post by oryaaaaa »

Don't display My picture, My video, My musinc in my document on Windows7.

But My win7 pc did display it, only my father pc didn't display.
I use compiler option by Reqest user mode, but not change.

Where my picture?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: [Win7] ExplorerTreeGadget, Where My picture?

Post by RASHAD »

Hi oryaaaaa

Code: Select all

#TVGN_LASTVISIBLE = 10

Procedure AddItem(gadget.l, text.s)
  hRoot = SendMessage_(GadgetID(gadget), #TVM_GETNEXTITEM, #TVGN_LASTVISIBLE, 0)
  lpis.TV_INSERTSTRUCT
  lpis\hParent = SendMessage_(GadgetID(gadget), #TVM_GETNEXTITEM, #TVGN_PARENT, hRoot)
  lpis\hInsertAfter = hRoot
  lpis\item\mask = #TVIF_TEXT
  lpis\item\cchTextMax = Len(text)
  lpis\item\pszText = @text
  SendMessage_(GadgetID(gadget), #TVM_INSERTITEM, 0, @lpis)
EndProcedure

    OpenWindow(0, 0, 0, 300, 350, "ExplorerTreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ExplorerTreeGadget(0, 10, 10, 280, 280, "*.*")
    SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) | #TVS_CHECKBOXES|#TVS_TRACKSELECT)
    If OSVersion() = #PB_OS_Windows_7
      AddItem(0,"C:\Users\Public\Public Pictures")
      AddItem(0,"C:\Users\Public\Public Videos")
    EndIf 
    
    Repeat
    Select WaitWindowEvent()
       Case #PB_Event_CloseWindow
           Quit = 1          

   EndSelect
   
    Until Quit = 1

The rest is yours
Egypt my love
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: [Win7] ExplorerTreeGadget, Where My picture?

Post by em_uk »

RASHAD wrote:Hi oryaaaaa

Code: Select all


       Case #PB_Event_CloseWindow
           Quit = 1          

   EndSelect
   
    Until Quit = 1

Why are you using that work around? LOL :lol:

Anyway, RASHAD - do you know how to select the whole tree subsection, when the parent is clicked?
----

R Tape loading error, 0:1
User avatar
Shardik
Addict
Addict
Posts: 2060
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: [Win7] ExplorerTreeGadget, Where My picture?

Post by Shardik »

em_uk wrote:Anyway, RASHAD - do you know how to select the whole tree subsection, when the parent is clicked?
Unfortunately I am not RASHAD but perhaps you nevertheless may take a look
into my code example... :wink:

I have modified an old TreeGadget example which I had posted in the German
forum. The following example selects all subnodes that don't contain further
subnodes (tested in Windows XP SP3 x86 and Windows 7 SP1 x86):

Code: Select all

Procedure.I CheckForChildItems(ItemHandle)
  Shared SelectionState

  Protected TVItem.TV_ITEM 

  TVItem\Mask = #TVIF_CHILDREN | #TVIF_HANDLE | #TVIF_STATE 
  TVItem\hItem = ItemHandle 
  TVItem\StateMask = #TVIS_STATEIMAGEMASK 
  SendMessage_(GadgetID(0), #TVM_GETITEM, 0, @TVItem) 

  ; Checkbox in front of item 
  ; 4096 = without check mark, 8192 = with checkmark

  If (TVItem\State >> 12) - 1 
    SelectionState = 4096 
  Else 
    SelectionState = 8192 
  EndIf 

  If TVItem\cChildren = 1 
    ProcedureReturn #True 
  Else 
    ProcedureReturn #False 
  EndIf 
EndProcedure

Procedure TreeCallback(WindowHandle, Msg, wParam, lParam) 
  Shared SelectionState

  Protected ItemHandle
  Protected *NMTV.NM_TREEVIEW 
  Protected TVHitTest.TV_HITTESTINFO 
  Protected TVItem.TV_ITEM 
  Protected WantedSelectionState

  If Msg = #WM_NOTIFY 
    *NMTV = lParam 

    If *NMTV\Hdr\hwndFrom = GadgetID(0) 
      If *NMTV\Hdr\Code = #NM_CLICK 
        TVHitTest\Pt\x = WindowMouseX(0) - GadgetX(0) 
        TVHitTest\Pt\y = WindowMouseY(0) - GadgetY(0) 

        ItemHandle = SendMessage_(GadgetID(0), #TVM_HITTEST, 0, @TVHitTest) 

        If ItemHandle <> 0 
          If TVHitTest\Flags = #TVHT_ONITEMSTATEICON 
            SendMessage_(GadgetID(0), #TVM_SELECTITEM, #TVGN_CARET, TVHitTest\hItem) 

            If CheckForChildItems(ItemHandle) 
              WantedSelectionState = SelectionState 
              SendMessage_(GadgetID(0), #TVM_EXPAND, #TVE_EXPAND, ItemHandle) 
              ItemHandle = SendMessage_(GadgetID(0), #TVM_GETNEXTITEM, #TVGN_CHILD, ItemHandle) 

              While ItemHandle <> 0 
                If CheckForChildItems(ItemHandle) = #False 
                  TVItem\Mask = #TVIF_HANDLE | #TVIF_STATE 
                  TVItem\hItem = ItemHandle 
                  TVItem\StateMask = #TVIS_STATEIMAGEMASK 
                  TVItem\State = WantedSelectionState 
                  
                  SendMessage_(GadgetID(0), #TVM_SETITEM, 0, @TVItem) 
                EndIf 

                ItemHandle = SendMessage_(GadgetID(0), #TVM_GETNEXTITEM, #TVGN_NEXT, ItemHandle) 
              Wend 
            EndIf 
          EndIf 
        EndIf 
      EndIf 
    EndIf 
  EndIf 

  ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure 

OpenWindow(0, 1400, 100, 400, 400, "Select/unselect all subnodes (without subitems)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ExplorerTreeGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20, #PB_Compiler_Home + "*.*")
SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) | #TVS_CHECKBOXES)
SetWindowCallback(@TreeCallback()) 

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: [Win7] ExplorerTreeGadget, Where My picture?

Post by em_uk »

That's awesome! Exactly what I was looking for!

Thanks

:)
----

R Tape loading error, 0:1
Post Reply