How to prevent form from being activated when the users clicks on it?

前端 未结 2 1460
孤独总比滥情好
孤独总比滥情好 2020-12-20 00:25

I have a main form and non-modal autocomplete form. How can I prevent the autocomplete form from being activated by the user, when the user clicks on the list in the autocom

相关标签:
2条回答
  • 2020-12-20 01:06

    Override CreateParams method of your form and add WS_EX_NOACTIVATE style to the extended styles.

    procedure TForm1.CreateParams(var Params: TCreateParams);
    begin
      inherited;
    
      Params.WindowClass.ExStyle := Params.WindowClass.ExStyle or WS_EX_NOACTIVATE;
    end;
    

    (code written from memory, might contain typos)

    0 讨论(0)
  • 2020-12-20 01:17

    Use CreateParams (Alex T. answer) or you can try set YourForm.Enabled to False.

    0 讨论(0)
提交回复
热议问题