March 29, 2024, 05:39:38 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


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.

sapero

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
SetInsertmarkColor(0);
}
declare virtual OnBeginDrag(NMTOOLBAR *nmtb),LRESULT
{
m_dragfrom = CommandToIndex(nmtb->iItem);
SetInsertmark(m_dragfrom,0);
}
declare virtual OnMouseMove(int x,int y,DWORD flags),LRESULT
{
m_pt.x=x;
m_pt.y=y;
LRESULT res = DoDefault(); // call the original toolbar.wndproc
if ((m_dragfrom != -1) && (flags & 1))
{
TBINSERTMARK im;
InsertmarkHitTest(&m_pt,&im);
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

sapero

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