如何在文本框密码字段上禁用系统的大写锁定通知 [英] how to disable System's caps-lock notification on textbox password field

查看:21
本文介绍了如何在文本框密码字段上禁用系统的大写锁定通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Winforms Textbox 中,我定义了新的 ToolTip 并进行了配置.我已将 PasswordChar 设置为*".但是,当大写锁定打开时,会显示两个 tooltip.其中一个是我的,另一个是系统默认的 tooltip 通知.我只想显示我的 tooltip.我想禁用系统的tooltip.如何禁用它?

In Winforms Textbox, I have defined new ToolTip and configured it. I have set the PasswordChar to '*'. However, when caps lock is on, two tooltip is shown. One of them is mine the other one is system's default tooltip notification. I only want to show my tooltip. I want to disable system's tooltip. How can I disable it?

推荐答案

一种方法是从现有的文本框控件派生您自己的文本框控件并处理 EM_SHOWBALLOONTIP 消息.然后只需将此控件拖到您的表单上,而不是常规的文本框控件.

One way is to derive your own textbox control from the existing one and handle the EM_SHOWBALLOONTIP message. Then just drag this control onto your form instead of the regular textbox control.

public partial class PasswordTextBox : TextBox
{
    private const int EM_SHOWBALLOONTIP = 0x1503;

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == EM_SHOWBALLOONTIP)
        {
            m.Result = (IntPtr)0;
            return;
        }
        base.WndProc(ref m);
    }

    public PasswordTextBox()
    {
        InitializeComponent();
    }
}

这篇关于如何在文本框密码字段上禁用系统的大写锁定通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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