I have an application A that listen an application B (using Hook)
ListBox 1 = All application in my desktop with Button or TextBox
As you can see I already have Red Rectangle, I can use two method :
var dc = GetWindowDC((LBListControl.SelectedItem as Data).Value);
            using (Graphics g = Graphics.FromHdc(dc))
            {
                g.DrawRectangle(Pens.Red, 0,0,50,20);
                g.Dispose();
                g.ReleaseHdc(dc);
            }
            // paintedRectangle = lRectangle[i];
            //ControlPaint.DrawReversibleFrame(paintedRectangle, SystemColors.Highlight, FrameStyle.Dashed);
// -> Second Method. It's function that I call when I change my ListBox.SelectedIndex
private void LBListControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                PaintRedRectangle(LBListControl.SelectedIndex);
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }
lRectangle is a list that contains X, Y of my button / textbox (Widht / Height are set by myself).
I heard that using the handle i could change BorderStyle / BorderColor of a controller. If it's true I didn't found a thing about that and I would like to know if you know something.
Else how could I supress my RedRectangle when I want to show someone else ?
BTW : Using g.ReleaseHdc(dc); doesn't work parameter is invalid (Don't know why)
Thank you in advance
![[Application A]](../../images/3824946332.webp)
![[Application B]](../../images/3784182825.webp)