Checking the checkboxes in front of the icon

The place for threads about version 1.x of TimoSoft ExplorerTreeView.
Post Reply
Johannes

Checking the checkboxes in front of the icon

Post by Johannes »

Hi There,
the answer you gave me yesterday helped me a lil out of my problem, but I havn't found a way to get a information which boxes are checked. So I searched for a way to save all checked boxes into a mySQL DB. Right now I'm running your ocx in my AccessXP.

nice would be something like:
for each checkedBox in ExplorerTreeView
somecode
next

THX alot in advance, and sorry for my crappy english

MfG Johannes
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: Checking the checkboxes in front of the icon

Post by TiKu »

Johannes wrote:Hi There,
the answer you gave me yesterday helped me a lil out of my problem, but I havn't found a way to get a information which boxes are checked. So I searched for a way to save all checked boxes into a mySQL DB. Right now I'm running your ocx in my AccessXP.

nice would be something like:
for each checkedBox in ExplorerTreeView
somecode
next
I finally should complete version 2.0 - this is just another situation where it would help much, because version 2.0 allows just what you've written.

However, here's the solution for version 1.x:

Code: Select all

  Dim hItem As Long

  ' ExplorerTreeView methods that return an item handle, return 0
  ' to identify the root item (only if ShowRoot = False) and -1 to
  ' "identify" a non-existent item.

  hItem = ExTvw1.GetFirstItem     ' can return 0
  If hItem = 0 Then hItem = -1     ' we'll handle 0 and -1 the same way
  While hItem <> -1
    If ExTvw1.ItemStateIconIndex(hItem) = 2 Then
      ' checked, so write the display name to the debug window
      Debug.Print ExTvw1.ItemHandleToDisplayName(hItem)
    End If

    ' get the next item to check
    hItem = findNextItemToProcess(hItem)     ' won't return 0
  Wend

Private Function findNextItemToProcess(ByVal hBaseItem As Long)
  Dim hDummy As Long
  Dim ret As Long

  ' ExplorerTreeView methods that return an item handle, return 0
  ' to identify the root item (only if ShowRoot = False) and -1 to
  ' "identify" a non-existent item.

  ret = ExTvw1.ItemGetFirstSubItem(hBaseItem)     ' won't return 0
  If ret = -1 Then
    ' the item doesn't have sub-items - try its successor
    ret = ExTvw1.ItemGetNextItem(hBaseItem)     ' won't return 0
    If ret = -1 Then
      ' there is no successor - try the parent item's successor
      ' and if we again don't have success, go upwards until
      ' we find an item with a successor
      ret = hBaseItem
      hDummy = -1
      Do
        ret = ExTvw1.ItemGetParentItem(ret)     ' can return 0
        If (ret <> 0) And (ret <> -1) Then
          hDummy = ExTvw1.ItemGetNextItem(ret)     ' no 0...
        Else
          ' this is a bit rude, but it improves performance,
          ' because we don't have to check <ret> again in
          ' the Loop While statement
          Exit Do
        End If
      Loop While hDummy = -1
      ' at this point hDummy is either a valid handle or -1
      ret = hDummy
    End If
  End If

  findNextItemToProcess = ret
End Function
I've done some tests and it seems to work. It might be a little bit slow if the control contains many items. In this case we could use the SendMessage api to operate directly on the underlying native treeview control. Let me know if you need the SendMessage-solution, too.

TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Johannes

Post by Johannes »

THX alot, that's working for me over here.

But there seems to be a bug:
if you expand a folder and deexpand it after that, you can't check the box of this folder to check all those subfolders. So once expanded you loose the "parent" ability of a folder.

btw, can your Treeview return the full path with the code you posted?

THX alot again,
MfG Johannes
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Post by TiKu »

Johannes wrote:But there seems to be a bug:
if you expand a folder and deexpand it after that, you can't check the box of this folder to check all those subfolders. So once expanded you loose the "parent" ability of a folder.
That's how the Windows native treeview (SysTreeView32) works. You'll have to check the subfolders yourself in the ItemStateIconChanged event. The TechDemo sample does this.
However, I just noticed that this event isn't raised if the state image was changed using the mouse. It's just raised on changes that are done via the keyboard. I'll fix this bug.
Johannes wrote:btw, can your Treeview return the full path with the code you posted?
Yes, to get the filesystem path of an item, use ItemHandleToFSPath. To get the tree-path (i. e. the path that the item has in the treeview control) use ItemHandleToTreePath.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Guest

