win32: fix TWin32WSCustomForm.SetShowInTaskbar for the case when window is visible

git-svn-id: trunk@20710 -
This commit is contained in:
paul 2009-06-22 08:09:27 +00:00
parent cc9bb3ed6e
commit 7a0a4d2038

View File

@ -424,18 +424,33 @@ class procedure TWin32WSCustomForm.SetShowInTaskbar(const AForm: TCustomForm;
const AValue: TShowInTaskbar); const AValue: TShowInTaskbar);
var var
Style: DWord; Style: DWord;
Visible, Active: Boolean;
begin begin
if not WSCheckHandleAllocated(AForm, 'SetShowInTaskbar') then if not WSCheckHandleAllocated(AForm, 'SetShowInTaskbar') then
Exit; Exit;
if (Application <> nil) and (AForm = Application.MainForm) then if (Application <> nil) and (AForm = Application.MainForm) then
Exit; Exit;
// to apply this changes we need either to hide window or recreate it. Hide is
// less difficult
Visible := IsWindowVisible(AForm.Handle);
Active := GetForegroundWindow = AForm.Handle;
if Visible then
ShowWindow(AForm.Handle, SW_HIDE);
Style := GetWindowLong(AForm.Handle, GWL_EXSTYLE); Style := GetWindowLong(AForm.Handle, GWL_EXSTYLE);
if AValue = stAlways then if AValue = stAlways then
Style := Style or WS_EX_APPWINDOW Style := Style or WS_EX_APPWINDOW
else else
Style := Style and not WS_EX_APPWINDOW; Style := Style and not WS_EX_APPWINDOW;
SetWindowLong(AForm.Handle, GWL_EXSTYLE, Style); SetWindowLong(AForm.Handle, GWL_EXSTYLE, Style);
// now we need to restore window visibility with saving focus
if Visible then
if Active then
ShowWindow(AForm.Handle, SW_SHOW)
else
ShowWindow(AForm.Handle, SW_SHOWNA);
end; end;
class procedure TWin32WSCustomForm.ShowModal(const ACustomForm: TCustomForm); class procedure TWin32WSCustomForm.ShowModal(const ACustomForm: TCustomForm);