-
2010. 12. 31. 17:21 IDE & SDK/Delphi
구 버전 델파이를 사용중인 경우, 아래 코드를 복사하여 상단에 붙여넣은뒤 코드를 사용 합니다.
type
PuNotifyIconDataA = ^TuNotifyIconDataA;
PuNotifyIconDataW = ^TuNotifyIconDataW;
PuNotifyIconData = PuNotifyIconDataW;
_uNOTIFYICONDATAA = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: array [0..127] of AnsiChar;
dwState: DWORD;
dwStateMask: DWORD;
szInfo: array [0..255] of AnsiChar;
case Integer of
0: (
uTimeout: UINT);
1: (uVersion: UINT;
szInfoTitle: array [0..63] of AnsiChar;
dwInfoFlags: DWORD;
guidItem: TGUID;
hBalloonIcon: HICON);
end;
_uNOTIFYICONDATAW = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: array [0..127] of WideChar;
dwState: DWORD;
dwStateMask: DWORD;
szInfo: array [0..255] of WideChar;
case Integer of
0: (
uTimeout: UINT);
1: (uVersion: UINT;
szInfoTitle: array [0..63] of WideChar;
dwInfoFlags: DWORD;
guidItem: TGUID;
hBalloonIcon: HICON);
end;
_uNOTIFYICONDATA = _uNOTIFYICONDATAW;
TuNotifyIconDataA = _uNOTIFYICONDATAA;
TuNotifyIconDataW = _uNOTIFYICONDATAW;
TuNotifyIconData = TuNotifyIconDataW;
uNOTIFYICONDATAA = _uNOTIFYICONDATAA;
uNOTIFYICONDATAW = _uNOTIFYICONDATAW;
uNOTIFYICONDATA = uNOTIFYICONDATAW;
현재 클래스에 등록 ( private ).
procedure IconMessage(var Message: TMessage); message WM_USER;
procedure TMainForm.IconMessage(var Message: TMessage);
begin
case Message.lParam of
WM_LBUTTONDOWN:
begin
Self.Show;
end;
WM_RBUTTONDOWN:
begin
//PopupMenu.Popup(Screen.Width, Screen.Height);
end;
end;
end;
전역 변수 지정
PTrayType: uNOTIFYICONDATAW;
FormCreate 혹은 FormShow 이벤트에 등록.
PTrayType.cbSize:=SizeOf(PTrayType);
PTrayType.Wnd:=Self.Handle;
PTrayType.uID:=1;
PTrayType.uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP or $10;//NIF_INFO;
PTrayType.uCallbackMessage:=WM_USER;
PTrayType.hIcon:=Application.Icon.Handle;
CopyMemory(@PTrayType.szTip, PWideChar(WideString(Application.Title)), Length(Application.Title)*2);
//PTrayType.szTip:=WideString(Application.Title);
PTrayType.dwState:=2;
PTrayType.dwStateMask:=0;
CopyMemory(@PTrayType.szInfo,PWideChar(WideString('내용1'+#13#10+'내용2')), 0);
//PTrayType.szInfo:='트레이 아이콘 마우스 오버시 보여질 내용';
PTrayType.uTimeout:=3000;
CopyMemory(@PTrayType.szInfoTitle,PWideChar(WideString('제목')), 4);
//PTrayType.szInfoTitle:=WideString('');
PTrayType.dwInfoFlags:=NIF_MESSAGE;
PTrayType.uCallbackMessage:=WM_USER;//트레이아이콘 메세지 등록
Shell_NotifyIconW(NIM_ADD, @PTrayType);
FormClose 혹은 FormQueryClose 이벤트에 등록.
Shell_NotifyIconW(NIM_DELETE, @PTrayType);
---------------- 간단히 사용하기 ----------------
JDEI 컴포넌트 설치후 VCL 목록 : jv Non-Visual 텝
JvTrayIcon 을 찾아 폼에 넣고 간단히 사용 할수 있습니다.
type
PuNotifyIconDataA = ^TuNotifyIconDataA;
PuNotifyIconDataW = ^TuNotifyIconDataW;
PuNotifyIconData = PuNotifyIconDataW;
_uNOTIFYICONDATAA = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: array [0..127] of AnsiChar;
dwState: DWORD;
dwStateMask: DWORD;
szInfo: array [0..255] of AnsiChar;
case Integer of
0: (
uTimeout: UINT);
1: (uVersion: UINT;
szInfoTitle: array [0..63] of AnsiChar;
dwInfoFlags: DWORD;
guidItem: TGUID;
hBalloonIcon: HICON);
end;
_uNOTIFYICONDATAW = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: array [0..127] of WideChar;
dwState: DWORD;
dwStateMask: DWORD;
szInfo: array [0..255] of WideChar;
case Integer of
0: (
uTimeout: UINT);
1: (uVersion: UINT;
szInfoTitle: array [0..63] of WideChar;
dwInfoFlags: DWORD;
guidItem: TGUID;
hBalloonIcon: HICON);
end;
_uNOTIFYICONDATA = _uNOTIFYICONDATAW;
TuNotifyIconDataA = _uNOTIFYICONDATAA;
TuNotifyIconDataW = _uNOTIFYICONDATAW;
TuNotifyIconData = TuNotifyIconDataW;
uNOTIFYICONDATAA = _uNOTIFYICONDATAA;
uNOTIFYICONDATAW = _uNOTIFYICONDATAW;
uNOTIFYICONDATA = uNOTIFYICONDATAW;
현재 클래스에 등록 ( private ).
procedure IconMessage(var Message: TMessage); message WM_USER;
procedure TMainForm.IconMessage(var Message: TMessage);
begin
case Message.lParam of
WM_LBUTTONDOWN:
begin
Self.Show;
end;
WM_RBUTTONDOWN:
begin
//PopupMenu.Popup(Screen.Width, Screen.Height);
end;
end;
end;
전역 변수 지정
PTrayType: uNOTIFYICONDATAW;
FormCreate 혹은 FormShow 이벤트에 등록.
PTrayType.cbSize:=SizeOf(PTrayType);
PTrayType.Wnd:=Self.Handle;
PTrayType.uID:=1;
PTrayType.uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP or $10;//NIF_INFO;
PTrayType.uCallbackMessage:=WM_USER;
PTrayType.hIcon:=Application.Icon.Handle;
CopyMemory(@PTrayType.szTip, PWideChar(WideString(Application.Title)), Length(Application.Title)*2);
//PTrayType.szTip:=WideString(Application.Title);
PTrayType.dwState:=2;
PTrayType.dwStateMask:=0;
CopyMemory(@PTrayType.szInfo,PWideChar(WideString('내용1'+#13#10+'내용2')), 0);
//PTrayType.szInfo:='트레이 아이콘 마우스 오버시 보여질 내용';
PTrayType.uTimeout:=3000;
CopyMemory(@PTrayType.szInfoTitle,PWideChar(WideString('제목')), 4);
//PTrayType.szInfoTitle:=WideString('');
PTrayType.dwInfoFlags:=NIF_MESSAGE;
PTrayType.uCallbackMessage:=WM_USER;//트레이아이콘 메세지 등록
Shell_NotifyIconW(NIM_ADD, @PTrayType);
FormClose 혹은 FormQueryClose 이벤트에 등록.
Shell_NotifyIconW(NIM_DELETE, @PTrayType);
---------------- 간단히 사용하기 ----------------
JDEI 컴포넌트 설치후 VCL 목록 : jv Non-Visual 텝
JvTrayIcon 을 찾아 폼에 넣고 간단히 사용 할수 있습니다.