Можно создать значок в системном трее:
program Example;
uses
Windows, Messages;
const
WM_TRAYICON = WM_USER + 1;
WM_BTNCLK = WM_USER + 111;
NIM_ADD = $00000000;
NIF_MESSAGE = $00000001;
NIF_ICON = $00000002;
NIF_TIP = $00000004;
NIM_MODIFY = $00000001;
NIM_DELETE = $00000002;
type
PNotifyIconData = ^TNotifyIconData;
TNotifyIconData = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: array [0..63] of AnsiChar;
end;
var
WC: TWndClass;
Msg: TMsg;
Win, Memo1, Button1: HWND;
Font1: HFONT;
function Shell_NotifyIcon(dwMessage: DWORD; lpData: PNotifyIconData): BOOL;
stdcall; external 'shell32.dll' name 'Shell_NotifyIconA';
function TaskBarAddIcon(hWindow: HWND; idIcon: Cardinal; ICON: hIcon;
CallbackMessage: Cardinal; Tip: PChar): Boolean;
var
NID: TNotifyIconData;
begin
FillChar(NID, SizeOf(TNotifyIconData), 0);
with NID do begin
cbSize := SizeOf(TNotifyIconData);
Wnd := hWindow;
uID := idIcon;
uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
uCallbackMessage := WM_TRAYICON;
hIcon := Icon;
lstrcpyn(szTip, Tip, SizeOf(szTip));
end;
Result := Shell_NotifyIcon(NIM_ADD, @NID);
end;
function TaskBarDeleteIcon(hWindow: HWND; ID: Integer): Boolean;
var
NID: TNotifyIconData;
begin
FillChar(NID, SizeOf(TNotifyIconData), 0);
with NID do begin
cbSize := SizeOf(TNotifyIconData);
Wnd := hWindow;
uID := ID;
end;
Result := Shell_NotifyIcon(NIM_DELETE, @NID);
end;
function WindowProc(Win, Msg, WP, LP: Integer): Integer; stdcall;
begin
case Msg of
WM_CREATE:
begin
SendMessage(Win, WM_SYSCOMMAND, SC_MINIMIZE, 0);
TaskBarAddIcon(Win, 1, LoadIcon(0, IDI_INFORMATION), WM_TRAYICON,
PChar('Тайминг 0.01'))
end;
WM_TRAYICON:
if LP = WM_LBUTTONUP then
begin
SendMessage(Win, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
TaskBarDeleteIcon(Win, 1)
end;
WM_DESTROY:
begin
TaskBarDeleteIcon(Win, 1);
PostQuitMessage(0)
end
end;
Result := DefWindowProc(Win, Msg, WP, LP)
end;
BEGIN
with WC do
begin
lpszClassName:= 'asd';
lpfnWndProc := @WindowProc;
hbrBackground := 1;
hCursor := LoadCursor(0, IDC_ARROW)
end;
RegisterClass(WC);
Win := CreateWindow(WC.lpszClassName, 'Заголовок программы',
WS_OVERLAPPED or WS_SYSMENU or WS_MINIMIZEBOX or WS_VISIBLE,
400, 200, 350, 600, 0, 0, hInstance, nil);
Font1 := GetStockObject(ANSI_VAR_FONT);
Memo1 := CreateWindowEx(WS_EX_STATICEDGE, 'Edit', '',
WS_VISIBLE or WS_CHILD or WS_VSCROLL or ES_MULTILINE,
5, 5, 335, 540, Win, 1001, hInstance, nil);
SendMessage(Memo1, WM_SETFONT, Font1, 0);
Button1 := CreateWindowEx(WS_EX_STATICEDGE, 'Button', 'Кнопка',
WS_VISIBLE or WS_CHILD, 275, 550, 66, 20, Win, 1002, hInstance, nil);
SendMessage(Button1, WM_SETFONT, Font1, 0);
while GetMessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg)
end;
END.