Post by Guest »

Wow...great. Really nice job on this thingy man :)

I created a VB 6.0 file with this ocx, and I didn't needed to register this ocx. Is this right?

So it works here on Access XP but not that good as I want it too...and on VB it works great (where it was designed for...I know ;) )

Would be nice if you can give a list of all Instructions for your TreeView, as I don't want to extract them all from your ocx (if you open it in a editor you can see some of them :mrgreen: )

THX alot...

MfG Johannes


btw: Dresden ist gar nicht soooo weit weg von hier :oops:
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Post by TiKu »

Anonymous wrote:Wow...great. Really nice job on this thingy man :)

I created a VB 6.0 file with this ocx, and I didn't needed to register this ocx. Is this right?
Thanks.:) You must register the control. VB6 did it for you when you integrated the control into your project.
Anonymous wrote:So it works here on Access XP but not that good as I want it too...and on VB it works great (where it was designed for...I know ;) )
Could you give me some more details about what's buggy on Access XP? If it's easy to fix, then why not make the control more compatible with other containers?
Anonymous wrote:Would be nice if you can give a list of all Instructions for your TreeView, as I don't want to extract them all from your ocx (if you open it in a editor you can see some of them :mrgreen: )
What do you mean? A list of all properties, methods and events? The VB object catalog (just hit F2 in the IDE) gives you such a list. AFAIR Access has something similiar. If you really need a more detailed list, I could write one - but not before March, because I don't have the time before.
Or do you mean a list of all API methods I'm using? Well, I'm using about 200 of them and many COM interfaces. Do you really need a list?;) If you wonder how I've implemented specific things, feel free to ask me. The control is closed source, but not closed knowledge.
btw: Dresden ist gar nicht soooo weit weg von hier :oops:
Genau genommen komme ich aus einem Dorf bei Döbeln (Nähe Riesa) und studiere hier "nur". Woher kommen Sie denn?
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Johannes

Post by Johannes »

TiKu wrote:Thanks.:) You must register the control. VB6 did it for you when you integrated the control into your project.
Well...I tried on 2 machines where this ocx wasn't registred (one Win2k and one WinXP). It was able tu runn there without any problems. But I tried a Win98 machine also and there was the registration problem. :cry:
TiKu wrote: Could you give me some more details about what's buggy on Access XP? If it's easy to fix, then why not make the control more compatible with other containers?
Well, when you try around with the registration status of this ocx sometimes you can't access it in MSAccess any more. Also you can't insert it in the Form and so on. Unfortunaly I wasn't able to reproduce it, so that I can say "Hey...thats it". But the failure had been 2 times since monday.
TiKu wrote: What do you mean? A list of all properties, methods and events? The VB object catalog (just hit F2 in the IDE) gives you such a list. AFAIR Access has something similiar. If you really need a more detailed list, I could write one - but not before March, because I don't have the time before.
Or do you mean a list of all API methods I'm using? Well, I'm using about 200 of them and many COM interfaces. Do you really need a list?;) If you wonder how I've implemented specific things, feel free to ask me. The control is closed source, but not closed knowledge.
Yes...that was it...just a small hit on F2 and everything seems to be more clearly. I'm not interested in those APIs...thx anyway.
TiKu wrote: Genau genommen komme ich aus einem Dorf bei Döbeln (Nähe Riesa) und studiere hier "nur". Woher kommen Sie denn?
Ich bin zwar aus NRW, nähe DDorf, aber dafür das dieses Forum ja die Welt ansprechen soll ist das scho nicht sooo weit weg.

MfG Johannes
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Post by TiKu »

I just noticed a small mistake in the code I posted:

Code: Select all

hItem = ExTvw1.GetFirstItem     ' can return 0
If hItem = 0 Then hItem = -1     ' we'll handle 0 and -1 the same way
GetFirstItem can't return 0. So the 2nd line isn't required.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Post Reply