Skip to content

Commit

Permalink
Add a config menu item to the tray icon
Browse files Browse the repository at this point in the history
  • Loading branch information
BazzaCuda committed Sep 2, 2023
1 parent 585338d commit dff29ec
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 54 deletions.
16 changes: 8 additions & 8 deletions CustomMenu.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
<PostBuildEvent><![CDATA[copy $(OUTPUTPATH) $(PROJECTDIR)\SampleMenu\
:: copy $(OUTPUTPATH) F:\
$(PostBuildEvent)]]></PostBuildEvent>
<VerInfo_Release>6</VerInfo_Release>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.6.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.6.0;Comments=</VerInfo_Keys>
<VerInfo_Release>7</VerInfo_Release>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.7.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.7.0;Comments=</VerInfo_Keys>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">
Expand Down Expand Up @@ -206,19 +206,19 @@ $(PostBuildEvent)]]></PostBuildEvent>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win64\Debug\CustomMenu.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win64">
<RemoteName>CustomMenu.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="menu.png" Configuration="Release" Class="UWP_DelphiLogo44">
<Platform Name="Win32">
<RemoteDir>Assets\</RemoteDir>
<RemoteName>Logo44x44.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win64\Debug\CustomMenu.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win64">
<RemoteName>CustomMenu.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win32\Debug\CustomMenu.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>CustomMenu.exe</RemoteName>
Expand Down
Binary file modified CustomMenu.res
Binary file not shown.
2 changes: 1 addition & 1 deletion CustomMenuCommon.pas
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ TItemData = record
CM_NEW_ITEM_NAME = 'New Menu Item';
CM_REGISTRY_KEY = 'SOFTWARE\Classes\DesktopBackground\shell'; // don't add the trailing \
CM_CTRL_FILE_NAME = 'ctrl-click';
CM_HEIGHT_TRAY_MENU = 30;

