Author Topic: Reorder Tab control using Drag/Drop  (Read 1112 times)

iancasey

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Reorder Tab control using Drag/Drop
« on: July 30, 2021, 12:05:51 AM »
I added some drag/drop code to reorder Tabs to my MoveAnchor demo.
I used some code from AddTabb/RemTab functions and found some help for this on Gary Beanes website. 

https://bcxbasiccoders.com/bcxusers/ian/programs/TabReOrderAnchor.zip

I hope this helps.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1885
    • View Profile
Re: Reorder Tab control using Drag/Drop
« Reply #1 on: July 30, 2021, 02:25:49 PM »
Hi Ian ...

That is useful.  Thanks!

I think it would improve the UI tremendously if, while dragging, the tab-in-motion could be highlighted somehow.

Food for thought ...

Robert

  • Hero Member
  • *****
  • Posts: 1141
    • View Profile
Re: Reorder Tab control using Drag/Drop
« Reply #2 on: July 30, 2021, 03:28:36 PM »
I added some drag/drop code to reorder Tabs to my MoveAnchor demo.
I used some code from AddTabb/RemTab functions and found some help for this on Gary Beanes website. 

https://bcxbasiccoders.com/bcxusers/ian/programs/TabReOrderAnchor.zip

I hope this helps.

Hi Ian :

I really like this. It's a great demo.

C++ compilers hate it.

Remove line 47,
Code: [Select]
GLOBAL Days$[7]
nobody needs it, even BCX issues a warning
Code: [Select]
Two Variables Line 49 in Module: TabReOrderAnchor.bas : Days[7]=[BCXSTRSIZE] as char *  previously defined at Line 47 in Module: TabReOrderAnchor.bas : Days[7][BCXSTRSIZE] as char *
The array declaration
Code: [Select]
SET Days$[7]
does it all.

Also, for C++, a cast is needed, in line 409 change from
Code: [Select]
   pa = malloc(SIZEOF(*pa))
to
Code: [Select]
   pa = (LPANCHOR)malloc(SIZEOF(*pa))

iancasey

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: Reorder Tab control using Drag/Drop
« Reply #3 on: July 30, 2021, 11:19:57 PM »
Thanks for the input,
I tried changing the cursor when moving the tab
Line  136 should have been:
  SetSystemCursor(LoadCursor(0,IDC_HAND),OCR_NORMAL)
But it doesn't like to be reset. 

I'm not sure about BCX_CURSOR, it doesn't work for me.


iancasey

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: Reorder Tab control using Drag/Drop
« Reply #4 on: November 29, 2021, 10:59:48 AM »
Hi All,
I have re-written this code to allow usage with multi-line Tab controls.
The trick being to turn of the BCX sub-classing of the Tab control and using code in WM_LBUTTONDOWN & WM_LBUTTONUP to complete the needed functions.

The code is at:
https://bcxbasiccoders.com/bcxusers/ian/programs/TabReOrderAnchor.zip

I also updated the Toaster code to use the new centering code.
https://bcxbasiccoders.com/bcxusers/ian/programs/ToasterA.zip

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1885
    • View Profile
Re: Reorder Tab control using Drag/Drop
« Reply #5 on: November 29, 2021, 12:01:28 PM »
Hi All,
I have re-written this code to allow usage with multi-line Tab controls.
The trick being to turn of the BCX sub-classing of the Tab control and using code in WM_LBUTTONDOWN & WM_LBUTTONUP to complete the needed functions.

The code is at:
https://bcxbasiccoders.com/bcxusers/ian/programs/TabReOrderAnchor.zip

I also updated the Toaster code to use the new centering code.
https://bcxbasiccoders.com/bcxusers/ian/programs/ToasterA.zip

Thanks Ian,

That's a nice improvement and a simple-to-use implementation.