From: <rem...@us...> - 2006-06-03 14:04:11
|
Revision: 10633 Author: remkobonte Date: 2006-06-03 07:03:56 -0700 (Sat, 03 Jun 2006) ViewCVS: http://svn.sourceforge.net/jvcl/?rev=10633&view=rev Log Message: ----------- Calling Shell_NotifyIcon can fail on XP when the shell is busy. Modified Paths: -------------- trunk/jvcl/run/JvTrayIcon.pas Modified: trunk/jvcl/run/JvTrayIcon.pas =================================================================== --- trunk/jvcl/run/JvTrayIcon.pas 2006-06-02 18:33:00 UTC (rev 10632) +++ trunk/jvcl/run/JvTrayIcon.pas 2006-06-03 14:03:56 UTC (rev 10633) @@ -101,6 +101,8 @@ function GetApplicationVisible: Boolean; procedure SetApplicationVisible(const Value: Boolean); + function GetIconVisible: Boolean; + procedure SetIconVisible(const Value: Boolean); protected FActive: Boolean; FIcon: TIcon; @@ -204,6 +206,7 @@ property ApplicationVisible: Boolean read GetApplicationVisible write SetApplicationVisible; property VisibleInTaskList: Boolean read FTask write SetTask default True; + property IconVisible: Boolean read GetIconVisible write SetIconVisible; published property Active: Boolean read FActive write SetActive default False; property Animated: Boolean read FAnimated write SetAnimated default False; @@ -859,6 +862,11 @@ end; end; +function TJvTrayIcon.GetIconVisible: Boolean; +begin + Result := tisTrayIconVisible in FState; +end; + function TJvTrayIcon.GetSystemMinimumBalloonDelay: Cardinal; begin // from Microsoft's documentation, a balloon is shown for at @@ -1159,6 +1167,14 @@ end; end; +procedure TJvTrayIcon.SetIconVisible(const Value: Boolean); +begin + if Value then + ShowTrayIcon + else + HideTrayIcon; +end; + procedure TJvTrayIcon.SetTask(const Value: Boolean); begin if FTask <> Value then @@ -1276,16 +1292,20 @@ // All checks passed, make the trayicon visible: - Include(FState, tisTrayIconVisible); + { Calling Shell_NotifyIcon can fail on XP when the shell is busy + See http://support.microsoft.com/default.aspx?scid=kb;ja;418138 + } + if NotifyIcon(NIF_MESSAGE or NIF_ICON or NIF_TIP, NIM_ADD) then + begin + Include(FState, tisTrayIconVisible); - NotifyIcon(NIF_MESSAGE or NIF_ICON or NIF_TIP, NIM_ADD); + // If we call NIM_SETVERSION, we must call it *after* NIM_ADD. + if GetShellVersion >= Shell32VersionIE5 then + NotifyIcon(0, NIM_SETVERSION); - // If we call NIM_SETVERSION, we must call it *after* NIM_ADD. - if GetShellVersion >= Shell32VersionIE5 then - NotifyIcon(0, NIM_SETVERSION); - - if Animated then - StartAnimation; + if Animated then + StartAnimation; + end; end; procedure TJvTrayIcon.StartAnimation; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rem...@us...> - 2006-06-07 20:10:44
|
Revision: 10644 Author: remkobonte Date: 2006-06-05 11:21:28 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/jvcl/?rev=10644&view=rev Log Message: ----------- Calling Shell_NotifyIcon can fail on XP when the shell is busy. Modified Paths: -------------- trunk/jvcl/run/JvTrayIcon.pas Modified: trunk/jvcl/run/JvTrayIcon.pas =================================================================== --- trunk/jvcl/run/JvTrayIcon.pas 2006-06-05 08:04:07 UTC (rev 10643) +++ trunk/jvcl/run/JvTrayIcon.pas 2006-06-05 18:21:28 UTC (rev 10644) @@ -540,27 +540,28 @@ FIconData.uTimeOut := ADelay; FIconData.dwInfoFlags := cInfoFlagValues[BalloonType]; - NotifyIcon(NIF_INFO, NIM_MODIFY); - - if (Title = '') and (Value = '') then + if NotifyIcon(NIF_INFO, NIM_MODIFY) then begin - Dec(FBalloonCount); - if FBalloonCount < 0 then - FBalloonCount := 0; - end - else - Inc(FBalloonCount); + if (Title = '') and (Value = '') then + begin + Dec(FBalloonCount); + if FBalloonCount < 0 then + FBalloonCount := 0; + end + else + Inc(FBalloonCount); - // if the delay is less than the system's minimum and the balloon - // was really shown (title and value are not both empty) - // (rb) XP: if Value = '' then balloon is not shown - if (ADelay < GetSystemMinimumBalloonDelay) and ((Title <> '') or (Value <> '')) then - // then we enable the ballon closer timer which will cancel - // the balloon when the delay is elapsed - SetTimer(FHandle, CloseBalloonTimer, ADelay, nil); + // if the delay is less than the system's minimum and the balloon + // was really shown (title and value are not both empty) + // (rb) XP: if Value = '' then balloon is not shown + if (ADelay < GetSystemMinimumBalloonDelay) and ((Title <> '') or (Value <> '')) then + // then we enable the ballon closer timer which will cancel + // the balloon when the delay is elapsed + SetTimer(FHandle, CloseBalloonTimer, ADelay, nil); - if Assigned(FOnBalloonShow) then - FOnBalloonShow(Self); + if Assigned(FOnBalloonShow) then + FOnBalloonShow(Self); + end; end; end; @@ -929,9 +930,10 @@ // reentrance check if tisTrayIconVisible in FState then begin - Exclude(FState, tisTrayIconVisible); EndAnimation; - NotifyIcon(0, NIM_DELETE); + + if NotifyIcon(0, NIM_DELETE) then + Exclude(FState, tisTrayIconVisible); end; end; @@ -1050,9 +1052,48 @@ end; function TJvTrayIcon.NotifyIcon(uFlags: UINT; dwMessage: DWORD): Boolean; +const + cMaxRetryCount = 30; // arbitrary + cDelay = 1000; // arbitrary +var + ErrorCode: Integer; + RetryCount: Integer; begin FIconData.uFlags := uFlags; Result := Shell_NotifyIcon(dwMessage, @FIconData); + if not Result then + begin + { Calling Shell_NotifyIcon can fail on XP when the shell is busy + See http://support.microsoft.com/default.aspx?scid=kb;ja;418138 + + Shell_NotifyIcon has a timeout of 4 sec. to complete. If that fails + because the shell is busy, then False is returned and GetLastError + returns ERROR_TIMEOUT (but testing shows that it can also return 0) + Solution is to wait a bit and retry. The translated text of the + Japanese MSDN web-page is a bit hard to read for me, but I think + it also mentions calling with parameter NIM_MODIFY. + + http://qc.borland.com/wc/qcmain.aspx?d=29306 provides steps to + reproduce this problem. + } + ErrorCode := GetLastError; + if (ErrorCode = 0) or (ErrorCode = ERROR_TIMEOUT) then + begin + RetryCount := 0; + repeat + Sleep(cDelay); + if dwMessage = NIM_ADD then + begin + Result := Shell_NotifyIcon(NIM_MODIFY, @FIconData); + if Result then + Exit; + end; + + Inc(RetryCount); + Result := Shell_NotifyIcon(dwMessage, @FIconData); + until Result or (RetryCount > cMaxRetryCount); + end; + end; end; procedure TJvTrayIcon.SetActive(Value: Boolean); @@ -1292,9 +1333,6 @@ // All checks passed, make the trayicon visible: - { Calling Shell_NotifyIcon can fail on XP when the shell is busy - See http://support.microsoft.com/default.aspx?scid=kb;ja;418138 - } if NotifyIcon(NIF_MESSAGE or NIF_ICON or NIF_TIP, NIM_ADD) then begin Include(FState, tisTrayIconVisible); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rem...@us...> - 2006-06-07 20:14:33
|
Revision: 10646 Author: remkobonte Date: 2006-06-06 12:09:08 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/jvcl/?rev=10646&view=rev Log Message: ----------- Mantis #3747: JvTrayIcon - Problem when Shell_NotifyIcon(NIM_DELETE) does timeout. (Mantis #3747) Modified Paths: -------------- trunk/jvcl/run/JvTrayIcon.pas Modified: trunk/jvcl/run/JvTrayIcon.pas =================================================================== --- trunk/jvcl/run/JvTrayIcon.pas 2006-06-06 13:35:07 UTC (rev 10645) +++ trunk/jvcl/run/JvTrayIcon.pas 2006-06-06 19:09:08 UTC (rev 10646) @@ -1069,10 +1069,17 @@ Shell_NotifyIcon has a timeout of 4 sec. to complete. If that fails because the shell is busy, then False is returned and GetLastError returns ERROR_TIMEOUT (but testing shows that it can also return 0) - Solution is to wait a bit and retry. The translated text of the - Japanese MSDN web-page is a bit hard to read for me, but I think - it also mentions calling with parameter NIM_MODIFY. + Solution is to wait a bit and retry. + However, even when GetLastError() returns ERROR_TIMEOUT, + the icon can often be actually added(or deleted). + + In the timeout of NIM_ADD, it can be confirmed that Shell_NotifyIcon(NIM_MODIFY) + returns true and the addition of the icon has succeeded. + To similar, In the timeout of NIM_DELETE, it can be confirmed that + Shell_NotifyIcon(NIM_MODIFY) returns false and the deletion of the icon has + succeeded. (See Mantis #3747) + http://qc.borland.com/wc/qcmain.aspx?d=29306 provides steps to reproduce this problem. } @@ -1082,13 +1089,15 @@ RetryCount := 0; repeat Sleep(cDelay); - if dwMessage = NIM_ADD then - begin - Result := Shell_NotifyIcon(NIM_MODIFY, @FIconData); - if Result then - Exit; + + case dwMessage of + NIM_ADD: Result := Shell_NotifyIcon(NIM_MODIFY, @FIconData); + NIM_DELETE: Result := not Shell_NotifyIcon(NIM_MODIFY, @FIconData); end; + if Result then + Exit; + Inc(RetryCount); Result := Shell_NotifyIcon(dwMessage, @FIconData); until Result or (RetryCount > cMaxRetryCount); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rem...@us...> - 2006-10-04 00:49:00
|
Revision: 10960 http://svn.sourceforge.net/jvcl/?rev=10960&view=rev Author: remkobonte Date: 2006-10-03 16:22:07 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Added RefreshTray: Deletes icons corresponding to killed programs from the tray. Modified Paths: -------------- trunk/jvcl/run/JvTrayIcon.pas Modified: trunk/jvcl/run/JvTrayIcon.pas =================================================================== --- trunk/jvcl/run/JvTrayIcon.pas 2006-10-03 23:20:05 UTC (rev 10959) +++ trunk/jvcl/run/JvTrayIcon.pas 2006-10-03 23:22:07 UTC (rev 10960) @@ -232,6 +232,8 @@ property OnContextPopup: TContextPopupEvent read FOnContextPopup write FOnContextPopup; end; +procedure RefreshTray; + {$IFDEF UNITVERSIONING} const UnitVersioning: TUnitVersionInfo = ( @@ -250,6 +252,38 @@ type TRegisterServiceProcess = function(dwProcessID, dwType: Integer): Integer; stdcall; + TExtraData = packed record + Wnd: THandle; + uID: UINT; + end; + + TTrayIconEnumerator = class + private + FToolbarHandle: THandle; + FProcess: THandle; + FCount: Integer; + FData: Pointer; + FIndex: Integer; + FButton: TTBButton; + FExtraData: TExtraData; + procedure Init(const DataSize: Integer); + public + constructor Create; overload; + constructor Create(DataSize: Integer); overload; + destructor Destroy; override; + function MoveNext: Boolean; + + function ReadProcessMemory(const Address: Pointer; Count: DWORD; var Buffer): Boolean; + + property CurrentButton: TTBButton read FButton; + property CurrentWnd: THandle read FExtraData.Wnd; + property CurrentID: UINT read FExtraData.uID; + + property ToolbarHandle: THandle read FToolbarHandle; + property Index: Integer read FIndex; + property Data: Pointer read FData; + end; + const AnimationTimer = 1; CloseBalloonTimer = 2; @@ -461,6 +495,57 @@ EnumChildWindows(TrayHandle, @FindToolbar, Longint(@Result)); end; +function GetIconRect(const AWnd: THandle; const AID: UINT; var IconRect: TRect): Boolean; +begin + Result := False; + + with TTrayIconEnumerator.Create(SizeOf(IconRect)) do + try + while MoveNext do + if (CurrentWnd = AWnd) and (CurrentID = AID) then + begin + // Button can be hidden in XP + if (CurrentButton.fsState and TBSTATE_HIDDEN) <> 0 then + Exit; + + // Retrieve the button rectangle.. + SendMessage(ToolbarHandle, TB_GETITEMRECT, Index, Longint(Data)); + // ..and copy it to the current process. If it fails no need to continue + if not ReadProcessMemory(FData, SizeOf(IconRect), IconRect) then + Exit; + + // Convert it to the desktop coordinate space + MapWindowPoints(ToolbarHandle, HWND_DESKTOP, IconRect.TopLeft, 2); + + Result := True; + Exit; + end; + finally + Free; + end; +end; + +procedure RefreshTray; +var + IconData: TNotifyIconData; +begin + FillChar(IconData, SizeOf(IconData), #0); + IconData.cbSize := SizeOf(IconData); + + with TTrayIconEnumerator.Create do + try + while MoveNext do + if not IsWindow(CurrentWnd) then + begin + IconData.Wnd := CurrentWnd; + IconData.uID := CurrentID; + Shell_NotifyIcon(NIM_DELETE, @IconData); + end; + finally + Free; + end; +end; + //=== { TJvTrayIcon } ======================================================== constructor TJvTrayIcon.Create(AOwner: TComponent); @@ -764,103 +849,8 @@ end; function TJvTrayIcon.GetIconRect(var IconRect: TRect): Boolean; -{ Taken from http://www.thecodeproject.com/shell/ctrayiconposition.asp } -type - TExtraData = packed record - Wnd: THandle; - uID: UINT; - end; -var - ToolbarHandle: THandle; - ProcessID: DWORD; - Process: THandle; - ButtonCount: Integer; - Data: Pointer; - Index: Integer; - BytesRead: DWORD; - Button: TTBButton; - ExtraData: TExtraData; begin - Result := False; - - // The trayicons are actually buttons on a toolbar - ToolbarHandle := GetToolbarHandle; - if ToolbarHandle = 0 then - Exit; - - ButtonCount := SendMessage(ToolbarHandle, TB_BUTTONCOUNT, 0, 0); - if ButtonCount < 1 then - Exit; - - // We want to get data from another process - it's not possible - // to just send messages like TB_GETBUTTON with a locally - // allocated buffer for return data. Pointer to locally allocated - // data has no usefull meaning in a context of another - // process (since Win95) - so we need - // to allocate some memory inside Tray process. - // Use @ProcessId for C5/D5 compatibility - - if GetWindowThreadProcessId(ToolbarHandle, @ProcessID) = 0 then - Exit; - - Process := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID); - if Process = 0 then - Exit; - try - // Allocate needed memory in the context of the tray process. We reuse - // Data to read multiple parts so we set it to the biggest chunk we need - // (TTBButton) - Data := VirtualAllocEx(Process, nil, SizeOf(TTBButton), MEM_COMMIT, PAGE_READWRITE); - if Data = nil then - Exit; - try - for Index := 0 to ButtonCount - 1 do - begin - // First we have to determine if the button with index Index is our - // button. - SendMessage(ToolbarHandle, TB_GETBUTTON, Index, Longint(Data)); - - // Read the data from the tray process into the current process. - Result := ReadProcessMemory(Process, Data, - @Button, SizeOf(Button), BytesRead) and (BytesRead = SizeOf(Button)); - if not Result then - Continue; - - // Read the extra data, Button.dwData points to its location - Result := ReadProcessMemory(Process, Pointer(Button.dwData), - @ExtraData, SizeOf(ExtraData), BytesRead) and (BytesRead = SizeOf(ExtraData)); - if not Result then - Continue; - - // Is it our button? - if (ExtraData.Wnd <> FHandle) or (ExtraData.uID <> cTaskbarIconIdentifier) then - Continue; - - // Button can be hidden in XP - if (Button.fsState and TBSTATE_HIDDEN) <> 0 then - Break; - - // Retrieve the button rectangle.. - SendMessage(ToolbarHandle, TB_GETITEMRECT, Index, Longint(Data)); - // ..and copy it to the current process - Result := ReadProcessMemory(Process, Data, - @IconRect, SizeOf(IconRect), BytesRead) and (BytesRead = SizeOf(IconRect)); - // If it fails no need to continue - if not Result then - Break; - - // Convert it to the desktop coordinate space - MapWindowPoints(ToolbarHandle, HWND_DESKTOP, IconRect.TopLeft, 2); - - Result := True; - Break; - end; - finally - VirtualFreeEx(Process, Data, 0, MEM_RELEASE); - end; - finally - CloseHandle(Process); - end; + Result := JvTrayIcon.GetIconRect(Self.FHandle, cTaskbarIconIdentifier, IconRect); end; function TJvTrayIcon.GetIconVisible: Boolean; @@ -1074,11 +1064,10 @@ However, even when GetLastError() returns ERROR_TIMEOUT, the icon can often be actually added(or deleted). - In the timeout of NIM_ADD, it can be confirmed that Shell_NotifyIcon(NIM_MODIFY) - returns true and the addition of the icon has succeeded. - To similar, In the timeout of NIM_DELETE, it can be confirmed that - Shell_NotifyIcon(NIM_MODIFY) returns false and the deletion of the icon has - succeeded. (See Mantis #3747) + If NIM_ADD times out and Shell_NotifyIcon(NIM_MODIFY) returns true, + the addition of the icon was actually successful. + Similarly, if NIM_DELETE times out and Shell_NotifyIcon(NIM_MODIFY) returns + false, the deletion of the icon was actually successful. (See Mantis #3747) http://qc.borland.com/wc/qcmain.aspx?d=29306 provides steps to reproduce this problem. @@ -1116,8 +1105,6 @@ if FActive then begin InitIconData; - if (csDesigning in ComponentState) and not (tvVisibleDesign in Visibility) then - Exit; Hook; ShowTrayIcon; end @@ -1512,6 +1499,105 @@ end; end; +//=== { TTrayIconEnumerator } ============================================== + +constructor TTrayIconEnumerator.Create(DataSize: Integer); +begin + inherited Create; + if DataSize < SizeOf(TTBButton) then + DataSize := SizeOf(TTBButton); + Init(DataSize); + FIndex := FCount; +end; + +constructor TTrayIconEnumerator.Create; +begin + inherited Create; + Init(SizeOf(TTBButton)); + FIndex := FCount; +end; + +destructor TTrayIconEnumerator.Destroy; +begin + if FData <> nil then + VirtualFreeEx(FProcess, FData, 0, MEM_RELEASE); + if FProcess <> 0 then + CloseHandle(FProcess); + inherited Destroy; +end; + +procedure TTrayIconEnumerator.Init(const DataSize: Integer); +{ Taken from http://www.thecodeproject.com/shell/ctrayiconposition.asp } +var + ProcessID: DWORD; +begin + // The trayicons are actually buttons on a toolbar + FToolbarHandle := GetToolbarHandle; + if FToolbarHandle = 0 then + Exit; + + FCount := SendMessage(FToolbarHandle, TB_BUTTONCOUNT, 0, 0); + if FCount < 1 then + Exit; + + // We want to get data from another process - it's not possible + // to just send messages like TB_GETBUTTON with a locally + // allocated buffer for return data. Pointer to locally allocated + // data has no usefull meaning in a context of another + // process (since Win95) - so we need + // to allocate some memory inside Tray process. + // Use @ProcessId for C5/D5 compatibility + + if GetWindowThreadProcessId(FToolbarHandle, @ProcessID) = 0 then + Exit; + + FProcess := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID); + if FProcess = 0 then + Exit; + + // Allocate needed memory in the context of the tray process. We reuse + // Data to read multiple parts so we set it to the biggest chunk we need + // (TTBButton) + FData := VirtualAllocEx(FProcess, nil, DataSize, MEM_COMMIT, PAGE_READWRITE); +end; + +function TTrayIconEnumerator.MoveNext: Boolean; +begin + Result := False; + + if (FProcess = 0) or not Assigned(FData) then + Exit; + + Dec(FIndex); + + while FIndex >= 0 do + begin + SendMessage(FToolbarHandle, TB_GETBUTTON, FIndex, Longint(FData)); + + // Read the data from the tray process into the current process. + if ReadProcessMemory(FData, SizeOf(FButton), FButton) then + begin + // Read the extra data, Button.dwData points to its location + if ReadProcessMemory(Pointer(FButton.dwData), SizeOf(FExtraData), FExtraData) then + begin + Result := True; + Exit; + end; + end; + + Dec(FIndex); + end; +end; + +function TTrayIconEnumerator.ReadProcessMemory(const Address: Pointer; + Count: DWORD; var Buffer): Boolean; +var + BytesRead: DWORD; +begin + Result := Windows.ReadProcessMemory(FProcess, Address, @Buffer, Count, BytesRead) and + (BytesRead = Count); +end; + initialization {$IFDEF UNITVERSIONING} RegisterUnitVersion(HInstance, UnitVersioning); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rem...@us...> - 2007-02-06 22:42:48
|
Revision: 11184 http://svn.sourceforge.net/jvcl/?rev=11184&view=rev Author: remkobonte Date: 2007-02-06 14:42:47 -0800 (Tue, 06 Feb 2007) Log Message: ----------- + New flag tvNoRetryOnFailure, doesn't retry Shell_NotifyIcon on failure + Method BalloonHint fails immediately if no icon is visible (otherwise the application is blocked because Shell_NotifyIcon is retried until a time-out) Modified Paths: -------------- trunk/jvcl/run/JvTrayIcon.pas Modified: trunk/jvcl/run/JvTrayIcon.pas =================================================================== --- trunk/jvcl/run/JvTrayIcon.pas 2007-02-06 21:48:30 UTC (rev 11183) +++ trunk/jvcl/run/JvTrayIcon.pas 2007-02-06 22:42:47 UTC (rev 11184) @@ -85,7 +85,8 @@ the trayicon, and could not come up with a backwards compatible way right-away } TTrayVisibility = (tvVisibleTaskBar, tvVisibleTaskList, tvAutoHide, tvAutoHideIcon, tvVisibleDesign, - tvRestoreClick, tvRestoreDbClick, tvMinimizeClick, tvMinimizeDbClick, tvAnimateToTray); + tvRestoreClick, tvRestoreDbClick, tvMinimizeClick, tvMinimizeDbClick, tvAnimateToTray, + tvNoRetryOnFailure); TTrayVisibilities = set of TTrayVisibility; TJvTrayIconState = (tisTrayIconVisible, tisAnimating, tisHooked, tisHintChanged, @@ -608,7 +609,7 @@ cInfoFlagValues: array [TBalloonType] of DWORD = (NIIF_NONE, NIIF_ERROR, NIIF_INFO, NIIF_WARNING); begin - if AcceptBalloons then + if (tisTrayIconVisible in FState) and AcceptBalloons then begin FTime := Now; FTimeDelay := ADelay div 1000; @@ -1051,7 +1052,7 @@ begin FIconData.uFlags := uFlags; Result := Shell_NotifyIcon(dwMessage, @FIconData); - if not Result then + if not Result and not (tvNoRetryOnFailure in Visibility) then begin { Calling Shell_NotifyIcon can fail on XP when the shell is busy See http://support.microsoft.com/default.aspx?scid=kb;ja;418138 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ob...@us...> - 2007-11-08 21:34:29
|
Revision: 11558 http://jvcl.svn.sourceforge.net/jvcl/?rev=11558&view=rev Author: obones Date: 2007-11-08 13:34:21 -0800 (Thu, 08 Nov 2007) Log Message: ----------- Fix for D2007 that introduced ShowMainFormOnTaskbar and some new behaviours with it. Modified Paths: -------------- trunk/jvcl/run/JvTrayIcon.pas Modified: trunk/jvcl/run/JvTrayIcon.pas =================================================================== --- trunk/jvcl/run/JvTrayIcon.pas 2007-11-03 16:36:36 UTC (rev 11557) +++ trunk/jvcl/run/JvTrayIcon.pas 2007-11-08 21:34:21 UTC (rev 11558) @@ -406,6 +406,10 @@ function IsApplicationMinimized: Boolean; begin Result := IsIconic(Application.Handle); + {$IFDEF COMPILER11_UP} + if ShowMainFormOnTaskBar and Assigned(Application.MainForm) then + Result := IsIconic(Application.MainForm.Handle); + {$ENDIF COMPILER11_UP} end; function GetTrayHandle: THandle; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rem...@us...> - 2007-11-10 12:02:48
|
Revision: 11559 http://jvcl.svn.sourceforge.net/jvcl/?rev=11559&view=rev Author: remkobonte Date: 2007-11-10 04:02:42 -0800 (Sat, 10 Nov 2007) Log Message: ----------- Fix for D2007 that introduced Application.MainFormOnTaskbar Modified Paths: -------------- trunk/jvcl/run/JvTrayIcon.pas Modified: trunk/jvcl/run/JvTrayIcon.pas =================================================================== --- trunk/jvcl/run/JvTrayIcon.pas 2007-11-08 21:34:21 UTC (rev 11558) +++ trunk/jvcl/run/JvTrayIcon.pas 2007-11-10 12:02:42 UTC (rev 11559) @@ -403,15 +403,21 @@ be to also delay OnMouseUp. } -function IsApplicationMinimized: Boolean; +function GetHandleOnTaskBar: THandle; begin - Result := IsIconic(Application.Handle); {$IFDEF COMPILER11_UP} - if ShowMainFormOnTaskBar and Assigned(Application.MainForm) then - Result := IsIconic(Application.MainForm.Handle); + if Application.MainFormOnTaskBar and Assigned(Application.MainForm) then + Result := Application.MainForm.Handle + else {$ENDIF COMPILER11_UP} + Result := Application.Handle; end; +function IsApplicationMinimized: Boolean; +begin + Result := IsIconic(GetHandleOnTaskBar); +end; + function GetTrayHandle: THandle; var ShellTrayHandle: THandle; @@ -873,7 +879,7 @@ end; // ..and hide the taskbar button of the application - ShowWindow(Application.Handle, SW_HIDE); + ShowWindow(GetHandleOnTaskBar, SW_HIDE); Exclude(FVisibility, tvVisibleTaskBar); if tvAutoHideIcon in Visibility then @@ -1275,7 +1281,7 @@ // Show the taskbar button of the application.. Include(FVisibility, tvVisibleTaskBar); - ShowWindow(Application.Handle, SW_SHOW); + ShowWindow(GetHandleOnTaskBar, SW_SHOW); if not ApplicationVisible then begin This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |