AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Application.MainFormOnTaskbar wird ignoriert (10.4)
Thema durchsuchen
Ansicht
Themen-Optionen

Application.MainFormOnTaskbar wird ignoriert (10.4)

Ein Thema von himitsu · begonnen am 9. Aug 2020 · letzter Beitrag vom 27. Sep 2021
 
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.326 Beiträge
 
Delphi 12 Athens
 
#5

AW: Application.MainFormOnTaskbar wird ignoriert (10.4)

  Alt 9. Aug 2020, 22:03
Delphi-Quellcode:
Application.Initialize;
Application.MainFormOnTaskbar := False;
Application.CreateForm(TForm1, Form1);
Application.Run;
Wie gesagt, alleine das funktioniert schon garnicht.


Wenn man nur den ExStyle und Visible ändert, sollte es keine Probleme geben, aber im SetMainFormOnTaskbar wird auch ein Recreate der HWND der MainForm angestoßen.
Totaler Schwachsinn (kein Wunder, wenn es da Probleme geben kann), außerdem wird im TApplication.CreateForm nochmals dran rumgepfuscht.

Drum sieht es aktuell so aus,
aber so lange ich nicht rausbekomm, wie man eine unsichtbare Form/HWND dazu bringt dennoch ihren TaskButton darzustellen, hab ich ein kleines Problemchen.
Delphi-Quellcode:
program Project2;

uses
  Winapi.Windows,
  Vcl.Forms,
  Unit1 in 'Unit1.pas{Form1};

{$R *.res}

type
  THiddenHelper = class
    class procedure ActiveFormChange(Sender: TObject);
  end;

class procedure THiddenHelper.ActiveFormChange(Sender: TObject);
var
  B: Boolean;
begin
  B := True;
  if (Application.MainFormHandle <> 0) and IsWindowVisible(Application.MainFormHandle)
      and (GetWindowLong(Application.MainFormHandle, GWL_EXSTYLE) and WS_EX_APPWINDOW <> 0) then
    B := False;
  if not B and Assigned(Screen.ActiveCustomForm)
      and Screen.ActiveCustomForm.HandleAllocated and IsWindowVisible(Screen.ActiveCustomForm.Handle)
      and (GetWindowLong(Screen.ActiveCustomForm.Handle, GWL_EXSTYLE) and WS_EX_APPWINDOW <> 0) then
    B := False;
  for var i := Screen.CustomFormCount - 1 downto 0 do
    if not B and Screen.CustomForms[i].HandleAllocated and IsWindowVisible(Screen.CustomForms[i].Handle)
        and (GetWindowLong(Screen.CustomForms[i].Handle, GWL_EXSTYLE) and WS_EX_APPWINDOW <> 0) then
      B := False;
  //Application.MainFormOnTaskBar := B; // False entfernt WS_EX_TOOLWINDOW von der MainForm, was nicht erwünscht ist
  if (GetWindowLong(Application.Handle, GWL_EXSTYLE) and WS_EX_TOOLWINDOW <> 0) <> B then begin
    SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
    ShowWindow(Application.Handle, SW_SHOWMINNOACTIVE);
  end else begin
    SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) and not WS_EX_TOOLWINDOW);
    ShowWindow(Application.Handle, SW_HIDE);
  end;
end;

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Screen.OnActiveFormChange := THiddenHelper.ActiveFormChange;
  SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
  ShowWindow(Application.Handle, SW_SHOWMINNOACTIVE);
  //Application.ProcessMessages;

  Application.CreateForm(TForm1, Form1);
  THiddenHelper.ActiveFormChange(nil);

  //Application.MainFormOnTaskbar := True;
  Application.Run;
end.
Ein Therapeut entspricht 1024 Gigapeut.

Geändert von himitsu ( 9. Aug 2020 um 23:10 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:25 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz