Short cut keys doing function without alt
Kennzeichnen
7 Nachrichten - Alle ausblenden
/groups/adfetch?hl=de&adid=eiy59BEAAAAANF9yS50A0O2cHD0Q83HGFSRgCP-avRN4YT0eROC0jw
Bei der Gruppe, für die Sie eine Mitteilung verfassen, handelt es sich um eine Usenet-Gruppe. Wenn Sie in dieser Gruppe Nachrichten posten, ist Ihre E-Mail-Adresse für jeden im Internet sichtbar
Ihre Antwort wurde nicht gesendet.
Die Nachricht wurde übermittelt.
 
Von:
An:
Cc:
Nachtrag zu:
Cc hinzufügen | Nachtrag hinzufügen zu | Betreff bearbeiten
Betreff:
Bestätigung:
Geben Sie zur Bestätigung die im folgenden Bild angezeigten Zeichen oder die durchgesagten Zahlen ein, indem Sie auf das Eingabesymbol klicken. Hören Sie zu und geben Sie die gehörten Zahlen ein
 
1.  Rob  
Profil anzeigen   Übersetzen in die Sprache: Übersetzt (Original anzeigen)
 Weitere Optionen 29 Sep. 2001, 09:24
Newsgroups: borland.public.delphi.objectpascal
Von: "Rob" <r...@activitylinksystems.com>
Datum: Fri, 28 Sep 2001 20:50:06 -1000
Lokal: Sa 29 Sep. 2001 08:50
Betreff: Short cut keys doing function without alt
When I give a button a short cut, like the printer button, &Print, I expect
to have to press Alt-P.  When I' in an object, like a grid which does not
allow editing, and I press the letter P, I get the print button firing.  I
am trying to trap the keypress(or keydown) in the grid and do something when
I press the letter P.  I do not want to have the Print button fire.  Is
there a way to forces this behavior?  The keydown fires first and I can do
something there, but abort does not keep the focus from moving to the Print
button.

    Antwort an Autor    Weiterleiten  
Sie müssen sich anmelden, bevor Sie Nachrichten veröffentlichen können.
Bevor Sie eine Nachricht posten können, müssen Sie zunächst dieser Gruppe beitreten.
Bitte aktualisieren Sie vor dem Posten in den Abonnementeinstellungen Ihren Spitznamen.
Sie haben nicht die erforderliche Berechtigung zum Posten.
2.  Peter Below (TeamB)  
Profil anzeigen   Übersetzen in die Sprache: Übersetzt (Original anzeigen)
 Weitere Optionen 29 Sep. 2001, 15:59
Newsgroups: borland.public.delphi.objectpascal
Von: "Peter Below (TeamB)" <100113.1...@compuXXserve.com>
Datum: Sat, 29 Sep 2001 15:50:25 +0200
Lokal: Sa 29 Sep. 2001 15:50
Betreff: Re: Short cut keys doing function without alt

In article <3bb57583_2@dnews>, Rob wrote:
> When I give a button a short cut, like the printer button, &Print, I expect
> to have to press Alt-P.  When I' in an object, like a grid which does not
> allow editing, and I press the letter P, I get the print button firing.  I
> am trying to trap the keypress(or keydown) in the grid and do something when
> I press the letter P.  I do not want to have the Print button fire.  Is
> there a way to forces this behavior?  The keydown fires first and I can do
> something there, but abort does not keep the focus from moving to the Print
> button.

Disabling acelerators without Alt:

this is nothing specific to a string grid, it is standard Windows
behaviour: if the control having focus does not process character input
then Alt is not needed to have a character act as an accelerator.

To fix this, add a handler for CM_DIALOGCHAR to your form:

  private
    { Private declarations }
    procedure cmDialogChar( Var msg: TCMDialogChar );
      message CM_DIALOGCHAR;

procedure TForm1.cmDialogChar( Var msg: TCMDialogChar );
begin
  If ((msg.keydata and $20000000) = 0) Then
    msg.result := 1 // alt not down, eat key
  Else
    inherited;
end;

You can also use the forms OnShortcut event to process keys before the
controls on the form see them.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.


    Antwort an Autor    Weiterleiten  
Sie müssen sich anmelden, bevor Sie Nachrichten veröffentlichen können.
Bevor Sie eine Nachricht posten können, müssen Sie zunächst dieser Gruppe beitreten.
Bitte aktualisieren Sie vor dem Posten in den Abonnementeinstellungen Ihren Spitznamen.
Sie haben nicht die erforderliche Berechtigung zum Posten.
3.  Rob  
Profil anzeigen   Übersetzen in die Sprache: Übersetzt (Original anzeigen)
 Weitere Optionen 29 Sep. 2001, 21:04
