Form without focus/activation

后端 未结 2 589
广开言路
广开言路 2020-12-20 06:47

I want to implement intellisense-like feature for my multiline textbox. The intellisense control is placed in standard form without control box (so, no title or maximize/min

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

    To show the form without activation, override the ShowWithoutActivation property

    protected override bool ShowWithoutActivation
    {
      get { return true; }
    }
    

    And if you do not want to activate the form even on mouse clicks, override the CreateParams and set these styles

    protected override CreateParams CreateParams
    {
      get
      {
        CreateParams p = base.CreateParams;
    
        p.Style |= 0x40000000; // WS_CHILD
        p.ExStyle |= 0x8000000; // WS_EX_NOACTIVATE - requires Win 2000 or higher :)
    
        return p;
      }
    }
    
    0 讨论(0)
  • 2020-12-20 06:59

    i have a code somedays i downloaded from code project (i think ) and i dont what is the original download link try using this

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    
    namespace Balloon.NET
    {
        public class BalloonWindow : Form
        {
            public static readonly int TIPMARGIN;
            public static readonly int TIPTAIL;
    
            public BalloonWindow();
    
            public Point AnchorPoint { get; set; }
            public BalloonWindow.BallonQuadrant Quadrant { get; }
    
            public static Point AnchorPointFromControl(Control anchorControl);
            protected override void Dispose(bool disposing);
            protected override void OnLoad(EventArgs e);
            protected virtual Rectangle OnNCCalcSize(Rectangle windowRect);
            protected virtual void OnNCPaint(Graphics g);
            protected override void OnResize(EventArgs e);
            protected void RecalcLayout();
            protected void RepositionWindow(Point oldAnchorPoint, Point newAnchorPoint);
            public void ShowBalloon(Control anchorControl);
            protected override void WndProc(ref Message m);
    
            public enum BallonQuadrant
            {
                TopLeft = 0,
                TopRight = 1,
                BottomLeft = 2,
                BottomRight = 3,
            }
        }
    }
    

    and use this form as follow

    Balloon.NET.BalloonWindow ms = new Balloon.NET.BalloonWindow();
    private void numberEdit1_TextChanged(object sender, EventArgs e)
    {
        if (!ms.Visible)
        {
            ms.ShowBalloon(numberEdit1);
            numberEdit1.Focus();
        }
    }
    
    0 讨论(0)
提交回复
热议问题