Написал скрипт, сворачивающий инсталер в трей на странице установки [more]#define MyAppVerName "My Program"
#define MyAppExeName "MyProg.exe"
[Setup]
AppName=MyApp
AppVerName=MyApp Ver 1.0
DefaultDirName={pf}\MyApp
DefaultGroupName=MyApp
Compression=none
[Files]
Source: trayiconctrl.dll; DestDir: {tmp}; Flags: dontcopy
Source: InnoCallback.dll; DestDir: {tmp}; Flags: dontcopy
Source: "icon.ico"; Flags: dontcopy
Source: "icon1.ico"; Flags: dontcopy
Source: "icon2.ico"; Flags: dontcopy
Source: "icon3.ico"; Flags: dontcopy
Source: "icon4.ico"; Flags: dontcopy
Source: "D:\Games\Ballance.mdf"; DestDir: {app}; Flags: external
[no][code][/no]
type
TIconList = record
Icon1: UINT;
Icon2: UINT;
Icon3: UINT;
Icon4: UINT;
end;
TMenuItemClickProc = procedure(MenuIndex: Integer);
TMenuPopupProc = procedure(PopMenu: LongWord; var bShow: Boolean);
function WrapMenuItemClickProc(Callback: TMenuItemClickProc; ParamCount: Integer): LongWord; external 'wrapcallback@files:innocallback.dll stdcall';
function WrapMenuPopupProc(Callback: TMenuPopupProc; ParamCount: Integer): LongWord; external 'wrapcallback@files:innocallback.dll stdcall';
function LoadImage(hInst: UINT; ImageName: String; ImageType: UINT; X, Y: Integer; Flags: UINT): THandle; external 'LoadImageA@user32.dll stdcall';
function EnableMenuItem(hMenu: UINT; uIDEnableItem, uEnable: UINT): BOOL; external 'EnableMenuItem@user32.dll stdcall';
function IsWindowEnabled(hWnd: HWND): BOOL; external 'IsWindowEnabled@user32.dll stdcall';
function InitTrayIconCtrl(MainForm_Handle, WizardForm_Handle: THandle; uCallbackMessage: UINT;
szToolTip: String; icon: UINT; bHidden: BOOL; ShowTaskbarAppBtn: BOOL; MenuItems: String;
DefaultMnuIndex: Integer; MenuItemOnClickCallBack, MenuOnPopupCallBack: LongWord): Boolean;
external 'inittrayiconctrl@files:trayiconctrl.dll stdcall';
function UninitTrayIconCtrl(): Boolean; external 'uninittrayiconctrl@files:trayiconctrl.dll stdcall';
function HideTrayIcon(): Boolean; external 'hidetrayicon@files:trayiconctrl.dll stdcall';
function ShowTrayIcon(): Boolean; external 'showtrayicon@files:trayiconctrl.dll stdcall';
function SetIconList(pHIconList: TIconList; nNumIcons: UINT): Boolean; external 'seticonlist@files:trayiconctrl.dll stdcall';
function AnimateTrayIcon(nDelayMilliSeconds: UINT; nNumSeconds: Integer): Boolean; external 'animatetrayicon@files:trayiconctrl.dll stdcall';
function StopAnimation(): Boolean; external 'stopanimation@files:trayiconctrl.dll stdcall';
function ToggleWizardVisible(): Boolean; external 'togglewizardvisible@files:trayiconctrl.dll stdcall';
function ShowBalloon(szText, szTitle: String; dwIcon: DWORD; uTimeout: UINT; bWaitforPreMsg: Boolean): Boolean; external 'showballoon@files:trayiconctrl.dll stdcall';
function HideBalloon(): Boolean; external 'hideballoon@files:trayiconctrl.dll stdcall';
function WizardFormInTray(): Boolean; external 'wizardformintray@files:trayiconctrl.dll stdcall';
const
WM_USER = $400;
WM_ICON_NOTIFY = WM_USER + 22;
IMAGE_ICON = 1;
LR_LOADFROMFILE = $10;
NIIF_NONE = 0;
NIIF_INFO = $1;
NIIF_WARNING = $2;
NIIF_ERROR = $3;
MF_BYPOSITION = $400;
MF_ENABLED = 0;
MF_GRAYED = 1;
procedure TrayMenuItemOnClick(MenuItemIndex: Integer);
begin
if not IsWindowEnabled(WizardForm.Handle) then exit;
Case MenuItemIndex of
0: ToggleWizardVisible;
2: AnimateTrayIcon(40, -1);
3: StopAnimation();
5: MainForm.ShowAboutBox;
7: WizardForm.Close;
end;
end;
procedure TrayMenuOnPopup(PopMenu: LongWord; var bShow: Boolean);
begin
bShow := IsWindowEnabled(WizardForm.Handle);
if WizardFormInTray() then
begin
EnableMenuItem(PopMenu, 5, MF_BYPOSITION or MF_GRAYED);
EnableMenuItem(PopMenu, 7, MF_BYPOSITION or MF_GRAYED);
end else begin
EnableMenuItem(PopMenu, 5, MF_BYPOSITION or MF_ENABLED);
EnableMenuItem(PopMenu, 7, MF_BYPOSITION or MF_ENABLED);
end;
end;
procedure InitializeWizard();
begin
ExtractTemporaryFile('icon.ico');
ExtractTemporaryFile('icon1.ico');
ExtractTemporaryFile('icon2.ico');
ExtractTemporaryFile('icon3.ico');
ExtractTemporaryFile('icon4.ico');
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
AniIcon: TIconList;
Ico: UINT;
MenuStrs: String;
MenuItemClickCallback: LongWord;
MenuPopupCallback: LongWord;
begin
if CurStep = ssInstall then begin
MenuItemClickCallback := WrapMenuItemClickProc(@TrayMenuItemOnClick, 1);
MenuPopupCallback := WrapMenuPopupProc(@TrayMenuOnPopup, 2);
AniIcon.Icon1 := LoadImage(0, ExpandConstant('{tmp}\icon1.ico'), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
AniIcon.Icon2 := LoadImage(0, ExpandConstant('{tmp}\icon2.ico'), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
AniIcon.Icon3 := LoadImage(0, ExpandConstant('{tmp}\icon3.ico'), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
AniIcon.Icon4 := LoadImage(0, ExpandConstant('{tmp}\icon4.ico'), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
SetIconList(AniIcon, SizeOf(AniIcon) div SizeOf(AniIcon.Icon1));
Ico := LoadImage(0, ExpandConstant('{tmp}\icon.ico'), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
MenuStrs := '&Show/Hide WizardForm;' + // 0
'-;' + // 1
'&Animate Icon;' + // 2
'S&top Animation;' + // 3
'-;' + // 4
'&About...;' + // 5
'-;' + // 6
'E&xit'; // 7
InitTrayIconCtrl(MainForm.Handle, WizardForm.Handle, WM_ICON_NOTIFY, 'Установка {#MyAppVerName}', Ico,
True, False, MenuStrs, 0, MenuItemClickCallback, MenuPopupCallback);
ToggleWizardVisible
AnimateTrayIcon(40, -1);
ShowBalloon('Копирование файлов'+#13#10+'Пожалуйста, подождите...', 'Установка {#MyAppVerName}', NIIF_INFO, 5, False);
end else begin
ToggleWizardVisible
StopAnimation();
HideTrayIcon();
UninitTrayIconCtrl();
end; end;
procedure DeinitializeSetup();
begin
MainForm.Hide;
WizardForm.Hide;
end;[/more] Вопрос:
можно ли сделать так, чтобы при нажатии на всплывший Balloon основная форма появлялась? И можно ли при наведении курсора на иконку в трее вылазил hint с текущим копируемым файлом? Кетайская библиотека
тут