Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM toolbars: how to drag and drop a button
#15
Function dlg_ole_drop_text
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dlg_ole_drop_text" &dlg_ole_drop_text 0 _hwndqm 0 0 0 0 1 -1)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;END DIALOG
;DIALOG EDITOR: "" 0x2020006 "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,QmRegisterDropTarget(hDlg hDlg 0)
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_QM_DRAGDROP
,QMDRAGDROPINFO& di=+lParam
,sel wParam
,,case 3 ;;drop
,,str s
,,if(!di.GetText(s)) ret
,,out s
,,ret DT_Ret(hDlg 1)
,
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Member function QMDRAGDROPINFO.GetText
Code:
Copy      Help
function! str&s [flags] ;;flags: 1 drag source must not delete text

;Extracts dropped text.
;Returns 1 if successful, 0 if failed.


s.fix(0)

int k=GetMod
sel(k) case [0,2] case else this.effect=DROPEFFECT_NONE; ret
if(flags&1) k=2

int i
for(i 0 this.formats.len) if(this.formats[i].cfFormat=CF_UNICODETEXT) break
if(i=this.formats.len) ret

STGMEDIUM sm
this.dataObj.GetData(&this.formats[i] &sm); err ret

int gs=GlobalSize(sm.hGlobal)-2; if(gs<=0) ret
s.all(gs 2)
byte* m=GlobalLock(sm.hGlobal); if(!m) ret
memcpy s m s.len
GlobalUnlock sm.hGlobal
ReleaseStgMedium(&sm)
s.ansi

sel k
,case 0 this.effect&DROPEFFECT_MOVE
,case 2 this.effect&DROPEFFECT_COPY

ret 1


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)