Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
solve the conflict between double keys
#1
I have a few problem that is difficult to solve. I added a search edit box above the list box. I can use the arrow keys to make a selection, use the space bar and the Enter key to confirm, But

1. I can't enter a space in the edit box because it will trigger a double click event

2. I want to use the Enter key to achieve: select and execute the first item in the list , Can't do it now , because it will trigger a double click event
* For example, when I type the letter on in the edit box, one will be displayed in the list, at this time, I want to key Enter, select and execute it

3. I want to use the ESC key to delete all the letters I have entered, but the dialog will close.
I tried to add code in the case IDCANCEL, but because it have two edit boxes, I don't know how to judge
In addition, I want to close the dialog box by pressing the esc key twice in succession. Can it be achieved?

4. I want to add a right-click event to an item in the list, which can execute external macros

The above question, for me, is very complicated, I very hope that someone can provide some help, thanks in advance.
Heart

Macro Macro3
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 256 154 "Dialog" "4"
;3 Edit 0x54030080 0x200 24 12 96 13 ""
;4 ListBox 0x54230101 0x200 24 28 96 93 ""
;5 Edit 0x54030080 0x200 136 12 96 13 ""
;6 ListBox 0x54230101 0x200 136 28 96 93 ""
;1 Button 0x54030001 0x4 72 132 48 14 "OK"
;2 Button 0x54030000 0x4 136 132 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 4 5 6"
str e3 lb4 e5 lb6
lb4="one[]two[]three"
lb6="four[]five[]six"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SetTimer hDlg 1 10 0
,int he3=id(3 hDlg)
,SetProp he3 "wndproc" SubclassWindow(he3 &sub.EditSubclassProc3)
,
,SetTimer hDlg 2 10 0
,int he5=id(5 hDlg)
,SetProp he5 "wndproc" SubclassWindow(he5 &sub.EditSubclassProc5)
,
,case WM_TIMER
,sel wParam
,,case 1
,,KillTimer hDlg wParam
,,goto e3text
,,case 2
,,KillTimer hDlg wParam
,,goto e5text
,,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case EN_CHANGE<<16|3
,SetTimer hDlg 1 100 0
,case EN_CHANGE<<16|5
,SetTimer hDlg 2 100 0
,
,case LBN_DBLCLK<<16|4
,int i4=LB_SelectedItem(lParam)
,mes F"selected {i4+1}"
,
,case LBN_DBLCLK<<16|6
,int i6=LB_SelectedItem(lParam)
,mes F"selected {i6+1}"
,case IDOK
,case IDCANCEL
ret 1

;e3text
int hlb4=id(4 hDlg)
SendMessage hlb4 LB_RESETCONTENT 0 0
str s3 sEdit3.getwintext(id(3 hDlg)) 
foreach s3 lb4
,if(sEdit3.len and find(s3 sEdit3 0 1)<0) continue
,LB_Add hlb4 s3
ret

;e5text
int hlb6=id(6 hDlg)
SendMessage hlb6 LB_RESETCONTENT 0 0
str s5 sEdit5.getwintext(id(5 hDlg)) 
foreach s5 lb6
,if(sEdit5.len and find(s5 sEdit5 0 1)<0) continue
,LB_Add hlb6 s5
ret

#sub EditSubclassProc3
function# hWnd message wParam lParam

;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,
,case WM_GETDLGCODE
,sel(wParam) 
,,case [VK_RETURN,VK_SPACE]
,,ret DLGC_WANTALLKEYS

,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,SendMessage id(4 GetParent(hWnd)) message wParam lParam
,,ret
,,case [VK_RETURN,VK_SPACE]
,,SendMessage GetParent(hWnd) WM_COMMAND LBN_DBLCLK<<16|4 hWnd
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)


#sub EditSubclassProc5
function# hWnd message wParam lParam

;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,
,case WM_GETDLGCODE
,sel(wParam) 
,,case [VK_RETURN,VK_SPACE]
,,ret DLGC_WANTALLKEYS