Newsgroups: borland.public.delphi.objectpascal
Von: "Rob" <r...@activitylinksystems.com>
Datum: Sat, 29 Sep 2001 08:57:17 -1000
Lokal: Sa 29 Sep. 2001 20:57
Betreff: Re: Short cut keys doing function without alt
Thanks. Appreciate the reply.


    Antwort an Autor    Weiterleiten  
Sie müssen sich anmelden, bevor Sie Nachrichten veröffentlichen können.
Bevor Sie eine Nachricht posten können, müssen Sie zunächst dieser Gruppe beitreten.
Bitte aktualisieren Sie vor dem Posten in den Abonnementeinstellungen Ihren Spitznamen.
Sie haben nicht die erforderliche Berechtigung zum Posten.
4.  Rob  
Profil anzeigen   Übersetzen in die Sprache: Übersetzt (Original anzeigen)
 Weitere Optionen 29 Sep. 2001, 21:38
Newsgroups: borland.public.delphi.objectpascal
Von: "Rob" <r...@activitylinksystems.com>
Datum: Sat, 29 Sep 2001 09:32:40 -1000
Lokal: Sa 29 Sep. 2001 21:32
Betreff: Re: Short cut keys doing function without alt

>   If ((msg.keydata and $20000000) = 0) Then
>     msg.result := 1 // alt not down, eat key
>   Else
>     inherited;
> end;

I don't understand the (msg.keydata and $20000000).  Also, I would like to
do it in the Onshortcut, as I am not well  versed in adding a handler.

    Antwort an Autor    Weiterleiten  
Sie müssen sich anmelden, bevor Sie Nachrichten veröffentlichen können.
Bevor Sie eine Nachricht posten können, müssen Sie zunächst dieser Gruppe beitreten.
Bitte aktualisieren Sie vor dem Posten in den Abonnementeinstellungen Ihren Spitznamen.
Sie haben nicht die erforderliche Berechtigung zum Posten.
5.  Peter Below (TeamB)  
Profil anzeigen   Übersetzen in die Sprache: Übersetzt (Original anzeigen)
 Weitere Optionen 30 Sep. 2001, 15:39
Newsgroups: borland.public.delphi.objectpascal
Von: "Peter Below (TeamB)" <100113.1...@compuXXserve.com>
Datum: Sun, 30 Sep 2001 15:37:56 +0200
Lokal: So 30 Sep. 2001 15:37
Betreff: Re: Short cut keys doing function without alt

In article <3bb621b9$1_1@dnews>, Rob wrote:
> >   If ((msg.keydata and $20000000) = 0) Then
> >     msg.result := 1 // alt not down, eat key
> >   Else
> >     inherited;
> > end;

> I don't understand the (msg.keydata and $20000000).

The CM_DIALOGCHAR message is an "echo" of a WM_CHAR or WM_SYSCHAR message
Windows send to the application in response to a keystroke. Look at the
topics for these messages in win32.hlp. You will see that the messages
lparam encodes some information about the key (its keyboard scan code for
instance) and bit number 29 (counting from 0) in the 32 bit parameter
encodes the state of the Alt key. That is what the statement is testing, it
performs a bitwise AND of the parameter (which the TWMKey record type
cointains in the field named Keydata) with a value that has only the 29th
bit set. The result is <> 0 only if the bit was also set in msg.keydata.

If you look at SendMessage in win32.hlp you see that a message on the API
level consists of a message ID, two parameters (wparam and lparam, both 32
bits in Win32) and an optional result (also 32 bits) which the receiver of
the message can return to the sender. The "bottommost" layer of the VCL that
sits directly on top of the API packages a message into a record of type
TMessage, which is declared in the Messages unit:

  TMessage = packed record
    Msg: Cardinal;
    case Integer of
      0: (
        WParam: Longint;
        LParam: Longint;
        Result: Longint);
      1: (
        WParamLo: Word;
        WParamHi: Word;
        LParamLo: Word;
        LParamHi: Word;
        ResultLo: Word;
        ResultHi: Word);
  end;

In the 0 case you see the interpretation of parameters and result as 32 bit
values, the 1 case interprets the same data as a collection of 16 bit
values, which is sometimes useful. Even more useful are the message records
the Messages unit declares for most of the commom Windows messages. The
messages often encode several values into one of the parameters, which the
messages receiver has to laboriously pick apart again. The message records
do this for us automatically, e.g.

  TWMKey = packed record
    Msg: Cardinal;
    CharCode: Word;
    Unused: Word;
    KeyData: Longint;
    Result: Longint;
  end;

