zoukankan      html  css  js  c++  java
  • 解决cefsharp在winform中不显示tooltipText问题(网页元素的title提示)

     1.监听网页属性改变事件

    webView.PropertyChanged += webView_PropertyChanged;

    2.拖一个ToolTip控件到窗体

    3.在webView_PropertyChanged这个事件处理函数中,获取TooltipText并显示出来

      //隐藏toolTip
                    if (this.IsHandleCreated)
                    {
                        this.BeginInvoke(new MethodInvoker(() =>
                        {
                            if (this.IsHandleCreated && !this.IsDisposed)
                            {
                                if (this.toolTip1.Active)
                                {
                                    this.toolTip1.Hide(this);
                                }
                            }
                        }));
                    }
    
    
                    if (e.PropertyName == "TooltipText") //tooltipText改变事件
                    {
                        string tooltipText = this.webView.TooltipText;
                        Point elementPos = new Point(Cursor.Position.X - this.Location.X, Cursor.Position.Y - this.Location.Y);
                        if (!String.IsNullOrEmpty(tooltipText))
                        {
                            this.Invoke(new MethodInvoker(() =>
                            {
                                System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                                timer.Interval = 600;
                                timer.Tick += (timer_sender, timer_e) =>
                                {
                                    Point nowPos = new Point(Cursor.Position.X - this.Location.X, Cursor.Position.Y - this.Location.Y);
                                    //if ((nowPos.X <= elementPos.X + 20 && nowPos.X >= elementPos.X - 20) && (nowPos.Y <= elementPos.Y + 20 && nowPos.Y >= elementPos.Y - 20)) //鼠标停留了500ms(范围限定在一定范围)
                                    if (this.webView.TooltipText == tooltipText) //600毫秒后,tooltipText没变
                                    {
                                        this.toolTip1.Show(tooltipText, this, nowPos.X + 15, nowPos.Y + 15);
                                    }
                                    (timer_sender as System.Windows.Forms.Timer).Stop();
                                    (timer_sender as System.Windows.Forms.Timer).Dispose();
                                };
                                timer.Start();
    
                            }));
                        }
                    }
  • 相关阅读:
    hbase
    pig
    flume
    sqoop
    eclipse 提交作业到JobTracker Hadoop的数据类型要求必须实现Writable接口
    hadoop 8步走
    ssh原理
    MapReduce基础
    Arduino数字贴片磁感应传感器(收藏篇)
    去掉input回车自动提交
  • 原文地址:https://www.cnblogs.com/hdwang/p/3922329.html
Copyright © 2011-2022 走看看