Autor Beitrag
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Do 31.03.05 16:16 
Hallo, ich möchte mein aktives Fenster per Tastendruck minimieren, doch es tut sich einfach nichts.

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:
43:
44:
45:
var
  Form1: TForm1;
  h2:hwnd;
implementation

{$R *.dfm}
function hideactive():boolean;
var
   hnd: HWND;

begin
      hnd := GetForegroundWindow;

      ShowWindow(hnd,SW_HIDE);
      h2:=hnd;


end;
function showactive():boolean;
var
   hnd: HWND;

begin

   if h2<>0 then begin
      ShowWindow(h2,SW_SHOW);
   end;
end;

procedure TForm1.hotkey(var msg:TMessage);
begin
   if (msg.LParamLo=MOD_CONTROL+MOD_CONTROL) and (msg.LParamHi=72) then begin
      hideactive();
   end;
   if (msg.LParamLo=MOD_CONTROL+MOD_CONTROL) and (msg.LParamHi=83) then begin
      showactive();
   end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
   id:=GlobalAddAtom('closewh');
   RegisterHotkey(handle,id,MOD_CONTROL+MOD_ALT,72);
   id:=GlobalAddAtom('closewh2');
   RegisterHotkey(handle,id,MOD_CONTROL+MOD_ALT,83);
   end;

Was mache ich falsch?

Hab noch was vergessen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  protected
     procedure hotkey(var msg:Tmessage); message WM_HOTKEY;
  private
      id:integer;
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;


Moderiert von user profile iconChristian S.: Beiträge zusammengefasst

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?


Zuletzt bearbeitet von Christian V. am Do 31.03.05 16:51, insgesamt 1-mal bearbeitet
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Do 31.03.05 16:24 
Dieser Schwachsinn mit AddGlobalAtom usw. wurde von Delphi-Source verbreitet, richtig? :twisted: (nein, das war nicht ernst gemeint :mrgreen: )

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.hotkey(var msg:TMessage);
begin
 case msg.wparam of
  1 : hideactive();
  2 : showactive();
 end; 
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
 RegisterHotkey(handle,1,MOD_CONTROL or MOD_ALT,72);
 RegisterHotkey(handle,2,MOD_CONTROL or MOD_ALT,83);
end;


Zuletzt bearbeitet von Karlson am Do 31.03.05 16:26, insgesamt 1-mal bearbeitet
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 31.03.05 16:24 
Hallo!

Bitte ändere den Titel des Topics, da er wenig über das eigentlich Thema verrät. Hier der entsprechende Absatz aus den Delphi-Forum.de Richtlinien:

Richtlinien hat folgendes geschrieben:
1.2 Beiträge
Bitte formuliere den Betreff Deiner Beiträge so, dass andere Mitglieder anhand dieser bereits das eigentliche Thema festmachen können. Beiträge wie etwa "Eine Anfängerfrage" oder "Weiß jemand, wie das geht?" lassen den Leser im Unklaren darüber, was das Thema der Diskussion ist.[...]

Einfach oben bei Deinem ersten Beitrag auf "Edit" klicken und den Titel ändern. Dank Dir!

Gruß,
Motzi :-)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Christian V. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Do 31.03.05 16:32 
Danke, jezt gehts. Was ich aber nicht verstehe ist warum es auf einmahl nicht mehr geht. ICh habe es schon einmal so gemacht und es hat funktioniert.
P.S: Der Schwachsinn :D habe ich aus meinem Delphi-6 Buch.
Und warum "or"? Ich möchte ja beides.

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?
fvolk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 203

Win XP (Home & Pro)
Delphi 2005 Pers
BeitragVerfasst: Do 31.03.05 18:53 
Bei Windows-API-Aufrufen werden sog. Flags fast immer mit or verknüpft. Da die Konstanten ja Zahlenwerte wiederspiegeln, kann man (also Windows) - soweit man diese Zahlen mit or verknüpft - aus den entstehenden Zahlen die Einzelzahlen wieder rausholen. (Natürlich nur, wenn sie intelligent gewählt sind.)

Vielleicht kann das jemand besser erklären.

_________________
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn jedermann ist überzeugt, dass er genug davon habe.
(René Descartes)
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 31.03.05 19:00 
user profile iconinvulnerabilis hat folgendes geschrieben:

Und warum "or"? Ich möchte ja beides.

Hier bedeutet or = beides. Falls die beiden Konstanten keine gemeinsamen Bits besitzen kannst du auch + schreiben.
Das or wird hier bitweise interpretiert. Beispiel: 000111 or 110000 = 110111