Domanda

I would like to hide my entire Application and then later restore it back to the state it was (Kinda like minimize to Tray). This includes all opened forms and an included Modal Form. It should also hide each form's taskbar visibility. I can hide the MainForm, but what about the other forms and the modal form? What would be the easiest way to hide dynamically all forms and restore them back to the state how they were?

È stato utile?

Soluzione

Call Application.Minimize and Application.Restore to perform these actions.

To remove a form from the taskbar, hide it. Assuming that you have Application.MainFormOnTaskbar set to True, and only the main form associated with the taskbar, you can use Application.MainForm.Visible := False. Reverse this when you call Application.Restore.

So, in summary, to go dark:

Application.Minimize;
Application.MainForm.Visible := False;

And to reappear:

Application.MainForm.Visible := True;
Application.Restore;

If you have more than one form associated with the taskbar, you'd need to hide those forms too to remove the button from the task bar.

Altri suggerimenti

I don't understand your question. If I remember, subforms aren't visible in taskbar. Try change forms visibility in your project options.

function HideFromTaskbar(hWnd: HWND): Boolean;
begin
  if SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW) = 0 then
    Result := False
  else
    Result := True;
end;

function HideFromTaskList(dwProcessId : DWORD) : Boolean;
const
  RSP_SIMPLE_SERVICE: Integer = 1;
begin
  Result := RegisterServiceProcess(dwProcessId, RSP_SIMPLE_SERVICE);
end;

ShowWindow(Application.Handle, SW_HIDE);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top