Board index » cppbuilder » CTRL-A and CTRL-Z in TEdit descendant -- closed

CTRL-A and CTRL-Z in TEdit descendant -- closed


2003-11-10 03:15:35 PM
cppbuilder11
Quote
You can map the EM_UNDO message (or override WindowProc())
and intercept the message. As for "Select all," I can't seem to lose the
"ding..."
Okay, that was easy... I had tried to work with keybook hooks...
As for CTRL-A, keyboard hooks solved the problem:
TShiftState TestState;
TestState << ssCtrl;
...
if (Key == 65 && Shift == TestState) { // CTRL-A
if (Screen->ActiveForm != NULL &&
Screen->ActiveForm->ActiveControl != NULL)
{
// Enable CTRL-A (Select All) for edit fields
TWinControl *ActiveControl = Screen->ActiveForm->ActiveControl;
if (ActiveControl->InheritsFrom(__classid(TCustomEdit)))
((TCustomEdit*)ActiveControl)->SelectAll();
}
}
Ron Sommer
 
 

Re:CTRL-A and CTRL-Z in TEdit descendant -- closed

Ron Sommer wrote:
Quote
As for CTRL-A, keyboard hooks solved the problem:
Maybe keyboard hook means something different to you. Where
exactly do you test? I was trying WM_KEYDOWN and the
OnKeyDown event, not in a derived component but only subclassed.
Do you still get a beep?
 

Re:CTRL-A and CTRL-Z in TEdit descendant -- closed

I use an own event dispatcher component that enables all forms'
KeyPreview, and redirects it to an own message. It then lets any
component, that is interested in hooking keyboard messages, register
itself with the event dispatcher. However, the only component that does
that, is the main form, so actually I have set up an application-wide
key preview.
This main form then checks, if there is an active component, and if that
component is derived from TCustomEdit. If it is, it calls that
components' SelectAll(...) function, if CTRL-A is pressed.
With CTRL-Z, this didn't work - don't know why. I have therefore
followed your advice, intercept the EM_UNDO message and ignore it.
Therefore, there's no beep ...
Ron
 

{smallsort}

Re:CTRL-A and CTRL-Z in TEdit descendant -- closed

Ron Sommer wrote:
Quote
With CTRL-Z, this didn't work - don't know why. I have therefore
followed your advice, intercept the EM_UNDO message and ignore
it. Therefore, there's no beep ...
I only got the beep with the <ctrl>+ A. I thought you wanted all the
behavior wrapped into the component. Or do you create the event
dispatcher from within the component?
The win32.hlp topic "Edit Control Default Message Processing"
says of WM_CHAR:
"Writes a character to the single-line edit control and sends the
EN_UPDATE and EN_CHANGE notification messages to the
parent window. Writes a character to the multiline edit control.
Handles the accelerator keys for standard functions, such as
CTRL+C for copying and CTRL+V for pasting. In multiline edit
controls, also processes TAB, and CTRL+TAB keystrokes to
move among the controls in a dialog box and to insert tabs into
multiline edit controls. Uses the MessageBeep function for illegal
characters."
This may be the beep I am hearing. Somehow, setting the Key to
zero may not suppressing a subsequent WM_CHAR. I even tried
both both WM_KEYDOWN and WM_KEYUP.
 

Re:CTRL-A and CTRL-Z in TEdit descendant -- closed

Quote
I only got the beep with the <ctrl>+ A. I thought you wanted all the
behavior wrapped into the component.
That's not necessary, although it might be a better style... I'm glad it
works the way it does... ;-)
Quote
Uses the MessageBeep function for illegal characters."

This may be the beep I am hearing. Somehow, setting the Key to
zero may not suppressing a subsequent WM_CHAR.
MessageBeep does not produce a beep, but plays a WAV sound. Windows'
system sounds must be activated and assigned for that. But even with
system sounds enabled, I don't hear anything. Maybe because I'm using
single-line edits only...
Ron