Search code examples
delphidelphi-xe

how to make Form2 visible no matter what the state of Form1 (main form ) is?


using Delphi XE (1) i have a application with TWO forms

Form1 is the main form..

Form2 is a msn like notification (a form that slide to show notification then disappears ).

stuff working smoothly until the form1 is minimized.

Q: how i make form2 show visible even if form1(main) is minimized to taskbar


Solution

  • You can use CreateParams to override default behavior. Something like this:

    Add declaration to your form

      protected
        procedure CreateParams(var Params: TCreateParams); override;
    

    Add a procedure

    procedure TMyForm.CreateParams(var Params: TCreateParams);
    begin
      inherited CreateParams(Params);
    
      with Params do
      begin
        Style := WS_POPUP or WS_BORDER;
        ExStyle := WS_EX_TOPMOST or WS_EX_NOACTIVATE;
        WndParent := 0;
      end;
    end;