,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,SendMessage id(6 GetParent(hWnd)) message wParam lParam
,,ret
,,case [VK_RETURN,VK_SPACE]
,,SendMessage GetParent(hWnd) WM_COMMAND LBN_DBLCLK<<16|6 hWnd
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)
#2
#1 change case [VK_RETURN,VK_SPACE]
to case VK_RETURN
#3
I just found out that by using the search results, using the carriage return or double-clicking on it, the result displayed in the dialog box is wrong. Huh

Please see the picture below

the code after Remove space, can solve the problem when typing, but lost the function of triggering the double-click event, It seems that this is the only way


Attached Files Image(s)
   
#4
mes F"selected {i4+1}" <---------------------thats why
#5
I don't understand much  Undecided
#6
just change code to this and it will show the selected text


Code:
Copy      Help
,case LBN_DBLCLK<<16|4
,LB_SelectedItem(lParam _s)
,mes F"selected {_s}"
#7
I use the Enter key, Message box is empty


Attached Files Image(s)
   
#8
first things first stop using that until you fix your code
you need to remove the props you set when dialog starts

you must always do this

Everytime you use
SetProp

you must also use 
RemoveProp
either when the dialog closes or the function/macro ends

    case WM_DESTROY
    RemoveProp he3 "wndproc"
    RemoveProp he5 "wndproc"

fix your code  like i suggested above.   then restart qm

    int i4=LB_SelectedItem(lParam _s)
    mes F"selected {i4} text  {_s}"
#9
Okay thank you
#10
In many search tools, there are the following search logic: 

1. After entering the keyword, if the required item is already in the first place in the list box, I can directly select and perform the operation by pressing Enter  (My code is currently not implemented)

2. Without entering the keyword, use the mouse, select the desired item in the list box, and press Enter to perform the operation.  (My code is currently not implemented, it Will close the dialog)

3. After entering the keyword, Use the arrow keys select the item in the list box to perform the operation. (my code has been implemented)

How to implement the first and second functions? Any suggestions are welcome, thanks in advance 
Heart Heart Heart
#11
Does this code still not work?

,case LBN_DBLCLK<<16|4
,LB_SelectedItem(lParam _s)
,mes F"selected {_s}"

If it still doesn't work there seems to be something wrong with your qm installation or your experiencing a bug that no one else has reported. I would suggest you to try and uninstall qm reboot pc then reinstall. Open a clean file and try code then. Because you cant seem to get any results or have errors from all functions that have optional function arguments. Something is definitely not right.
#12
Still showing empty  

I will reinstall the system later, thank you for your reminder.


I reinstalled the English version of the system, the test is OK

Is it related to the Chinese version of the system?
Huh

Below is an animated GIF

https://ibb.co/pnJ8pNg
#13
In the code below,  How to add two events to the Enter key, for example:
1. Enter directly in the edit box, the first item in the list will be executed.
2. If there is already an item selected in the list, press Enter in the edit box to execute the selected item.

In addition, the following code, there is a problem, the Enter key can not be used in the window after execution
Huh

 
Code:
Copy      Help
#sub EditSubclassProc
function# hWnd message wParam lParam
int cid=GetDlgCtrlID(hWnd)
int Phwnd= GetParent(hWnd)
;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,case WM_GETDLGCODE
,sel(wParam) case [VK_RETURN] ret DLGC_WANTALLKEYS
,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam ;;virtual key code
,,case VK_RETURN
,,;on enter in the edit box select the item in the list box
,,sel cid
,,,case 3
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(4 Phwnd)) id(4 Phwnd)
,,,case 7
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(10 Phwnd)) id(10 Phwnd)
,,,case 8
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(11 Phwnd)) id(11 Phwnd)
,,ret
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,;relay these keys to the listbox and not to the edit box
,,sel cid
,,,case 3
,,,SendMessage id(4 Phwnd) message wParam lParam
,,,case 7
,,,SendMessage id(10 Phwnd) message wParam lParam
,,,case 8
,,,SendMessage id(11 Phwnd) message wParam lParam
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)
#14
in reference to this 
"I reinstalled the English version of the system, the test is OK

