Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM toolbars: how to drag and drop a button
#12
Function tb_drag_drop_hook
Code:
Copy      Help
;/Toolbar qm
function# hWnd message wParam lParam
int+ g_tb_move_htb g_tb_move_hfore
POINT+ g_tb_move_pos
POINT p

if(TB_DetectDragDropButton(&hWnd _s))
,out "dropped %s" _s

sel message
,case WM_INITDIALOG
,int htb=wParam
,QmRegisterDropTarget(htb hWnd 16)
,    case WM_SETCURSOR
,,if(lParam=WM_LBUTTONDOWN<<16|HTCLIENT)
,,,if(wParam=hWnd)
,,,else if(GetDlgCtrlID(wParam)=9999)
,,,,GetCursorPos &p; ScreenToClient wParam &p
,,,,if(SendMessage(wParam TB_HITTEST 0 &p)>=0) ret ;;button
,,,else ret
,,,
,,,GetCursorPos &g_tb_move_pos
,,,g_tb_move_htb=hWnd
,,,g_tb_move_hfore=win
,,,act hWnd ;;for SetCapture
,,,SetCapture hWnd
,,
,,case [WM_LBUTTONUP,WM_CANCELMODE]
,,g_tb_move_htb=0
,,SetCapture 0
,,act g_tb_move_hfore; err
,,
,,case WM_MOUSEMOVE
,,if(g_tb_move_htb=hWnd)
,,,RECT r; GetWindowRect hWnd &r
,,,GetCursorPos &p
,,,mov r.left+p.x-g_tb_move_pos.x r.top+p.y-g_tb_move_pos.y hWnd
,,,g_tb_move_pos=p
,
,case WM_DESTROY
,case WM_QM_DRAGDROP
,,;get button
,,htb=id(9999 hWnd)
,,;;POINT p;
,,xm p htb 1
,,int b=SendMessage(htb TB_HITTEST 0 &p) ;;toolbar line
,,if(b<1) ret
,,Acc a=acc("" "TOOLBAR" htb "" "" 0x1000)
,,a.elem=b+1; str buttonText=a.Name; err ret
,,out "dropped on '%s':" buttonText
,,
,,;get files
,,QMDRAGDROPINFO& di=+lParam
,,str s
,,foreach(s di.files) out s
pi


Messages In This Thread

Forum Jump:


Users browsing this thread: 8 Guest(s)