Tap-And-Hold in Edit Controls
-
I have an Edit Box within a Dialog on a PPC application written with eVC++ (using MFC). I would like to implement a context menu for copy/cut/paste/undo within the Edit Box. I have read some articles about using SHRecognizeGesture to implement this feature. But, SHRecognizeGesture is usually used with the WM_LBUTTONDOWN message handler. I receive the OnLButtonDown message in my Dialog Class only when the cursor is outside of the Edit Box. Any help on how to proceed is much appreciated. :confused:
-
I have an Edit Box within a Dialog on a PPC application written with eVC++ (using MFC). I would like to implement a context menu for copy/cut/paste/undo within the Edit Box. I have read some articles about using SHRecognizeGesture to implement this feature. But, SHRecognizeGesture is usually used with the WM_LBUTTONDOWN message handler. I receive the OnLButtonDown message in my Dialog Class only when the cursor is outside of the Edit Box. Any help on how to proceed is much appreciated. :confused:
To intercept a WM_LBUTTONDOWN in an edit box you will have to subclass it. Create a new class that inherits from CEdit, and override the OnLButtonDown message handler to handle the tap-and-hold. To ensure that it will work in the dialog, make sure you force class wizard to use your class in the CDialog generation (use the Control setting, not the Value). Regards, João Paulo
-
To intercept a WM_LBUTTONDOWN in an edit box you will have to subclass it. Create a new class that inherits from CEdit, and override the OnLButtonDown message handler to handle the tap-and-hold. To ensure that it will work in the dialog, make sure you force class wizard to use your class in the CDialog generation (use the Control setting, not the Value). Regards, João Paulo
-
To intercept a WM_LBUTTONDOWN in an edit box you will have to subclass it. Create a new class that inherits from CEdit, and override the OnLButtonDown message handler to handle the tap-and-hold. To ensure that it will work in the dialog, make sure you force class wizard to use your class in the CDialog generation (use the Control setting, not the Value). Regards, João Paulo
Hello Joao Paulo, I have another newby question. I was able to create a context menu (cut/copy/paste/undo) with your help. But now, I do not know how to get a pointer to the text which I selected in the edit control so that I can use the CEdit::Cut,Copy,... methods. Can you help me to understand this? Thanks and Best Regards, Dave Schneider
-
Hello Joao Paulo, I have another newby question. I was able to create a context menu (cut/copy/paste/undo) with your help. But now, I do not know how to get a pointer to the text which I selected in the edit control so that I can use the CEdit::Cut,Copy,... methods. Can you help me to understand this? Thanks and Best Regards, Dave Schneider
Hi Dave, To get the selected portion of the text, you use the
EM_GETSEL
message or, if using MFC,CEdit::GetSel
. These will return indexes to the starting and ending characters of the selected substring. To retrieve the full string, useGetWindowText
. Regards, João Paulo