Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging border of Control
    primarykey
    data
    text
    <p>Im having a problem with setting custom border of Control. This border can be done with DrawRectangle, DrawBorder or anything else as long as I get this behaviour</p> <p><img src="https://i.stack.imgur.com/WCijd.jpg" alt="enter image description here"></p> <p>Obviously, the darkest border is where previouse border was. Other borders are around it trying to mimic fade out(or whatever). Now, the most challenging thing is I cannot override OnPaint or extend any other Control. This HAS to work on all Controls! This is part of my extender provider whith which I set these borders when control has focus(like Google Chrome).</p> <p>So far I have come up with this... When adding controls in extender provider dictionary I hook up on Enter and Leave events of control. In there I get the parent of the control that is firing the event and on that form I draw these 3 rectangles. That way I sorted painting on non client area. The thing that remains is painting the actual border of control. I have tried and tried but to no avail.</p> <p>I also hooked up on paint event of that control but ControlPaint.DrawBorder() is not working.</p> <p>Okay, so this is method that is getting called on Enter and leave.</p> <pre><code>private void BojajGlow(Graphics gfx, Graphics gfxCtrl, Control parent, Control kontrola, bool novi) { Rectangle[] rect = new Rectangle[3]; for (int i = 0; i &lt; 3; i++) { int x = kontrola.Location.X - (i + 1); int y = kontrola.Location.Y - (i + 1); int w = kontrola.Size.Width + 2 * (i + 1) - 1; int h = kontrola.Size.Height + 2 * (i + 1) - 1; rect[i] = new Rectangle(x, y, w, h); } if (novi) { Color boja = DohvatiOpcije(kontrola).Boja; for (int i = 0; i &lt; 3; i++) { if (i &gt; 0) boja = Posvjetli(95, ControlPaint.Light(boja)); Pen olovka = new Pen(boja); olovka.EndCap = olovka.StartCap = LineCap.Round; olovka.Width = 1; GraphicsPath gfxPath = new GraphicsPath(); gfxPath.AddRectangle(rect[i]); gfx.DrawPath(olovka, gfxPath); } } else { for (int i = 0; i &lt; 3; i++) { Pen olovka = new Pen(parent.BackColor); olovka.EndCap = olovka.StartCap = LineCap.Round; olovka.Width = 1; GraphicsPath gfxPath = new GraphicsPath(); gfxPath.AddRectangle(rect[i]); gfx.DrawPath(olovka, gfxPath); } } } </code></pre> <p>From Enter event it is going to be called like this</p> <pre><code>if (((Control)sender).Parent != null) BojajGlow(Graphics.FromHwnd(((Control)sender).Parent.Handle), Graphics.FromHwnd(((Control)sender).Handle), ((Control)sender).Parent, (Control)sender, true); </code></pre> <p>Does anyone have any valuable input on this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload