Skip to content

Commit

Permalink
Don't pass 0 as 'vk' to RegisterHotKey (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
lighterowl authored Jul 21, 2024
1 parent fff59ee commit 88e1fba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
25 changes: 18 additions & 7 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,6 @@ TMainForm = class(TBaseForm)
{$ifdef windows}
FFileManagerDefault: string;
FFileManagerDefaultParam: string;
FGlobalHotkey: string;
fGlobalHotkeyMod: string;
FUserDefinedMenuEx: string;
FUserDefinedMenuParam: string;
{$endif windows}
Expand Down Expand Up @@ -811,6 +809,9 @@ TMainForm = class(TBaseForm)
function SelectRemoteFolder(const CurFolder, DialogTitle: string): string;
procedure ConnectionSettingsChanged(const ActiveConnection: string; ForceReconnect: boolean);
procedure StatusBarSizes;
{$ifdef windows}
procedure SetUpWindowsHotKey;
{$endif windows}
private
procedure _onException(Sender: TObject; E: Exception);
end;
Expand Down Expand Up @@ -1007,6 +1008,19 @@ function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam):LR
result:=CallWindowProc(PrevWndProc,Ahwnd, uMsg, WParam, LParam);
end;

procedure TMainForm.SetUpWindowsHotKey;
var
VKKey, VKModifier: word;
begin
VKKey:=VKStringToWord(Ini.ReadString('Interface','GlobalHotkey',''));
VKModifier:=VKStringToWord(Ini.ReadString('Interface','GlobalHotkeyMod',''));
if VKKey <> 0 then begin
HotKeyID:=GlobalAddAtom('TransGUIHotkey');
PrevWndProc:=windows.WNDPROC(SetWindowLongPtr(Self.Handle,GWL_WNDPROC,PtrInt(@WndCallback)));
RegisterHotKey(Self.Handle,HotKeyID, VKModifier, VKKey);
end;
end;

{$endif windows}

function IsHash(Hash: String): boolean;
Expand Down Expand Up @@ -1822,11 +1836,8 @@ procedure TMainForm.FormCreate(Sender: TObject);
{$ifdef windows}
FFileManagerDefault:=Ini.ReadString('Interface','FileManagerDefault','explorer.exe');
FFileManagerDefaultParam:=Ini.ReadString('Interface', 'FileManagerDefaultParam', '/select,"%s"');
FGlobalHotkey:=Ini.ReadString('Interface','GlobalHotkey','');
FGlobalHotkeyMod:=Ini.ReadString('Interface','GlobalHotkeyMod','0');
HotKeyID := GlobalAddAtom('TransGUIHotkey');
PrevWndProc:=windows.WNDPROC(SetWindowLongPtr(Self.Handle,GWL_WNDPROC,PtrInt(@WndCallback)));
RegisterHotKey(Self.Handle,HotKeyID, VKStringToWord(FGlobalHotkeyMod), VKStringToWord(FGlobalHotkey));
SetUpWindowsHotKey;

// Create UserMenus if any in [UserMenu]
j:= 1;
repeat
Expand Down
6 changes: 6 additions & 0 deletions transgui.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@
<GenerateDebugInfo Value="False"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<Verbosity>
Expand Down Expand Up @@ -504,6 +509,7 @@
<Unit>
<Filename Value="trackeruri.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="TrackerUri"/>
</Unit>
<Unit>
<Filename Value="macosthemedetect.pas"/>
Expand Down
12 changes: 1 addition & 11 deletions transgui.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*************************************************************************************}

{$ifdef windows}
{$apptype gui}
{$endif windows}

program transgui;

{$mode objfpc}{$H+}
Expand All @@ -39,20 +35,14 @@
clocale,
{$endif}
{$endif}
Interfaces, // this includes the LCL widgetset
Forms
{ you can add units after this }, BaseForm, Main, rpc, AddTorrent,
Interfaces, Forms, BaseForm, Main, rpc, AddTorrent,
ConnOptions, varlist, TorrProps, DaemonOptions, About, IpResolver, download,
ColSetup, utils, ResTranslator, AddLink, MoveTorrent, AddTracker, Options,
passwcon;

//{$ifdef windows}
{$R *.res}
//{$endif}

begin
//Application.Scaled:=True; //travis doesnt compile

if not CheckAppParams then exit;

Application.Initialize;
Expand Down

0 comments on commit 88e1fba

Please sign in to comment.