如何防止窗体在用户点击时被激活? [英] How to prevent form from being activated when the users clicks on it?

查看:143
本文介绍了如何防止窗体在用户点击时被激活?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主窗体和非模态自动填充表单。当用户在自动填充表单中点击列表时,如何防止用户自动填充表单被激活?



所以,基本上我想要自动填充表单当用户单击时接收鼠标点击消息,但永远不会变为活动状态,因为它会导致主窗体中无法控制的第三方组件出现问题。

解决方案

覆盖表单的CreateParams方法,并将扩展样式添加到WS_EX_NOACTIVATE样式。

  procedure TForm1.CreateParams(var Params:TCreateParams); 
开始
继承;

Params.WindowClass.ExStyle:= Params.WindowClass.ExStyle或WS_EX_NOACTIVATE;
结束

(内存中编写的代码,可能包含打字错误)


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 autocomplete form?

So, basically I want the autocomplete form the receive the mouse click message when the users clicks, but to never become active, because it causes problems with a third-party component in the main form over which I have no control.

解决方案

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)

这篇关于如何防止窗体在用户点击时被激活?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