CoolTray가 Mouse Down Event에서 Popup메뉴를 보여주어서 그런 현상이 발생한다고 합니다.
CoolTrayIcon.Pas 에서 WM_RBUTTONDOWN에서 해당부분 주석 처리 하시고 WM_RBUTTONUP에 추가해주시면 될겁니다.
<!--CodeS-->
WM_RBUTTONDOWN:
if FEnabled then
begin
Shift := ShiftState + [ssRight];
GetCursorPos(Pt);
MouseDown(mbRight, Shift, Pt.x, Pt.y);
//주석처리 시작
{if (Assigned(FPopupMenu)) and (FPopupMenu.AutoPopup) then
begin
SetForegroundWindow(TrayIconHandler.FHandle); // So menu closes when used in a DLL
PopupAtCursor;
end;}
//주석처리 끝
end;
WM_RBUTTONUP:
if FBehavior = bhWin95 then
if FEnabled then
begin
Shift := ShiftState + [ssRight];
GetCursorPos(Pt);
MouseUp(mbRight, Shift, Pt.x, Pt.y);
//수정 시작 WM_RBUTTONDOWN 이벤트에서 복사해옴
if (Assigned(FPopupMenu)) and (FPopupMenu.AutoPopup) then
begin
SetForegroundWindow(TrayIconHandler.FHandle); // So menu closes when used in a DLL
PopupAtCursor;
end;
//수정 끝
end;
<!--CodeE-->
{$R *.DFM}
const MY_SHOWFORM_ID = WM_USER+1; //<--- 사용자 정의 메세지
procedure TForm1.MinimizeHandler(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE); //최소화 될때 화면과 태스크바에서 사라지게 합니다.
end;
procedure TForm1.WndProc;
var pt : Tpoint;
begin
case Message.Msg of
MY_SHOWFORM_ID:
case Message.lParam of
WM_LBUTTONDBLCLK: //트레이 아이콘 좌클릭
begin
ShowWindow(Application.Handle,SW_SHOWNORMAL);
Self.Show;
SetForegroundWindow(Form1.Handle);
end;
wm_rbuttondown: //트레이 아이콘 우클릭
begin
GetcursorPos(pt);
SetForegroundWindow(Handle);
PopupMenu1.Popup(pt.x,pt.y);//<-- 사용자 정의 PopUpMenu popup.
end;
end;
end;
inherited;
end;
//트레이 아이콘 생성
procedure TForm1.FormCreate(Sender: TObject);
var
iconData : TNotifyIconData;
begin
ShowWindow (Application.Handle, SW_HIDE);
Application.ShowMainForm:= False;
with IconData do
begin
cbSize := SizeOf ( IconData );
Wnd := Handle;
uID := 100;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
uCallbackMessage := WM_USER + 1;
hIcon := Application.Icon.Handle;
StrPCopy(szTip, Application.Title);
end;
Shell_NotifyIcon( NIM_ADD, @IconData );
Application.OnMinimize := MinimizeHandler; //<--- MainForm의 최소화 메시지 핸들러 재정의
CoolTrayIcon.Pas 에서 WM_RBUTTONDOWN에서 해당부분 주석 처리 하시고 WM_RBUTTONUP에 추가해주시면 될겁니다.
<!--CodeS-->
WM_RBUTTONDOWN:
if FEnabled then
begin
Shift := ShiftState + [ssRight];
GetCursorPos(Pt);
MouseDown(mbRight, Shift, Pt.x, Pt.y);
//주석처리 시작
{if (Assigned(FPopupMenu)) and (FPopupMenu.AutoPopup) then
begin
SetForegroundWindow(TrayIconHandler.FHandle); // So menu closes when used in a DLL
PopupAtCursor;
end;}
//주석처리 끝
end;
WM_RBUTTONUP:
if FBehavior = bhWin95 then
if FEnabled then
begin
Shift := ShiftState + [ssRight];
GetCursorPos(Pt);
MouseUp(mbRight, Shift, Pt.x, Pt.y);
//수정 시작 WM_RBUTTONDOWN 이벤트에서 복사해옴
if (Assigned(FPopupMenu)) and (FPopupMenu.AutoPopup) then
begin
SetForegroundWindow(TrayIconHandler.FHandle); // So menu closes when used in a DLL
PopupAtCursor;
end;
//수정 끝
end;
<!--CodeE-->