Autor Beitrag
DonKnilch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: So 13.11.05 17:15 
Hi

Ich habe bei einem meiner Programme einen Hotkey definiert (F12), mit dem das Programm aus der System Tray in den Vordergrund geschaltet wird. Unter Windows ME lief das noch wunderbar, aber mittlerweile geht das nicht mehr (unter XP). Hat jemand einen Vorschlag, wie das funktionieren könnte?

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

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mo 14.11.05 13:41 
Hi,
hier verstecke ich andere fenster auf Tastendruck, und zeige sie wieder an.
Den Hotkey musst du noch verändern, und, dass es deine Anwendung nimmt, und nicht die derzeitig im Vordergrunde stehende.
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:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
unit Sh;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,shellapi, CoolTrayIcon, ImgList, Menus, ComCtrls, StdCtrls,
  ExtCtrls;

type
  TForm1 = class(TForm)
    CoolTrayIcon1: TCoolTrayIcon;
    PopupMenu1: TPopupMenu;
    Close1: TMenuItem;
    Config1: TMenuItem;
    sow: TLabeledEdit;
    Hide: TLabeledEdit;
    procedure FormCreate(Sender: TObject);
    procedure Close1Click(Sender: TObject);
    procedure Config1Click(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  protected
     procedure hotkey(var msg:Tmessage); message WM_HOTKEY; //Prozedur für die Hotkeys
  private
      id:integer;
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  h2:hwnd;    
  o,x:integer;
implementation
uses
gamma;

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

begin
      if (isWindowVisible(h2)) or (h2<>0) then
      else
      begin
      hnd := GetForegroundWindow;
      ShowWindow(hnd,SW_MINIMIZE);
      ShowWindow(hnd,SW_HIDE);
      h2:=hnd;

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

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

procedure TForm1.hotkey(var msg:TMessage);
begin
   case msg.wparam of
  1 : hideactive();
  2 : showactive();
  3 : Form1.Close;
 end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
   MessageDlg(Format('Screen Width = %d' + #13#10 + 'Screen Height = %d',
//            [Screen.Width, Screen.Height]), mtInformation, [mbOK], 0); 
   RegisterHotkey(handle,1,MOD_CONTROL or MOD_ALT,72); //Hotkeys definieren
   RegisterHotkey(handle,2,MOD_CONTROL or MOD_ALT,83);
   RegisterHotkey(handle,3,MOD_CONTROL or MOD_ALT,67);


end;

procedure TForm1.Close1Click(Sender: TObject);
begin
Form1.Close;
end;

procedure TForm1.Config1Click(Sender: TObject);
begin
CoolTrayIcon1.ShowMainForm;


end;

Die Form ansich wird mit einer CoolTray-komponente gehandhabt.

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



BeitragVerfasst: Mo 14.11.05 21:16 
Ok, erstmal danke für deine Hilfe. Ich habe sie dann aber letztendlich nicht gebraucht, denn es handelte sich um ein ganz simples Problem. Meine Methode funktionierte, aber es lag daran, dass Windows XP scheinbar F12 nicht freigibt. Mit jeder anderen Taste geht es. Darum habe ich ganz einfach F11 stattdessen genommen und damit funktioniert es genauso wie vorher...

Bis dann