bkneepkens:
--------------------------------------------------------------------------------
I experienced the same problem with a Delphi application. The solution proved
to be as follows.
I don't know what Delphi version was used to build PSPad, but this is what I did
in Delphi 7:
1. In FormCreate, hide the VCL-controlled taskbar button and assign an handler
for the OnActivate event:
procedure TfrmMain.FormCreate(Sender: TObject);
var
windowLong: integer;
begin
Application.OnActivate := OnApplicationActivate;
// Hide the taskbar button for the zero-size Application window.
// We'll let Windows deal with taskbar buttons and not the VCL.
windowLong := ((GetWindowLong(Application.Handle, GWL_EXSTYLE) and (not
WS_EX_APPWINDOW)) or WS_EX_TOOLWINDOW);
SetWindowLong(Application.Handle, GWL_EXSTYLE, windowLong);
end;
2. Implement the OnActivate event as follows:
procedure TfrmMain.OnApplicationActivate(Sender: TObject);
begin;
// Set the focus to the currently visible form. This may not always
// happen automatically because we're bypassing part of the VCL.
try
Screen.ActiveForm.SetFocus();
except
end;
end;
3. Override CreateParams to show a taskbar button:
procedure CreateParams(var Params: TCreateParams); override;
procedure TfrmMain.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
// Show a taskbar button
params.ExStyle := (params.ExStyle or WS_EX_APPWINDOW);
// Set the desktop as the window's parent.
// Without this the taskbar button will still appear, but then it
// won't move to Windows 10's second taskbar if the window is moved
// to a secondary monitor. (This is probably also true for Windows 8,
// but I haven't been able to test that).
params.WndParent := GetDesktopWindow();
end;
4. Handle the WM_SYSCOMMAND message to support minimize/restore:
procedure WMSysCommand(var msg: TWmSysCommand); message WM_SYSCOMMAND;
procedure TfrmMain.WMSysCommand(var msg: TWmSysCommand);
begin
// Bypass the VCL and let the Windows API
// handle minimize/restore functionality.
case (msg.CmdType and $FFF0) of
SC_MINIMIZE: begin
ShowWindow(Self.Handle, SW_MINIMIZE);
msg.Result := 0;
end;
SC_RESTORE : begin
ShowWindow(Self.Handle, SW_RESTORE);
msg.Result := 0;
end;
else begin
inherited;
end;
end;
end;
Hmm, the forum removes indentation, even within code tags... oh well. Hope this
helps :)
--------------------------------------------------------------------------------
Although I am quite sure it wont solve the problem this is a brilliant idea,
cheers
--
<https://forum.pspad.com/read.php?4,63717,69669>
PSPad freeware editor https://www.pspad.com