You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
2.8 KiB
Plaintext
111 lines
2.8 KiB
Plaintext
unit HiddenForm;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, Vcl.Forms, Vcl.Controls, Generics.Collections;
|
|
|
|
type
|
|
THiddenForm = class(TForm)
|
|
procedure WMDisplayChange(var pMsg: TWMDisplayChange); message WM_DISPLAYCHANGE;
|
|
procedure WMExitSizeMove(var pMsg: TMessage); message WM_EXITSIZEMOVE;
|
|
public
|
|
//procedure CreateParams(var Params: TCreateParams); override;
|
|
procedure DefaultHandler(var Message); override;
|
|
procedure WndProc(var Msg: TMessage); override;
|
|
end;
|
|
|
|
var
|
|
Hidden: THiddenForm;
|
|
WM_FINDINSTANCE: Integer;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses
|
|
SciterLib, UtilLib, GlobalLib, RQUtil, RnQSysUtils, RnQMacros, mainDlg, CLBox, hook;
|
|
|
|
//procedure THiddenForm.CreateParams(var Params: TCreateParams);
|
|
//begin
|
|
// inherited CreateParams(params);
|
|
// Params.WndParent := Handle;
|
|
// Params.ExStyle := Params.ExStyle and not WS_EX_APPWINDOW;
|
|
//end;
|
|
|
|
procedure THiddenForm.DefaultHandler(var Message);
|
|
var
|
|
Len: Integer;
|
|
Data: String;
|
|
begin
|
|
with TMessage(Message) do
|
|
if Msg = WM_FINDINSTANCE then
|
|
begin
|
|
Result := 1337;
|
|
end else if Msg = WM_HANDLEICQLINK then
|
|
begin
|
|
SetLength(Data, MAX_PATH);
|
|
Len := GlobalGetAtomName(WPARAM, PChar(Data), MAX_PATH);
|
|
GlobalDeleteAtom(WPARAM);
|
|
SetLength(Data, Len);
|
|
ProcessICQLink(Data);
|
|
end else inherited DefaultHandler(message);
|
|
end;
|
|
|
|
procedure THiddenForm.WndProc(var Msg: TMessage);
|
|
begin
|
|
case Msg.Msg of
|
|
WM_HOTKEY:
|
|
begin
|
|
if HotkeysEnabled and not Locked then
|
|
ExecuteMacro(Macros[Msg.WParam].opcode);
|
|
end;
|
|
WM_WTSSESSION_CHANGE:
|
|
case Msg.WParam of
|
|
WTS_CONSOLE_CONNECT: IsLocked := False;
|
|
WTS_CONSOLE_DISCONNECT: IsLocked := True;
|
|
WTS_REMOTE_CONNECT: IsLocked := False;
|
|
WTS_REMOTE_DISCONNECT: IsLocked := True;
|
|
WTS_SESSION_LOGON: IsLocked := False;
|
|
WTS_SESSION_LOGOFF: IsLocked := True;
|
|
WTS_SESSION_LOCK: IsLocked := True;
|
|
WTS_SESSION_UNLOCK: IsLocked := False;
|
|
end;
|
|
else
|
|
inherited;
|
|
end;
|
|
end;
|
|
|
|
procedure THiddenForm.WMDisplayChange(var pMsg: TWMDisplayChange);
|
|
var
|
|
Size: TFormPos;
|
|
Cnt: Integer;
|
|
begin
|
|
Cnt := GetActiveMonitorCount;
|
|
if not (LastMonCnt = Cnt) then
|
|
begin
|
|
LastMonCnt := cnt;
|
|
if CLBox.MonPositions.TryGetValue(LastMonCnt, Size) then
|
|
begin
|
|
TThread.CreateAnonymousThread(procedure
|
|
begin
|
|
Sleep(1000);
|
|
TThread.Synchronize(nil, procedure
|
|
begin
|
|
UI.CL.SetPosition(Size.Left, Size.Top);
|
|
end);
|
|
end).Start;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure THiddenForm.WMExitSizeMove(var pMsg: TMessage);
|
|
begin
|
|
UI.CL.SavePositionForCurrentMonitorCount;
|
|
end;
|
|
|
|
initialization
|
|
WM_FINDINSTANCE := RegisterWindowMessage('Unique R&Q message');
|
|
|
|
end.
|