Is it related to the Chinese version of the system? Huh

Below is an animated GIF

https://ibb.co/pnJ8pNg  "

you didn't test the correct code to see if the function would show the text as well
#15
Can display text successfully, I really tested

But the optional parameters are not tested successfully, it is very strange


http://www.quickmacros.com/forum/showthr...3#pid33363

Is this a bug?  Huh
#16
ok because the video only showed the numeric output. not the numeric output and text.

test this to see if it works

Function Function211
Code:
Copy      Help
str s ss sss
int i t
s="this is a test"
ss="for Win" 
i=4
t=132
sub.TestForWin(s sss ss i t)
out sss
#sub TestForWin
function ~s1 ~&result [~s2][ii][tt]
result.from(s1 " " ii " " s2 tt)
ret
#17
I just tested it again and can't output the text.  Huh

If you like, you can use teamviewer to connect to my computer and take a look at the situation. Currently my computer is an English system.


Attached Files Image(s)
   
#18
ya something is just not right there.
#19
what about this?
Function Function211
Code:
Copy      Help
str s ss sss
int i t
s="this is a test"
ss="for Win" 
i=4
t=132
sub.TestForWin(s sss ss i t)
out sss
#sub TestForWin
function ~s1 ~&result [~s2] [int'ii] [int'tt]
result.format("%s %i %s %i "s1 ii s2 tt)
ret

lol @ google translate

Something is wrong .Qm should not be doing that..
#20
Is successful


Attached Files Image(s)
   
#21
Very Interesting..

Qm is has code built in that if the variable is not defined it by default makes it an int 

what about this?

Function Function211
Code:
Copy      Help
str s ss sss
int i t
s="this is a test"
ss="for Win" 
i=4
t=132
sub.TestForWin(s sss ss i t)
out sss
#sub TestForWin
function ~s1 ~&result [~s2] [#ii] [#tt]
result.format("%s %i %s %i "s1 ii s2 tt)
ret
#22
Where is the problem? Is the result of my test the same as yours?   Angel
#23
all 3 codes work for me.

yes the desired output should be 

this is a test 4 for Win 132
#24
Is your system 64-bit? My system is 64-bit
#25
yes all my systems are 64 bit
win10 win7

does this work?
Function Function211
Code:
Copy      Help
str s ss sss
int i t
s="this is a test"
ss="for Win" 
i=4
t=132
sub.TestForWin(s sss ss i t)
out sss
#sub TestForWin
function ~s1 ~&result [~s2] [#ii] [#tt]
result.format("%s %i %s %i "s1 ii s2 tt)
ret
#26
That's too weird.  need to report the situation to administrator?
#27
probably but try these First and see what happens

Function Function211
Code:
Copy      Help
str s ss sss
int i t
s="this is a test"
ss="for Win" 
i=4
t=132
sub.TestForWin(s sss ss i t)
out sss
#sub TestForWin
function ~s1 ~&result [~s2][#ii][#tt]
result.format("%s %i %s %i "s1 ii s2 tt)
ret

Function Function211
Code:
Copy      Help
str s ss sss
int i t
s="this is a test"
ss="for Win" 
i=4
t=132
sub.TestForWin(s sss ss i t)
out sss
#sub TestForWin
function ~s1 ~&result [~s2][ii][tt]
result.format("%s %i %s %i "s1 ii s2 tt)
ret
#28
Unsuccessful


Attached Files Image(s)
   
#29
recompile them first the run again


Attached Files Image(s)
   
#30
Unable to use recompilation, prompt the same error as above


Forum Jump:


Users browsing this thread: 9 Guest(s)