[BUG] Form.SendToBack bring the Form to foreground !

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #71306
    chris2023
    Participant

    procedure TForm1.btn_ShowClick(Sender: TObject);
    begin
    Form2.Show;
    end;

    thats wrong it should to be
    procedure TForm1.btn_ShowClick(Sender: TObject);
    begin
    Form2.BringToFront;
    end;

    #71309
    SzakiLaci
    Participant

    Dear Chris,
    Thank you for trying to help, but you have misunderstood something very much.

    1. Nobody cares, how you bring that form2 to the front. (Mouse, Show, BringToFront, SetFocus )

    2. The problem is the opposite:
    – you can not send it behind the other form !
    Because even if it is already at the back, it brings it to front. What it SHOULD NOT !!!

    #71314
    SzakiLaci
    Participant

    This Solution WORKS fine:

    
    procedure Send_Form_to_Background(h: THandle);
    begin
        SetWindowPos(h, HWND_BOTTOM, 0,0, 0,0, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSENDCHANGING or SWP_NOSIZE or SWP_NOOWNERZORDER);
    end;

    The “trick” is SWP_NOSENDCHANGING which prevents AC to interfere.
    link to MSDN SetWindowPos…

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.