December 06, 2022, 10:56:32 AM


Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........

Toolbar buttons dragdrop

Started by sapero, October 10, 2006, 05:51:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Hello, I'm testing toolbar drag-drop features, and found a problem with the insertmark.
Any time you call TB_SETINSERTMARK it will work, except while dragging a button will not ???
I can draw the insertmark manually (already done in report-view listview), but why it will not work while drag-drop operation?
Google has NULL to say.

Here's the snippet:
- in OnBeginDrag the insertmark is set to left from pressed button.
- in OnMouseMove the mouse position is stored in internal POINT, I do button hittest and try to move the insertmark, but it moves once to position ZERO and will move not more.
The im.iButton offset is correct (printed to console)
- in OnEndDrag the insertmark is removed and toolbar button is moved to new position
class CToolbarDemo : CToolbar2
int   m_dragfrom;
POINT m_pt;
declare virtual OnCreate()
m_dragfrom = -1; // set to invalid
declare virtual OnBeginDrag(NMTOOLBAR *nmtb),LRESULT
m_dragfrom = CommandToIndex(nmtb->iItem);
declare virtual OnMouseMove(int x,int y,DWORD flags),LRESULT
LRESULT res = DoDefault(); // call the original toolbar.wndproc
if ((m_dragfrom != -1) && (flags & 1))
int posTo = im.iButton;   // ok
SetInsertmark(-1,0);      // did not help
SetInsertmark(posTo,0);   // did not work; insertmark will not move from pos 0
return res;
declare virtual OnEndDrag(NMTOOLBAR *nmtb) // nmtb->iItem == drag.start
int posTo = HitTestEx(m_pt);
if (((posTo-m_dragfrom )>0) || ((m_dragfrom-posTo)>0)) MoveButton(m_dragfrom,posTo);
m_dragfrom = -1;     // set to invalid
SetInsertmark(-1,0); // works

The CToolbar2 class is a custom class with all TB_ messages wrapped to methods, so don't search for it :D

Ionic Wind Support Team

Good question.  Unfortunatley I don't have a good answer ;)

There is almost no information available for the toolbar insertion mark messages.  Even Microsoft has limited info. 

If you want to send me the complete test program I will play with it.
Ionic Wind Support Team


Ok, I've uploaded the whole project, in original CToolbar class the method OnMouseMove is not called.
This is experimental and very extended gui library, like AFC (MFC) where CButton has OnClick method, etc. ;D