Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've simplified the code a bit and hooked up most of the events to a single method. There is no longer a Form-A, just a Form-B. Form-B now creates it's own Form-A on the fly without any need to actually make a code file. I moved the border size to a variable so it would be easy to adjust it.</p> <pre><code>Imports System.Runtime.InteropServices Public Class InnerForm Private borderSize As Integer = 10 Private border As Form = New Form() Private Sub InnerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load border.FormBorderStyle = Windows.Forms.FormBorderStyle.None border.ShowInTaskbar = False border.BackColor = Color.Blue border.Opacity = 0.5 border.Enabled = False RefreshBorder() End Sub Private Sub DrawRectangle() Dim p As New Drawing2D.GraphicsPath() p.StartFigure() p.AddArc(New Rectangle(0, 0, 40, 40), 180, 90) p.AddLine(40, 0, border.Width - 40, 0) p.AddArc(New Rectangle(border.Width - 40, 0, 40, 40), -90, 90) p.AddLine(border.Width, 40, border.Width, border.Height - 40) p.AddArc(New Rectangle(border.Width - 40, border.Height - 40, 40, 40), 0, 90) p.AddLine(border.Width - 40, border.Height, 40, border.Height) p.AddArc(New Rectangle(0, border.Height - 40, 40, 40), 90, 90) p.CloseFigure() border.Region = New Region(p) End Sub Private Sub RefreshBorder() border.Show() border.Size = New Size(Me.Width + borderSize * 2, Me.Height + borderSize * 2) border.Location = New Point(Me.Location.X - borderSize, Me.Location.Y - borderSize) DrawRectangle() SetWindowPos(border.Handle, Me.Handle, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE) Me.BringToFront() End Sub Private Sub frmMAin_Refresh(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Me.GotFocus, Me.Move, Me.Activated, Me.SizeChanged, MyBase.Shown 'dont show when maximized or minimized, else show it' If Me.WindowState = FormWindowState.Maximized Or Me.WindowState = FormWindowState.Minimized Then border.Hide() Else RefreshBorder() End If End Sub &lt;DllImport("user32.dll")&gt; _ Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean End Function Public Const SWP_NOSIZE As Int32 = &amp;H1 Public Const SWP_NOMOVE As Int32 = &amp;H2 Public Const SWP_NOACTIVATE As Int32 = &amp;H10 End Class </code></pre> <p>Let me know if this works for you.</p>
 

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