IL2_CHEVRON = 0;
IL2_LUASHIELD = 1;
Expand Down Expand Up @@ -150,7 +151,6 @@ function createMiniIni: boolean;
try
ini.add('name=Right-Click me to open Config;icon=' + getExePath + 'CustomMenu.exe,0;hint=You can right-click any menu to open Config;');
ini.saveToFile(getIniFileName);
// sleep(1000); // make sure it gets saved to disk before buildAndShowTheMenu tries to read it.
finally
ini.free;
end;
Expand Down
93 changes: 49 additions & 44 deletions FormCustomMenu.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,7 @@ object CustomMenu: TCustomMenu
Left = 64
Top = 32
Bitmap = {
494C010104001800040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010105001800040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000002000000001002000000000000020
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand All @@ -2909,113 +2909,113 @@ object CustomMenu: TCustomMenu
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000FAF7ED18DBBA6DCDD6B0
5AE9D6B05AE9D6B05AE9D6B05AE9D6B05AE9D6B05AE9D6B05AE9D6B05AE9D6B0
5AE9D7B35FE2EDDDB76500000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000D4AC52F4D5AF56EEDDBF
79BDDDBF79BDDDBF79BDDDBF79BDDDBF79BDDDBF79BDDDBF79BDDDBF79BDDDBF
79BDDBBB6FCAD3AA4BFFF8F2E523000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF0E3C5500000
0000000000000000000000000000000000000000000000000000000000000000
000000000000D3AA4BFFEFE0BD5C000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF1E4C64FFAF6
EC19D3AA4BFFD3AA4BFFD3AA4BFFD3AA4BFFD3AA4BFFD3AA4BFFD3AA4BFFDCBD
74C300000000D3AA4BFFEEDFBC5D000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF1E4C64FFCFA
F50DE8D3A381E8D3A381E8D3A381E8D3A381E8D3A381E8D3A381E8D3A381EDDD
B86300000000D3AA4BFFEEDFBC5D000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF1E4C64F0000
0000000000000000000000000000000000000000000000000000000000000000
000000000000D3AA4BFFEEDFBC5D000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF1E4C64FFBF7
EE17D5AE55EFD5AE55EFD5AE55EFD5AE55EFD5AE55EFD5AE55EFD5AE55EFDEC1
7CB700000000D3AA4BFFEEDFBC5D000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF1E4C64FFBF8
F013DBBB71C7DBBB71C7DBBB71C7DBBB71C7DBBB71C7DBBB71C7DBBB71C7E3CB
929800000000D3AA4BFFEEDFBC5D000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF1E4C64F0000
0000000000000000000000000000000000000000000000000000000000000000
000000000000D3AA4BFFEEDFBC5D000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF1E4C64FFAF6
ED17D6B15CE6D6B15CE6D6B15CE6D6B15CE6D6B15CE6D6B15CE6D6B15CE6DFC3
81B000000000D3AA4BFFEEDFBC5D000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF1E4C64FFBF7
EF15DAB768D5DAB768D5DAB768D5DAB768D5DAB768D5DAB768D5DAB768D5E2C8
8BA300000000D3AA4BFFEEDFBC5D000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFE01D3AA4BFFF0E3C3550000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFE01D3AA4BFFEFE0BF59000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000D7B360E0D2A94BFED4AC
52F4D4AC52F4D4AC52F4D4AC52F4D4AC52F4D4AC52F4D4AC52F4D4AC52F4D4AC
52F4D4AC50F7D3AA4BFFFBF8F113000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000FDFCFB04EAD7AB75E1C7
89A6E1C789A6E1C789A6E1C789A6E1C789A6E1C789A6E1C789A6E1C789A6E1C7
89A6E4CC9398F9F3E72200000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down Expand Up @@ -3159,11 +3159,11 @@ object CustomMenu: TCustomMenu
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000424D3E000000000000003E000000
2800000040000000200000000100010000000000000100000000000000000000
000000000000000000000000FFFFFF0000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000FFFF00000000FFFFFFFF00000000EFF7
000000000000000000000000FFFFFF00FFFF0000000000008003000000000000
80010000000000001FF900000000000000090000000000000009000000000000
1FF9000000000000000900000000000000090000000000001FF9000000000000
000900000000000000090000000000001FF10000000000008001000000000000
8003000000000000FFFF000000000000FFFF00000000FFFFFFFF00000000EFF7
FDFF00000000C7E3FEFF0000000083C1FF7F00000000C183FFBF00000000E007
FFDF00000000F00FFFEF00000000F81FFFF700000000F81FFFEF00000000F00F
FFDF00000000E007FFBF00000000C183FF7F0000000083C1FEFF00000000C7E3
Expand All @@ -3174,6 +3174,11 @@ object CustomMenu: TCustomMenu
Images = imageList2
Left = 240
Top = 32
object menuConfig: TMenuItem
Caption = 'Open Config Window'
ImageIndex = 4
OnClick = menuConfigClick
end
object menuExit: TMenuItem
Caption = 'Exit ( or SHIFT-RightClick the desktop)'
Hint = 'SHIFT-RightClick the desktop to EXIT'
Expand Down
12 changes: 11 additions & 1 deletion FormCustomMenu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ TCustomMenu = class(TForm)
bottomPanel: TPanel;
btnDown: TSpeedButton;
btnUp: TSpeedButton;
menuConfig: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure menuTimerTimer(Sender: TObject);
procedure FormActivate(Sender: TObject);
Expand All @@ -63,6 +64,7 @@ TCustomMenu = class(TForm)
procedure btnUpMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure menuConfigClick(Sender: TObject);
private
FHook: THook;
FPt: TPoint;
Expand Down Expand Up @@ -673,7 +675,8 @@ function TCustomMenu.setMouseTrap: boolean;
LLMouseHook := TLowLevelMouseHook(Hook);

case (HookMsg.msg = WM_MOUSEMOVE) or (HookMsg.Msg = WM_MOUSEWHEEL) of TRUE: EXIT; end; // only interested in clicks
case LLMouseHook.HookStruct.Pt.Y > screen.WorkAreaRect.Bottom of TRUE: EXIT; end; // the mouse is over the taskbar/system tray
case LLMouseHook.HookStruct.Pt.Y > (screen.WorkAreaRect.Bottom - CM_HEIGHT_TRAY_MENU) of TRUE: EXIT; end;
// the mouse is over the taskbar/system tray
// if we add more menu options to the systray icon, this will need to be revisited.

mouseWnd := WindowFromPoint(LLMouseHook.HookStruct.Pt); // get the window this mouse message is for
Expand Down Expand Up @@ -935,6 +938,13 @@ procedure TCustomMenu.listBoxWndProc(var Msg: TMessage);
FListBoxWndProc(Msg); // process message
end;

procedure TCustomMenu.menuConfigClick(Sender: TObject);
begin
mainMenu.shutMenus;
case configFormOpen of TRUE: enableConfigForm;
FALSE: showConfigForm; end;
end;

procedure TCustomMenu.menuTimerTimer(Sender: TObject);
// We can't call buildAndShowTheMenu directly from the anonymouse (ha!) hook procedure in setMouseTrap.
// Instead, that procedure enables the timer (currently set to 10ms) and we immediately disable the timer
Expand Down

0 comments on commit dff29ec

Please sign in to comment.