carlosprotos,
Cita:
Empezado por carlosprotos
...tengo un problema con los Hotkeys en Delphi...cuando le agrego ALT+1 o ALT+K , o tambien CTRL+T , no me funciona la combinación...Quisiera saber si hay alguna función o fuente que me ayude con ese problema...
|
Revisa este código:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
KeyPreview := True;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If (GetKeyState(VK_CONTROL) < 0) and
(GetKeyState(VK_F1) < 0) and
(GetKeyState(Ord('7')) < 0)
then
MessageDlg('Ctrl + F1 + 7',mtInformation,[mbOK],0);
if (Shift = [ssCtrl]) and (Key = VK_F7) then
MessageDlg('Ctrl + F7',mtInformation,[mbOK],0);
if (Shift = [ssAlt]) and (Key = Ord('N')) then
MessageDlg('Alt + N',mtInformation,[mbOK],0);
if (Shift = [ssCtrl]) and (Key = Ord('N')) then
MessageDlg('Ctrl + N',mtInformation,[mbOK],0);
if (Shift = [ssAlt]) and (Key = Ord('1')) then
MessageDlg('Alt + 1',mtInformation,[mbOK],0);
end;
end.
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
private
procedure WM_KEYDOWN(var Msg : TMessage); Message WM_KEYDOWN;
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WM_KEYDOWN(var Msg : TMessage);
begin
If (GetKeyState(VK_CONTROL) < 0) and
(GetKeyState(VK_F1) < 0) and
(GetKeyState(Ord('7')) < 0)
then
MessageDlg('Ctrl + F1 + 7',mtInformation,[mbOK],0);
If (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_F7) < 0)
then
MessageDlg('Ctrl + F7',mtInformation,[mbOK],0);
If (GetKeyState(VK_MENU) < 0) and (GetKeyState(Ord('N')) < 0) then
MessageDlg('Alt + N',mtInformation,[mbOK],0);
If (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(Ord('N')) < 0) then
MessageDlg('Ctrl + N',mtInformation,[mbOK],0);
If (GetKeyState(VK_MENU) < 0) and (GetKeyState(Ord('1')) < 0) then
MessageDlg('Alt + 1',mtInformation,[mbOK],0);
end;
end.
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
procedure MessageHandler(var Msg: TMsg; var Handled: Boolean);
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MessageHandler
end;
procedure TForm1.MessageHandler(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.message = WM_KEYDOWN) then
begin
If (GetKeyState(VK_CONTROL) < 0) and
(GetKeyState(VK_F1) < 0) and
(GetKeyState(Ord('7')) < 0)
then
MessageDlg('Ctrl + F1 + 7',mtInformation,[mbOK],0);
If (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_F7) < 0)
then
MessageDlg('Ctrl + F7',mtInformation,[mbOK],0);
If (GetKeyState(VK_MENU) < 0) and (GetKeyState(Ord('N')) < 0) then
MessageDlg('Alt + N',mtInformation,[mbOK],0);
If (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(Ord('N')) < 0) then
MessageDlg('Ctrl + N',mtInformation,[mbOK],0);
If (GetKeyState(VK_MENU) < 0) and (GetKeyState(Ord('1')) < 0) then
MessageDlg('Alt + 1',mtInformation,[mbOK],0);
end;
end;
end.
El código anterior en Delphi 7 sobre Windows 7 Professional x32,
Muestra 3 métodos de Gestión de Combinaciones de Teclas.
Revisa esta información:
Espero sea útil
Nelson.