Alaska Software Inc. - Multi-select on xbpTreeView
Username: Password:
AuthorTopic: Multi-select on xbpTreeView
Jack DuijfMulti-select on xbpTreeView
on Sat, 16 Sep 2017 16:54:49 +0200
Hello,

Is it possible in a Treeview to mark multiple xbpTreeviewItems?
Now i can only mark 1 item.
Just like Windows explorer, i would like to select more items with the Ctrl-mouseclick and/or Shift+Cursor key


Regards
Jack Duijf

-------------------------------------------------------------
Also a member off the XXP (http://www.xxp.nl)

---
Deze e-mail is gecontroleerd op virussen door AVG.
http://www.avg.com
Jose Antonio Diego KerejeRe: Multi-select on xbpTreeView
on Tue, 19 Sep 2017 11:26:41 +0200
Hello,

> Is it possible in a Treeview to mark multiple xbpTreeviewItems?

No, I don't think so.

I guess it's not exactly what you want, but maybe ...

Regards. Diego


CheckTV.zip
Jim LeeRe: Multi-select on xbpTreeView
on Wed, 20 Sep 2017 00:52:34 +0200
hi,

nice solution but how to get "checked" Treeview Items ?
Jose Antonio Diego KerejeRe: Multi-select on xbpTreeView
on Wed, 20 Sep 2017 17:42:05 +0200
Jim,

That code was a response to the  "Change image of treeview item";  Peter 
Alderliesten; public.xbase++.gui; 12/23/2003 thread, so it was not meant to 
be functional.

In the new sample I added the :getSelection() method that returns an array 
with the selected items.

Regards. Diego


CheckTV.zip
Jim LeeRe: Multi-select on xbpTreeView
on Wed, 20 Sep 2017 18:59:24 +0200
hi,

thx to share your solution.


if someone just want Checkbox you can "pimp" it this Way

   oTree := XbpTreeView():new(oParent ,, {0,0}, {640,400} )
   oTree:hasLines    := .T.
   oTree:hasButtons  := .T.
   oTree:create()

   PimpMyTreeview(oTree)


#define GWL_STYLE                (-16)

PROCEDURE PimpMyTreeview(oObj)
LOCAL hWnd
LOCAL nStyle

   IF VALTYPE(oObj) = "O"
      hWnd   := oObj:GetHWnd()
      oObj:hide()
      nStyle := @user32:GetWindowLongA(hWnd, GWL_STYLE)
      nStyle := nOr(nStyle, TVS_CHECKBOXES)
      @user32:SetWindowLongA(hWnd , GWL_STYLE , nStyle )
      @user32:InvalidateRect(hWnd,1)
      oObj:show()
   ENDIF
RETURN

but i have not found a solution to get "checked" Items.
Problem :  XbpTreeViewItem() does not have a o:GetHWnd() while it is only 
FROM DataRef()
Jose Antonio Diego KerejeRe: Multi-select on xbpTreeView
on Thu, 21 Sep 2017 01:08:16 +0200
Jim,

Try this new sample.

Regards. Diego


CheckTV.zip
Jim LeeRe: Multi-select on xbpTreeView
on Thu, 21 Sep 2017 03:28:45 +0200
> Try this new sample.

GREAT Work !!!

> IF Int( ( nState / 2**12 ) ) = 2

is this the same as (from MSDN)
https://msdn.microsoft.com/en-us/library/windows/desktop/bb761408(v=vs.85).aspx
#define INDEXTOOVERLAYMASK(i)    ((i) << 12)

i wonder why Alaska have not include Windows Control TVS_CHECKBOXES Style 
into XbpTreeview()
... not sure about OS/2
http://www.laser.ru/evgen/articles/ARTofOS2/aos2p_0.html
http://www.laser.ru/evgen/articles/ARTofOS2/aos2p_23.html#m5

thx for share your Work
Jose Antonio Diego KerejeRe: Multi-select on xbpTreeView
on Thu, 21 Sep 2017 21:48:47 +0200
Jim,

> IF Int( ( nState / 2**12 ) ) = 2
> is this the same as (from MSDN)
> #define INDEXTOOVERLAYMASK(i)    ((i) << 12)

No, is  ((State) >> 12) = 2

In fact, this seems to be the most "orthodox" code: (( State & 
TVIS_STATEIMAGEMASK ) >> 12 ) = 2

And in plain Xbase++: Int( BAnd( nState, TVIS_STATEIMAGEMASK ) / 2**12  ) = 
2

In your second message in this thread I see that you use ot4xb. You could do 
it this way:

nRShift( nAnd( nState, TVIS_STATEIMAGEMASK ), 12 ) = 2

Regards. Diego
Jose Antonio Diego KerejeRe: Multi-select on xbpTreeView
on Mon, 25 Sep 2017 00:06:08 +0200
New methods.

Regards. Diego


CheckTV.zip
Jim LeeRe: Multi-select on xbpTreeView
on Mon, 25 Sep 2017 19:41:10 +0200
> New methods.

nice with Icons and Bold.
what about show "marked" subitem ( o:setData(oMarked) ) when press getmarked 
button ?
Jose Antonio Diego KerejeRe: Multi-select on xbpTreeView
on Tue, 26 Sep 2017 00:15:57 +0200
Jim,

Sorry, but I do not understand.

Regards. Diego
Jim LeeRe: Multi-select on xbpTreeView
on Tue, 26 Sep 2017 01:25:21 +0200
hi,

when i start your latest Demo i see only Animales and Vertebrados checked.
when press o:GetChecked i got all checked but i (still) see only Animales 
and Vertebrados.
Jose Antonio Diego KerejeRe: Multi-select on xbpTreeView
on Tue, 26 Sep 2017 11:56:48 +0200
Jim,

> when i start your latest Demo i see only Animales and Vertebrados checked.
> when press o:GetChecked i got all checked but i (still) see only Animales 
> and Vertebrados.

Now I understand. I did the sample in that way to show that the 
pre-selection of items does not modify their expanded attribute.

Anyway, I added a new parameter to the :setCheckeds( aCheckeds, lCheck, 
lExpandItems) method to enable both scenarios.

Regards. Diego


CheckTV.zip
Jack DuijfRe: Multi-select on xbpTreeView
on Wed, 20 Sep 2017 18:59:44 +0200
Hello Diego,

Thank you for the suggestion .
I have to examin the code and see if it works for me.



On Tue, 19 Sep 2017 11:26:41 +0200, Jose Antonio Diego Kereje wrote:

>Hello,
>
>> Is it possible in a Treeview to mark multiple xbpTreeviewItems?
>
>No, I don't think so.
>
>I guess it's not exactly what you want, but maybe ...
>
>Regards. Diego
Regards
Jack Duijf

-------------------------------------------------------------
Also a member off the XXP (http://www.xxp.nl)

---
Deze e-mail is gecontroleerd op virussen door AVG.
http://www.avg.com