Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A few questions about editbox
#1
Hi guys,

i'm new here!

The following QM code is from the forum and I need some help:

There is a editorbox in the dialog box, I can drag and drop multiple files into the editing box

#1. Delete lines 27 and 28, it still works. In what case must it be added?

#2. How do I prevent adding duplicate file paths? (Do not display duplicate file paths)

#3. How to control code execution using the Ctrl key:
A. Drag and drop directly: Execute line 30
B. If the Ctrl key is held down during drag and drop, execute Line 32

#4. How to use Ctrl+a hotkey to select all text? here is the C++ implementation code, how to convert it into QM code?
 
Code:
Copy      Help
BOOL CMFCApplication1Dlg::PreTranslateMessage(MSG * pMsg)
{
,if (pMsg->message == WM_KEYDOWN)
,{
,,BOOL b = GetKeyState(VK_CONTROL) & 0x80;
,,CWnd *pActiveWnd = GetFocus();
,,DWORD nWndID = 0;
,,if (pActiveWnd)
,,{
,,,nWndID = pActiveWnd->GetDlgCtrlID();
,,}
,,if (b && (pMsg->wParam == 'a' || pMsg->wParam == 'A'))
,,{
,,,SendDlgItemMessage(nWndID, EM_SETSEL, 0, -1);
,,,return TRUE;
,,}
,}
,return CDialog::PreTranslateMessage(pMsg);
}

Solving these problems can help me better understand QM programming, Thanks for any help!
Aaron

Macro Macro2
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54231044 0x200 8 8 208 100 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,QmRegisterDropTarget(id(3 hDlg) hDlg 0)
,case WM_DESTROY
,case WM_COMMAND goto messages2
,
,case WM_QM_DRAGDROP
,QMDRAGDROPINFO& di=+lParam
,;sel wParam
,,;case 3 ;;drop
,,_s=di.files; _s+"[]"
,,_s.setsel(0 di.hwndTarget) ;;A: append
,,
,,;s.setwintext(di.hwndTarget) ;;B: Delete before add
,,ret DT_Ret(hDlg 1)
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#2
#3  and #4

Macro Macro5
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54221044 0x200 8 8 208 100 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str e3
e3=
;hello
;world

if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,QmRegisterDropTarget(id(3 hDlg) hDlg 0)
,DT_SetAccelerators(hDlg "401 Ca")
,case WM_DESTROY
,case WM_COMMAND goto messages2
,
,case WM_QM_DRAGDROP
,QMDRAGDROPINFO& di=+lParam
,;sel wParam
,,;case 3 ;;drop
,,_s=di.files; _s+"[]"
,,ifk(C)          ;; Ctrl
,,,_s.setwintext(di.hwndTarget) ;;B: Delete before add
,,else
,,,_s.setsel(0 di.hwndTarget) ;;A: append
,,ret DT_Ret(hDlg 1)
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 401 ;;Ctrl+A
,PostMessage(id(3 hDlg) EM_SETSEL, 0, -1)
ret 1


Forum Jump:


Users browsing this thread: 1 Guest(s)