You can see this as another view of a TMessage record, it has the same total
size and just takes the wparam field apart into two 16 bit fields.

> Also, I would like to
> do it in the Onshortcut, as I am not well  versed in adding a handler.

Come on, surely you can copy and paste the code from my message <g>. It
would not be totally straightforward to do the same in OnShortcut.
OnShortcut fires in response to a CM_KEYDOWN message (an echo of WM_KEYDOWN
or WM_SYSKEYDOWN), so at this point Windows has not yet performed the task
of separating keys that create characters from those that do not. Only the
former will generate an additional WM_CHAR/WM_SYSCHAR message, which in turn
create CM_DIALOGCHAR. We have to detect characters ourselves in OnShortcut,
but fortunately there is an API function we can use for that:

procedure TForm1.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
var
  res: Integer;
begin
  res := MapVirtualKey( msg.CharCode, 2 );
  If res > 0 then
    Handled := (msg.keydata and $20000000) = 0;
end;

There is one major difference between using CM_DIALOGCHAR and OnShortcut you
need to be aware of: CM_DIALOGCHAR is only send to the form when the active
control does not process character input, so it does not collide with text
input in an edit control, for instance. OnShortcut, on the other hand, is
fired for *every* keystroke, regardless of what the active control may be.
So having an onShortcut handler like the above would disable all character
input into edit controls and the like!

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.


    Antwort an Autor    Weiterleiten  
Sie müssen sich anmelden, bevor Sie Nachrichten veröffentlichen können.
Bevor Sie eine Nachricht posten können, müssen Sie zunächst dieser Gruppe beitreten.
Bitte aktualisieren Sie vor dem Posten in den Abonnementeinstellungen Ihren Spitznamen.
Sie haben nicht die erforderliche Berechtigung zum Posten.
6.  Rob  
Profil anzeigen   Übersetzen in die Sprache: Übersetzt (Original anzeigen)
 Weitere Optionen 1 Okt. 2001, 07:46
Newsgroups: borland.public.delphi.objectpascal
Von: "Rob" <r...@activitylinksystems.com>
Datum: Sun, 30 Sep 2001 19:37:41 -1000
Lokal: Mo 1 Okt. 2001 07:37
Betreff: Re: Short cut keys doing function without alt
Thanks, I think..

"Peter Below (TeamB)" <100113.1...@compuXXserve.com> wrote in message
news:VA.00007a19.00f3e009@antispam.compuserve.com...


    Antwort an Autor    Weiterleiten  
Sie müssen sich anmelden, bevor Sie Nachrichten veröffentlichen können.
Bevor Sie eine Nachricht posten können, müssen Sie zunächst dieser Gruppe beitreten.
Bitte aktualisieren Sie vor dem Posten in den Abonnementeinstellungen Ihren Spitznamen.
Sie haben nicht die erforderliche Berechtigung zum Posten.
7.  Barry Kelly  
Profil anzeigen   Übersetzen in die Sprache: Übersetzt (Original anzeigen)
 Weitere Optionen 2 Okt. 2001, 17:31
Newsgroups: borland.public.delphi.objectpascal
Von: Barry Kelly <dyna...@eircom.net>
Datum: Tue, 02 Oct 2001 16:08:42 +0100
Lokal: Di 2 Okt. 2001 17:08
Betreff: Re: Short cut keys doing function without alt
In article <3bb80155_2@dnews>
        "Rob" <r...@activitylinksystems.com> wrote:

> Thanks, I think..

Would you mind minimizing the amount of quoted text you include from the
previous poster to the least necessary for intelligible continuation of
conversation? Thanks.

-- Barry

--
  If you're not part of the solution, you're part of the precipitate.
Team JEDI: http://www.delphi-jedi.org
NNQ - Quoting Style in Newsgroup Postings
  http://web.infoave.net/~dcalhoun/nnq/nquote.html


    Antwort an Autor    Weiterleiten  
Sie müssen sich anmelden, bevor Sie Nachrichten veröffentlichen können.
Bevor Sie eine Nachricht posten können, müssen Sie zunächst dieser Gruppe beitreten.
Bitte aktualisieren Sie vor dem Posten in den Abonnementeinstellungen Ihren Spitznamen.
Sie haben nicht die erforderliche Berechtigung zum Posten.

Eine Gruppe erstellen - Google Groups - Google-Startseite - Nutzungsbedingungen - Datenschutzbestimmungen
©2009 Google