Autor Beitrag
Kuyatzu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 22.09.07 09:18 
Hi Leute

Mein Hotkey für das Hiden meines Fensters geht nicht und ich weiß nicht warum

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
type
TForm1 = class(TForm)
//...
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    
 
  private
    { Private-Deklarationen }
    procedure WmHotkey(var Msg: TMessage); message WM_HOTKEY;

procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterHotKey(Handle, 1,MOD_SHIFT or MOD_ALT, Ord('H'))
end;

procedure TForm1.WmHotkey(var Msg: TMessage);
begin
  if (Msg.WParam = 1) then
  begin
  HIDE;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnregisterHotKey(Handle,1);
end;

es liegen keine Fehler vor denoch will mein hotkey nicht richtig funktionieren


Zuletzt bearbeitet von Kuyatzu am Sa 22.09.07 14:06, insgesamt 2-mal bearbeitet
Silas
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 478

Windows XP Home
Delphi 2005, RAD Studio 2007, MASM32, FASM, SharpDevelop 3.0
BeitragVerfasst: Sa 22.09.07 10:34 
Du darfst nicht das Handle von Application nehmen, sondern das deiner Form. Nimm statt ShowWindow(Application.Handle, SW_HIDE); einfach Hide;.

_________________
Religionskriege sind nur Streitigkeiten darüber, wer den cooleren imaginären Freund hat ;-)
Kuyatzu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 22.09.07 13:51 
Es liegt nicht an Hide, es funktioniert der Hotkey einfach nicht Null Ahnung warum brauch Hilfe.
:shock: :shock: :shock: :shock: :shock: :shock:
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 22.09.07 13:58 
Ist diese Tastenkombination denn noch frei? RegisterHotkey liefert afaik einen boolean zurück, der angibt ob der Hotkey installiert wurde oder nicht.

_________________
We are, we were and will not be.
Kuyatzu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 22.09.07 14:05 
Glaub nicht das es daran liegt, da ich verschiedene hotkeys ausprobiert habe.
Aber es hat nie funktioniert.In diesem Fall ist mein Hotkey "schift+alt+H" aber es geht nicht.
Silas
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 478

Windows XP Home
Delphi 2005, RAD Studio 2007, MASM32, FASM, SharpDevelop 3.0
BeitragVerfasst: Sa 22.09.07 14:17 
Ich hab deinen Quelltext mal bei mir getestet, und er funktioniert einwandfrei. Das Problem muss wohl in einem anderen Teil des Codes liegen...

_________________
Religionskriege sind nur Streitigkeiten darüber, wer den cooleren imaginären Freund hat ;-)
Kuyatzu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 22.09.07 14:23 
Ich hab es noch einmal in einer neuen form ausprobiert und komm auf gleiche Ergebnis.
Kannst du mir ein gefallen tun und mir dein Source geben
Silas
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 478

Windows XP Home
Delphi 2005, RAD Studio 2007, MASM32, FASM, SharpDevelop 3.0
BeitragVerfasst: Sa 22.09.07 14:27 
Bitteschön :wink: :

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen }
    procedure HK(var Msg:TMessage); message WM_HOTKEY;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  RegisterHotKey(Handle, 1, MOD_SHIFT or MOD_ALT, Ord('H'))
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnRegisterHotKey(Handle, 1);
end;

procedure TForm1.HK(var Msg:TMessage);
begin
  if Msg.wParam = 1 then ShowMessage('Hotkey');
end;

end.


Der Rest ist einfach eine neue VCL-Anwendung (Win32).

_________________
Religionskriege sind nur Streitigkeiten darüber, wer den cooleren imaginären Freund hat ;-)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 22.09.07 14:30 
Nur der Sicherheit halber...die Prozeduren sind den entsprechenden Events zugeordnet, oder?

_________________
We are, we were and will not be.
Kuyatzu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 22.09.07 22:37 
naja ich glaub schon ich habe den source vonuser profile iconSilas
der soll richtig sein und auch funktionieren tut er aber bei mir nicht ich bin echt ratlos.
Ich weiß nicht mehr was ich noch machen soll. :( :shock: :? :cry: :( :shock: :? :cry:
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 23.09.07 07:55 
Du glaubst schon? :roll:

Klick mal auf deine Form, klicke im OI auf Events und guck nach, ob da die passenden Prozeduren eingetragen sind...

_________________
We are, we were and will not be.
Kuyatzu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: So 23.09.07 13:15 
So ich habe mein Problem gefunden und zwar will der RegisterHotKey in  procedure TForm1.FormCreate(Sender: TObject); nicht ausführen ich hab es jetzt via Button gemacht und da klappt es.
Dennoch wüsste ich gerne warum es mit FormCreate nicht klappt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 23.09.07 13:27 
Genau aus dem Grund, den user profile iconGausi gerade genannt hat, vermutlich... :roll:
Es reicht nicht, den Quelltext einfach so hinzuschreiben, du musst schon auch die Methoden den entsprechenden Events zuordnen, in diesem Fall musst du auf das Formular klicken und dann im Objektinspektor auf Ereignisse klicken und unter OnCreate die Methode FormCreate eintragen...
Kuyatzu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: So 23.09.07 13:59 
OK jetzt ist es geschafft
danke für eure mühe mir zu helfen, hätte nicht gedacht das mir so ein noob Fehler unterkommt.
:oops: :oops: :oops: