none
Customised Form leaves trails when moving. RRS feed

  • Question

  • Hi,

       I am working on a customised form that looks like a FixedToolWindow (i.e. square, not rounded borders) but can have a border with a specified colour and an icon at the top left.  I have produced a working solution using a "blank" form by setting its borderstyle to FormBorderStyle.None and placing suitable components to give movement, close and icon functionality as well as the required border.  The problem is that when I move the form over another form / component it leaves multiple border trails until the move stops.  I have used several methods to draw the border:

     Private Sub Me_Paint(ByVal sender As Object, _
           ByVal e As System.Windows.Forms.PaintEventArgs) _
           Handles Me.Paint
      Dim BorderPen As New Pen(_BorderColour, 1)
      
      e.Graphics.DrawRectangle(BorderPen, 0, 0, Me.Width - 1, Me.Height - 1)
      Me.SendToBack()
     End Sub
    
    and:
     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        MyBase.OnPaint(e)
      Dim BorderPen As New Pen(_BorderColour, 1)
      
      e.Graphics.DrawRectangle(BorderPen, 0, 0, Me.Width - 1, Me.Height - 1)
     End Sub

       Is anyone aware of this type of problem and is there a way to remove these trails?

    All the best,
                          HotIndigo.


    Monday, April 23, 2018 1:37 PM

All replies

  • In the form resize event or locationchanged event add:

        Me.Invalidate.

    this will fire the paint event.

    PS you only need one paint event for the form/control you show two.

    Monday, April 23, 2018 2:02 PM
  • Hi tommytwotrain,

       Thanks - I will try it.  I probably wasn't clear enough - I tried one of each subroutine and both methods gave the same trailing.

    All the best,
                               Hot Indigo.

    Monday, April 23, 2018 2:11 PM
  •  Hi tommytwotrain,

    I tried your suggestion - same result - lots of trailing :(. 

    Thanks anyway,
                                     HotIndigo.

    PS sorry about the deleted reply - still fumbling aroud with the features!

    Monday, April 23, 2018 2:31 PM
  •  Hi tommytwotrain,

    I tried your suggestion - same result - lots of trailing :(. 

    Thanks anyway,
                                     HotIndigo.

    PS sorry about the deleted reply - still fumbling aroud with the features!

    Please show a simple one form example that reproduces the problem and describe the steps to reproduce the problem.

    Monday, April 23, 2018 2:41 PM
  • Did you set the Forms DoubleBuffered property to True?

    La vida loca

    Monday, April 23, 2018 3:09 PM
  • Hi Mr. Monkeyboy,

       The form is set to DoubleBuffered = true.  Oddly enough, by setting it to false it reduces the problem slightly!

    Many thanks,
                           HotIndigo.

    Monday, April 23, 2018 8:54 PM
  • Hi Mr. Monkeyboy,

       The form is set to DoubleBuffered = true.  Oddly enough, by setting it to false it reduces the problem slightly!

    Many thanks,
                           HotIndigo.


    Well without seeing all the code then it is difficult to see why moving it would cause this issue. There are various methods to use for moving a borderless Form with a Mouse but the one you use may be affecting the painting or causing the trails. If you're using a wndproc sub to get windows messages for moving the form then perhaps you would call the paint events in that or something.

    La vida loca



    Monday, April 23, 2018 9:00 PM
  • Here's a Borderless Form with a red rectangle drawn in the upper left corner. It doesn't ghost when dragging it over Form2. Nor is it double buffered.

    Option Strict On
    
    Public Class Form1
    
        Private Const WM_NCHITTEST As Integer = &H84
        Private Const WM_MOUSEMOVE As Integer = &H200
        Private Const WM_LBUTTONDOWN As Integer = &H201
        Private Const WM_LBUTTONUP As Integer = &H202
        Private Const MK_LBUTTON As Integer = &H1
        Private Const HTLEFT As Integer = &HA
        Private Const HTRIGHT As Integer = &HB
        Private Const HTTOP As Integer = &HC
        Private Const HTTOPLEFT As Integer = &HD
        Private Const HTTOPRIGHT As Integer = &HE
        Private Const HTBOTTOM As Integer = &HF
        Private Const HTBOTTOMLEFT As Integer = &H10
        Private Const HTBOTTOMRIGHT As Integer = &H11
        Private OffSet As Point = Point.Empty
    
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.BackColor = Color.DarkSlateGray
            Panel1.BackColor = Color.DarkCyan
            Button1.BackColor = Color.DarkSlateGray
            TextBox1.BackColor = Color.DarkSlateGray
            Label1.BackColor = Color.Red
            Label2.BackColor = Color.Red
        End Sub
    
        Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
            e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
            e.Graphics.FillRectangle(Brushes.Red, 0, 0, 50, 50)
        End Sub
    
        Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
            If Label1.Text = "X" Then
                Application.Exit()
            End If
        End Sub
    
        Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
            If Label2.Text = "__" Then
                Me.WindowState = FormWindowState.Minimized
            End If
        End Sub
    
        Protected Overrides Sub WndProc(ByRef m As Message)
            If m.Msg = WM_NCHITTEST Then
                Dim loc As New Point(m.LParam.ToInt32 And &HFFFF, m.LParam.ToInt32 >> 16)
                loc = PointToClient(loc)
                Dim bTop As Boolean = (loc.Y < ClientRectangle.Y + 4)
                Dim bLeft As Boolean = (loc.X < ClientRectangle.X + 4)
                Dim bRight As Boolean = (loc.X > Width - 4)
                Dim bBottom As Boolean = (loc.Y > Height - 4)
                If bTop And bLeft Then
                    m.Result = CType(HTTOPLEFT, IntPtr)
                    Return
                ElseIf bTop And bRight Then
                    m.Result = CType(HTTOPRIGHT, IntPtr)
                    Return
                ElseIf bBottom And bLeft Then
                    m.Result = CType(HTBOTTOMLEFT, IntPtr)
                    Return
                ElseIf bBottom And bRight Then
                    m.Result = CType(HTBOTTOMRIGHT, IntPtr)
                    Return
                ElseIf bLeft Then
                    m.Result = CType(HTLEFT, IntPtr)
                    Return
                ElseIf bTop Then
                    m.Result = CType(HTTOP, IntPtr)
                    Return
                ElseIf bRight Then
                    m.Result = CType(HTRIGHT, IntPtr)
                    Return
                ElseIf bBottom Then
                    m.Result = CType(HTBOTTOM, IntPtr)
                    Return
                End If
            ElseIf m.Msg = WM_LBUTTONDOWN Then
                OffSet = New Point(MousePosition.X - Me.Location.X, MousePosition.Y - Me.Location.Y)
            ElseIf m.Msg = WM_MOUSEMOVE AndAlso m.WParam.ToInt32 = MK_LBUTTON Then
                Me.Location = New Point(MousePosition.X - OffSet.X, MousePosition.Y - OffSet.Y)
            End If
            MyBase.WndProc(m)
        End Sub
    
    
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim f2 As New Form2
            f2.Show()
        End Sub
    End Class


    La vida loca

    Monday, April 23, 2018 9:10 PM
  • Hi tommytwotrain,

       The essential code is:

    Friend Class frm_Squared
    
    	Private Posn As Point
    	Private fMove as Integer = 0
    
    	Private Sub BrdrForm_Load(ByVal sender As Object, _
    				  ByVal e As System.EventArgs) _
    				  Handles Me.Load
    
    	    With Me
    
    		.ParentForm.FormBorderStyle = FormBorderStyle.None
    		.DoubleBuffered = True
    		.Dock = DockStyle.Fill
    		.SendToBack()
    
    	    End With
    
       ' This is the top panel to move the form when clicked and mouse moved.
    	
    	    With pnl_Header
    		
    		.Height = 30
    		.Dock = DockStyle.Top
    		.BackColor = Color.LightGray
    
    	    End With
    
    	End Sub
    
    	Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    	    MyBase.OnPaint(e)
    		
    	    Dim BorderPen As New Pen(_BorderColour, 1)
    	  
    	    e.Graphics.DrawRectangle(BorderPen, 0, 0, Me.Width - 1, Me.Height - 1)
    	  
    	End Sub
    
    	Private Sub pnl_Header_MouseDown(ByVal sender As Object, _
    					 ByVal e As System.Windows.Forms.MouseEventArgs) _
    					 Handles pnl_Header.MouseDown
    
    	    fMove = 1
    	    Posn = e.Location
    
    	End Sub
    
    	Private Sub pnl_Header_MouseMove(ByVal sender As Object, _
    					 ByVal e As System.Windows.Forms.MouseEventArgs) _
    					 Handles pnl_Header.MouseMove
    
    	    If fMove = 1 Then
    
    		Dim X As Integer = Me.ParentForm.Location.X + (e.Location.X - Posn.X)
    		Dim Y As Integer = Me.ParentForm.Location.Y + (e.Location.Y - Posn.Y)
    
    		Posn.X = e.Location.X
    		Posn.Y = e.Location.Y
    
    		Me.ParentForm.Location = New Point(X, Y)
    
    	    End If
    
    	End Sub
    
    	Private Sub pnl_Header_MouseUp(ByVal sender As Object, _
    				       ByVal e As System.Windows.Forms.MouseEventArgs) _
    				       Handles pnl_Header.MouseUp
    		fMove = 0
    
    	End Sub
    
    End Class
    

       The mouse events are responsible for the form movement.  I hope this helps.

    All the best,
                          HotIndigo.

    Monday, April 23, 2018 9:43 PM
  • That could be the issue.

    This code is responsible for the move and resize of the Form in my code.

        Private Const WM_NCHITTEST As Integer = &H84
        Private Const WM_MOUSEMOVE As Integer = &H200
        Private Const WM_LBUTTONDOWN As Integer = &H201
        Private Const WM_LBUTTONUP As Integer = &H202
        Private Const MK_LBUTTON As Integer = &H1
        Private Const HTLEFT As Integer = &HA
        Private Const HTRIGHT As Integer = &HB
        Private Const HTTOP As Integer = &HC
        Private Const HTTOPLEFT As Integer = &HD
        Private Const HTTOPRIGHT As Integer = &HE
        Private Const HTBOTTOM As Integer = &HF
        Private Const HTBOTTOMLEFT As Integer = &H10
        Private Const HTBOTTOMRIGHT As Integer = &H11
        Private OffSet As Point = Point.Empty
    
        Protected Overrides Sub WndProc(ByRef m As Message)
            If m.Msg = WM_NCHITTEST Then
                Dim loc As New Point(m.LParam.ToInt32 And &HFFFF, m.LParam.ToInt32 >> 16)
                loc = PointToClient(loc)
                Dim bTop As Boolean = (loc.Y < ClientRectangle.Y + 4)
                Dim bLeft As Boolean = (loc.X < ClientRectangle.X + 4)
                Dim bRight As Boolean = (loc.X > Width - 4)
                Dim bBottom As Boolean = (loc.Y > Height - 4)
                If bTop And bLeft Then
                    m.Result = CType(HTTOPLEFT, IntPtr)
                    Return
                ElseIf bTop And bRight Then
                    m.Result = CType(HTTOPRIGHT, IntPtr)
                    Return
                ElseIf bBottom And bLeft Then
                    m.Result = CType(HTBOTTOMLEFT, IntPtr)
                    Return
                ElseIf bBottom And bRight Then
                    m.Result = CType(HTBOTTOMRIGHT, IntPtr)
                    Return
                ElseIf bLeft Then
                    m.Result = CType(HTLEFT, IntPtr)
                    Return
                ElseIf bTop Then
                    m.Result = CType(HTTOP, IntPtr)
                    Return
                ElseIf bRight Then
                    m.Result = CType(HTRIGHT, IntPtr)
                    Return
                ElseIf bBottom Then
                    m.Result = CType(HTBOTTOM, IntPtr)
                    Return
                End If
            ElseIf m.Msg = WM_LBUTTONDOWN Then
                OffSet = New Point(MousePosition.X - Me.Location.X, MousePosition.Y - Me.Location.Y)
            ElseIf m.Msg = WM_MOUSEMOVE AndAlso m.WParam.ToInt32 = MK_LBUTTON Then
                Me.Location = New Point(MousePosition.X - OffSet.X, MousePosition.Y - OffSet.Y)
            End If
            MyBase.WndProc(m)
        End Sub
    


    La vida loca

    Monday, April 23, 2018 9:59 PM
  • Hi tommytwotrain,

       The essential code is:

    Friend Class frm_Squared
    
    	Private Posn As Point
    	Private fMove as Integer = 0
    
    	Private Sub BrdrForm_Load(ByVal sender As Object, _
    				  ByVal e As System.EventArgs) _
    				  Handles Me.Load
    
    	    With Me
    
    		.ParentForm.FormBorderStyle = FormBorderStyle.None
    		.DoubleBuffered = True
    		.Dock = DockStyle.Fill
    		.SendToBack()
    
    	    End With
    
       ' This is the top panel to move the form when clicked and mouse moved.
    	
    	    With pnl_Header
    		
    		.Height = 30
    		.Dock = DockStyle.Top
    		.BackColor = Color.LightGray
    
    	    End With
    
    	End Sub
    
    	Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    	    MyBase.OnPaint(e)
    		
    	    Dim BorderPen As New Pen(_BorderColour, 1)
    	  
    	    e.Graphics.DrawRectangle(BorderPen, 0, 0, Me.Width - 1, Me.Height - 1)
    	  
    	End Sub
    
    	Private Sub pnl_Header_MouseDown(ByVal sender As Object, _
    					 ByVal e As System.Windows.Forms.MouseEventArgs) _
    					 Handles pnl_Header.MouseDown
    
    	    fMove = 1
    	    Posn = e.Location
    
    	End Sub
    
    	Private Sub pnl_Header_MouseMove(ByVal sender As Object, _
    					 ByVal e As System.Windows.Forms.MouseEventArgs) _
    					 Handles pnl_Header.MouseMove
    
    	    If fMove = 1 Then
    
    		Dim X As Integer = Me.ParentForm.Location.X + (e.Location.X - Posn.X)
    		Dim Y As Integer = Me.ParentForm.Location.Y + (e.Location.Y - Posn.Y)
    
    		Posn.X = e.Location.X
    		Posn.Y = e.Location.Y
    
    		Me.ParentForm.Location = New Point(X, Y)
    
    	    End If
    
    	End Sub
    
    	Private Sub pnl_Header_MouseUp(ByVal sender As Object, _
    				       ByVal e As System.Windows.Forms.MouseEventArgs) _
    				       Handles pnl_Header.MouseUp
    		fMove = 0
    
    	End Sub
    
    End Class

       The mouse events are responsible for the form movement.  I hope this helps.

    All the best,
                          HotIndigo.

    Indi,

    I don't see a resize event handler or locationchanged? There is no event that updates the form after you change the location?

    I cant tell what you are doing exactly from the example but I cant duplicate any trail ghosting with your code as a one form example although it does not work quite right.

    So apparently there is something more in the code not shown? What do you call trails exactly can you show an image?

    Also you could call invalidate or refresh from the pnl_Header_MouseMove event instead of resize or locationchanged. But the system does not call the paint event with some of these cases you have to do it with invalidate or refresh.

    You don't need the panel to do what you are doing you can drag the form the same way. Is that what you want to do is move the borderless form?


    Monday, April 23, 2018 10:13 PM
  • Hi tommytwotrain and Mr. Monkeyboy,

      Thanks for all your suggestions and guidance.  I tried your ideas and have uncovered a subtler problem that I had not anticipated.  My forms contain customised panels (called in from a .dll) that appear to be the real cause of the trailing.  When Mr. Monkeyboy's form goes over these panels, it leaves a trail!  Obviously I have omitted something from the .dll code, or done something wrong.  I have attached the full code - maybe there is a clue there.

    Option Strict On
    Option Explicit Off
    
    Imports System.ComponentModel
    Imports System.ComponentModel.Design
    Imports System.Drawing.Drawing2D
    
    <Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", _
    		  GetType(IDesigner))> _
    <ToolboxBitmap(GetType(qPanel), "BorderedPanel")> _
    Public Class qPanel
    
    Inherits UserControl
    Implements IContainerControl
    
    	Private _ContainerColour As Color = ColorTranslator.FromOle(&HC0C0C0)	  ' = Color.Yellow
    	Private _BorderColour As Color = Color.Black
    
    '   Container Colour 
    
    	<Description("Container Colour.")> _
    	Public Property ContainerColour() As Color
    	    Get
    		Return _ContainerColour
    	    End Get
    	    Set(ByVal value As Color)
    		_ContainerColour = value
    		Me.Invalidate()
    	    End Set
    	End Property
    
    '   Border Line Colour .
    
    	<Description("Border Line Colour.")> _
    	Public Property BorderColour() As Color
    	    Get
    		Return _BorderColour
    	    End Get
    	      Set(ByVal value As Color)
    		_BorderColour = value
    		Me.Invalidate()
    	    End Set
    	End Property
    
    	Private Sub qPanel_Load(ByVal sender As Object, _
    				ByVal e As System.EventArgs) _
    				Handles Me.Load
    	    Me.TabStop = False
    
    	End Sub
    
    	Private Sub qPanel_Paint(ByVal sender As Object, _
    				 ByVal e As System.Windows.Forms.PaintEventArgs) _
    				 Handles Me.Paint
    
    		Dim RX As Integer = Me.Width - 1
    		Dim RY As Integer = Me.Height - 1
    		Dim Top As Integer = 0
    		Dim LHS As Integer = 0
    		Dim gr As Graphics = e.Graphics
    
    		Me.BackColor = _ContainerColour
    
    		Dim bSb As New Pen(_BorderColour, 1)
    		Dim gp As GraphicsPath = New GraphicsPath
    		Dim RPb As New Rectangle(LHS, Top, RX, RY)
    
    		gp.AddRectangle(RPb)
    		gr.DrawPath(bSb, gp)
    
    ''Tidy up resources.
    
    		gp.Dispose()
    
    	End Sub
    
    	Private Sub qPanel_Resize(sender As Object, _
    				  e As System.EventArgs) _
    				  Handles Me.Resize
    		Me.Invalidate()
    	End Sub
    
    End Class
    
    
    

    Any observations on this would be welcome.

    All the best,
                        HotIndigo

    Tuesday, April 24, 2018 10:41 PM
  • You dispose of the Graphics path but not the Pen.

    Why don't you use e.Graphics to draw rather than creating new graphics as e.Graphics?

    Is it the Form or the custom control that leaves ghosting? That would be 2 different things.


    La vida loca


    Tuesday, April 24, 2018 11:59 PM
  •  I have no real idea how you are using the UserControl but,  this is how I would change the code.  I left a few comments in the code.

     However,  the only way we are going to know how to reproduce the same exact problem you are having is if you post a simple example that we can copy, paste, and debug.  I have seen this problem caused from a few different thing over the years so,  it is not clear where the problem is coming from yet.

    Imports System.ComponentModel Imports System.Drawing.Drawing2D Public Class qPanel

    Private _ContainerColour As Color = Color.Silver 'the color you had was just the common color Silver Private _BorderColour As Color = Color.Black <Description("Container Colour.")> Public Property ContainerColour() As Color Get Return _ContainerColour End Get Set(ByVal value As Color) _ContainerColour = value Me.Invalidate(False) End Set End Property <Description("Border Line Colour.")> Public Property BorderColour() As Color Get Return _BorderColour End Get Set(ByVal value As Color) _BorderColour = value Me.Invalidate(False) End Set End Property Private Sub qPanel_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.TabStop = False Me.BackColor = _ContainerColour 'set the BackColor here. You should avoid setting any properties in the Paint event. That event should only be used for drawing on the control. Me.ResizeRedraw = True 'just set this to get the usercontrol to redraw itself when it is resized, you don't need to use the Resize event for this. End Sub Private Sub qPanel_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Using gp As New GraphicsPath, bSb As New Pen(_BorderColour, 1) gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1)) e.Graphics.DrawPath(bSb, gp) End Using 'the new GraphicsPath and Pen will be disposed when this line is executed End Sub End Class



    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Wednesday, April 25, 2018 1:01 AM
    Wednesday, April 25, 2018 12:58 AM
  • Hi Mr M,

       It is the custom control (a panel) that leaves the trails. The container form doesn't show trailing.  The idea behind the custom panel is to have a definable border colour.

    HoIndigo.

    Wednesday, April 25, 2018 6:36 AM
  • Hi IronRazarz,

       I have a test project with forms and the .dll files but I feel it's a bit large to post.  Is there any way I can post it complete as a .zip file - it would be a simpler option.

    HotIndigo.

    Wednesday, April 25, 2018 10:57 AM
  • Hi IronRazarz,

       I have a test project with forms and the .dll files but I feel it's a bit large to post.  Is there any way I can post it complete as a .zip file - it would be a simpler option.

    HotIndigo.

    Indi,

    You will be lucky if anyone will download and debug your project for you.

    You should be able to create a simple one form example of the problem. In the process of trying to make a one form example you may solve the problem. If not post the example and we will try.

    And as part of the problem statement you need to describe what you mean in enough detail that we can understand the problem.

    "It is the custom control (a panel) that leaves the trails. The container form doesn't show trailing. "

    Does not describe the problem well enough to debug the code.

    I asked for an image showing the "trails" can you capture it and post it? At least better describe it.

    Is the trailing on the screen/desktop or application viewport? Is the custom control panel drawing on the screen or the panel control? What is drawing what and where. Its still not clear to me and all we can do is guess or tell you how to draw. Describe what the .dll is doing and etc.

    PS If you backup and describe what your overall goal is, what you want to do with the .dll and the panel and the code you are using, maybe there is a better way. Why a .dll ? Did you write the .dll? Lets see some of that maybe. Maybe you don't need the .dll? Maybe you don't need any of the custom drawing if you draw a different, better way. Even redesign your app to do it the better way that does not need custom panels and dlls??

    Wednesday, April 25, 2018 1:47 PM
  • Hi TommyT,

       It isn't the full project, just a sample of the code with an implementation that demontrates the "trailing".  The .dll contains the custom panel and custom input panel code.  These are then dropped into the custom form for the final project.

       The code I have put together, to post, is the absolute minimum to recreate the problem.  It consists of 2 panels in the .dll, the custom form and the working code for a MDIcontainer form which will contain several custom forms (each containing some custom panels) and a standard FixedToolWindow (also containing some custom panels) for comparison.  If it sounds acceptable, I will post it with instructions of what to put where.

    HotIndigo.

    Wednesday, April 25, 2018 4:09 PM
  • Hi TommyT,

       Just managed to capture the trailing of the custom form moving over a FixedToolWindow form containing two "qPanels" (custom bordered panels) at the top and 4 "qInputs" (custom input panels) below.  I was dragging "Trailing Form" (the custom form) from lower right to upper left.  The custom form uses much of the code posted by Mr Monkeyboy.

    HotIndigo.


    • Edited by HotIndigo Wednesday, April 25, 2018 4:23 PM
    Wednesday, April 25, 2018 4:20 PM
  • Hi TommyT,

       Just managed to capture the trailing of the custom form moving over a FixedToolWindow form containing two "qPanels" (custom bordered panels) at the top and 4 "qInputs" (custom input panels) below.  I was dragging "Trailing Form" (the custom form) from lower right to upper left.  The custom form uses much of the code posted by Mr Monkeyboy.

    HotIndigo.



    Indi,

    Ok that image is an improvement.

    Sorry I still cant guess what is happening based on what I see.

    It does look like you have a transparent window that is not being updated or something. It looks like the background form? midi? Panel? needs to be painted in the trailing form mouse move event. Or the background is not being captured properly or etc. Or the qpanel is not getting its paint event when needed.

    Is it all one application and main form? What is the gray area surrounding the trailing form and everything else, the main app form? So we see one application in the image? or is the green trailing form another application or another form (or a mdi form)?

    I still don't see the purpose of qpanel. What is it doing that is so fancy it needs a dll? Transparent panel is that what it is? All that does is show the form below. Which is what you are seeing?? But its not being updated as the mouse moves? Not sure why exactly. But I still question the need for qpanel but maybe I still don't understand.

    Wednesday, April 25, 2018 5:43 PM
  • Many thanks for all the suggestions - I am currently experimenting with them, but if it doesn't go well I will post the code that will reproduce the problem.

    HotIndigo.

    Friday, April 27, 2018 7:59 AM
  • Hi all,

    I tried some experiments using a non-dll way but the results are still the same - trailing.  The attached picture illustrates this.

    I have enclused the full code which should work with a simple cut and paste into a new Windows Application.  It's a cse of copying the Form1 code into Form1 and creating 3 new classes for the classes.  It looks horrendous but when I placed a qForm into the Form1 designer I could not get the qPanel or the qInput to drop into the qForm - they attached into the Form1!

    '   New Windows Form Application   Form1
    
    Imports System.ComponentModel
    
    Public Class Form1
    
    Inherits System.Windows.Forms.Form
    
        Friend WithEvents QForm1 As TestForm.qForm
        Friend WithEvents QForm2 As TestForm.qForm
        Friend WithEvents QInput1 As TestForm.qInput
        Friend WithEvents QInput2 As TestForm.qInput
        Friend WithEvents QInput3 As TestForm.qInput
        Friend WithEvents QInput4 As TestForm.qInput
        Friend WithEvents QInput5 As TestForm.qInput
        Friend WithEvents QInput6 As TestForm.qInput
        Friend WithEvents QInput7 As TestForm.qInput
        Friend WithEvents QInput8 As TestForm.qInput
        Friend WithEvents QPanel1 As TestForm.qPanel
        Friend WithEvents QPanel2 As TestForm.qPanel
        Friend WithEvents QPanel3 As TestForm.qPanel
        Friend WithEvents QPanel4 As TestForm.qPanel
        Friend WithEvents QPanel5 As TestForm.qPanel
        Friend WithEvents QPanel6 As TestForm.qPanel
    
        Private Sub InitializeComponent()
    
            Dim I As Integer
            Dim Ypos As Integer
            Dim Offset As Integer = 0
    
            Dim FormList(1) As qForm
            Dim PanelList(5) As qPanel
            Dim InputList(7) As qInput
    
            Me.QForm1 = New TestForm.qForm()
            Me.QForm2 = New TestForm.qForm()
            Me.QPanel1 = New TestForm.qPanel()
            Me.QPanel2 = New TestForm.qPanel()
            Me.QPanel3 = New TestForm.qPanel()
            Me.QPanel4 = New TestForm.qPanel()
            Me.QPanel5 = New TestForm.qPanel()
            Me.QPanel6 = New TestForm.qPanel()
            Me.QInput1 = New TestForm.qInput()
            Me.QInput2 = New TestForm.qInput()
            Me.QInput3 = New TestForm.qInput()
            Me.QInput4 = New TestForm.qInput()
            Me.QInput5 = New TestForm.qInput()
            Me.QInput6 = New TestForm.qInput()
            Me.QInput7 = New TestForm.qInput()
            Me.QInput8 = New TestForm.qInput()
            Me.SuspendLayout()
    
            FormList(0) = Me.QForm1
            FormList(1) = Me.QForm2
            PanelList(0) = Me.QPanel1
            PanelList(1) = Me.QPanel2
            PanelList(2) = Me.QPanel3
            PanelList(3) = Me.QPanel4
            PanelList(4) = Me.QPanel5
            PanelList(5) = Me.QPanel6
            InputList(0) = Me.QInput1
            InputList(1) = Me.QInput2
            InputList(2) = Me.QInput3
            InputList(3) = Me.QInput4
            InputList(4) = Me.QInput5
            InputList(5) = Me.QInput6
            InputList(6) = Me.QInput7
            InputList(7) = Me.QInput8
            'QForm1
            Me.QForm1.BackColor = System.Drawing.Color.LightGray
            Me.QForm1.Controls.Add(Me.QPanel1)
            Me.QForm1.Controls.Add(Me.QPanel2)
            Me.QForm1.Controls.Add(Me.QPanel3)
            Me.QForm1.Controls.Add(Me.QInput1)
            Me.QForm1.Controls.Add(Me.QInput2)
            Me.QForm1.Controls.Add(Me.QInput3)
            Me.QForm1.Controls.Add(Me.QInput4)
            Me.QForm1.Location = New System.Drawing.Point(28, 24)
            Me.QForm1.Name = "QForm1"
            Me.QForm1.Size = New System.Drawing.Size(365, 444)
            Me.QForm1.TabIndex = 1
            'QForm2
            Me.QForm2.BackColor = System.Drawing.Color.LightGray
            Me.QForm2.Controls.Add(Me.QPanel4)
            Me.QForm2.Controls.Add(Me.QPanel5)
            Me.QForm2.Controls.Add(Me.QPanel6)
            Me.QForm2.Controls.Add(Me.QInput5)
            Me.QForm2.Controls.Add(Me.QInput6)
            Me.QForm2.Controls.Add(Me.QInput7)
            Me.QForm2.Controls.Add(Me.QInput8)
            Me.QForm2.Location = New System.Drawing.Point(428, 24)
            Me.QForm2.Name = "QForm2"
            Me.QForm2.Size = New System.Drawing.Size(365, 444)
            Me.QForm2.TabIndex = 3
            'QPanels
            Offset = 50
            Ypos = 66
            For I = 0 To 5
                PanelList(I).BackColor = System.Drawing.Color.Silver
                PanelList(I).BorderColour = System.Drawing.Color.Black
                PanelList(I).ContainerColour = System.Drawing.Color.Silver
                PanelList(I).Location = New System.Drawing.Point(51, Ypos)
                PanelList(I).Name = "QPanel1"
                PanelList(I).Size = New System.Drawing.Size(250, 36)
                PanelList(I).TabIndex = 10
                If I = 2 Then
                    Ypos = 66
                Else
                    Ypos += Offset
                End If
            Next
            'QInputs
            Offset = 45
            Ypos = 243
            For I = 0 To 7
                InputList(I).BackColor = System.Drawing.Color.White
                InputList(I).BorderColour = System.Drawing.Color.Black
                InputList(I).ContainerColour = System.Drawing.Color.White
                InputList(I).InputColour = System.Drawing.Color.Black
                InputList(I).InputOffset = 2
                InputList(I).InputText = ""
                InputList(I).InputTop = 0
                InputList(I).InputWidth = 50
                InputList(I).Location = New System.Drawing.Point(51, Ypos)
                InputList(I).Name = "QInput1"
                InputList(I).Size = New System.Drawing.Size(273, 21)
                InputList(I).TabIndex = 6
                InputList(I).Tag = 0
                InputList(I).Text = " 0"
                InputList(I).PromptColour = System.Drawing.Color.Black
                InputList(I).PromptTop = 1
                If I = 3 Then
                    Ypos = 243
                Else
                    Ypos += Offset
                End If
            Next
            'Form1
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(1210, 633)
            Me.Controls.Add(Me.QForm2)
            Me.Controls.Add(Me.QForm1)
            Me.IsMdiContainer = True
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
            Me.ResumeLayout(False)
        End Sub
    
    End Class
    
    
    '   New Class   qPanel
    
    
    Option Strict On
    Option Explicit Off
    
    Imports System.ComponentModel
    Imports System.Drawing.Drawing2D
    
    Public Class qPanel
    
    Inherits Panel
    
        Private _ContainerColour As Color = ColorTranslator.FromOle(&HC0C0C0)
        Private _BorderColour As Color = Color.Black
    
        Public Property BorderColour() As Color
            Get
                Return _BorderColour
            End Get
            Set(ByVal value As Color)
                _BorderColour = value
                Me.Invalidate()
           End Set
        End Property
    
        Public Property ContainerColour() As Color
            Get
                Return _ContainerColour
            End Get
            Set(ByVal value As Color)
                _ContainerColour = value
                Me.BackColor = _ContainerColour
                Me.Invalidate()
           End Set
        End Property
    
        Friend Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub
    
        Private Sub InitializeComponent()
            Me.SuspendLayout()
            'qPanel
            Me.TabStop = False
            Me.BackColor = _ContainerColour
            Me.BorderColour = Color.Black
            Me.ResizeRedraw = True            ' Set the usercontrol to redraw itself when resized.
            Me.ResumeLayout(False)
        End Sub
    
        Private Sub qPanel_Paint(ByVal sender As Object, _
                                 ByVal e As System.Windows.Forms.PaintEventArgs) _
                                 Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(_BorderColour, 1)
                gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using
        End Sub
    
    End Class
    
    
    '   New Class   qInput
    
    
    Option Strict On
    Option Explicit Off
    
    Imports System.ComponentModel
    Imports System.Drawing.Drawing2D
    
    Public Class qInput
    
    Inherits Panel
    
        Friend WithEvents txt_Entry As System.Windows.Forms.TextBox
        Friend WithEvents lbl_Prompt As System.Windows.Forms.Label
    
        Private _BorderColour As Color = Color.Black    ' Input Panel Border Colour (1 pixel thick).
        Private _InnerBorderColour As Color = Color.Red ' Text Box    Border Colour (1 pixel thick).
        Private _ContainerColour As Color = Color.White ' Input Panel Background Colour.
        Private _InputText As String = "0g"
        Private _InputOffset As Integer = 2             ' Text Entry Offset from Panel LHS.
        Private _InputWidth As Integer = 50             ' Text Input Box Width.
        Private _InputTop As Integer = 0                ' Text Input Box Top relative to Panel.
        Private _InputColour As Color = Color.Black     ' Input Text Colour.
        Private _PromptText As String = "Prompt"        ' Prompt Panel Text.
        Private _PromptTop As Integer = 1               ' Prompt Panel Top.
        Private _PromptFont As Font                     ' PrPromptompt Panel Text Font.
        Private _PromptColour As Color = Color.Black    ' Prompt Panel Text Colour.
        Private _Width As Integer = 200                 ' Input Panel Width.
        Private _Height As Integer = 20                 ' Input Panel Height.
    
        Private _InputHeight As Integer     ' Text Input Box Height.
        Private _PromptHeight As Integer    ' Prompt Panel Height.
        Private _PromptLeft As Integer      ' Text Input Box LHS.
    
    #Region "Public Properties"
    
        <Description("Panel Border Colour.")> _
        Public Property BorderColour() As Color
            Get
                Return _BorderColour
            End Get
            Set(ByVal value As Color)
                _BorderColour = value
                Me.Invalidate()
           End Set
        End Property
    
        <Description("Container Colour.")> _
        Public Property ContainerColour() As Color
            Get
                Return _ContainerColour
            End Get
            Set(ByVal value As Color)
                _ContainerColour = value
                Me.BackColor = value
                lbl_Prompt.BackColor = value
                txt_Entry.BackColor = value
                Me.Invalidate()
           End Set
        End Property
    
        <Description("Text Entry panel offset from Left.")> _
        Public Property InputOffset() As Integer
            Get
                Return _InputOffset
            End Get
            Set(ByVal value As Integer)
                _InputOffset = value
                Call SetPanelPositions()
           End Set
        End Property
    
        <Description("Text Entry panel top.")> _
        Public Property InputTop() As Integer
            Get
                Return _InputTop
            End Get
            Set(ByVal value As Integer)
                _InputTop = value
                Call SetPanelPositions()
           End Set
        End Property
    
        <Description("Text Entry panel width.")> _
        Public Property InputWidth() As Integer
            Get
                Return _InputWidth
            End Get
            Set(ByVal value As Integer)
                _InputWidth = value
                Call SetPanelPositions()
           End Set
        End Property
    
        <Description("Input text.")> _
        Public Property InputText() As String
            Get
                Return _InputText
            End Get
            Set(ByVal value As String)
                _InputText = value
           End Set
        End Property
    
        <Description("Input text colour.")> _
        Public Property InputColour() As Color
            Get
                Return _InputColour
            End Get
            Set(ByVal value As Color)
                _InputColour = value
                txt_Entry.ForeColor = value
           End Set
        End Property
    
        <Description("Prompt Panel top.")> _
        Public Property PromptTop() As Integer
            Get
                Return _PromptTop
            End Get
            Set(ByVal value As Integer)
                _PromptTop = value
                Call SetPanelPositions()
           End Set
        End Property
    
        <Description("Prompt text colour.")> _
        Public Property PromptColour() As Color
            Get
                Return _PromptColour
            End Get
            Set(ByVal value As Color)
                _PromptColour = value
                lbl_Prompt.ForeColor = value
           End Set
        End Property
    
    #End Region
    
        Public Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub
    
        Private Sub InitializeComponent()
            Me.lbl_Prompt = New System.Windows.Forms.Label()
            Me.txt_Entry = New System.Windows.Forms.TextBox()
            Me.SuspendLayout()
            'lbl_Prompt
            Me.lbl_Prompt.AutoSize = True
            Me.lbl_Prompt.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(192, Byte), Integer))
            Me.lbl_Prompt.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.lbl_Prompt.Location = New System.Drawing.Point(0, 0)
            Me.lbl_Prompt.Name = "lbl_Prompt"
            Me.lbl_Prompt.Size = New System.Drawing.Size(39, 13)
            Me.lbl_Prompt.TabIndex = 0
            Me.lbl_Prompt.Text = "Label1"
            'txt_Entry
            Me.txt_Entry.BackColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.txt_Entry.BorderStyle = System.Windows.Forms.BorderStyle.None
            Me.txt_Entry.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.txt_Entry.Location = New System.Drawing.Point(0, 102)
            Me.txt_Entry.Name = "txt_Entry"
            Me.txt_Entry.Size = New System.Drawing.Size(50, 19)
            Me.txt_Entry.TabIndex = 0
            Me.txt_Entry.WordWrap = False
            'qInput
            Me.BackColor = System.Drawing.Color.Silver
            Me.Controls.Add(Me.lbl_Prompt)
            Me.Controls.Add(Me.txt_Entry)
            Me.Size = New System.Drawing.Size(152, 20)
            Me.ResumeLayout(False)
            Me.PerformLayout()
        End Sub
    
        Private Sub pnl_Input_Paint(ByVal sender As System.Object, _
                                    ByVal e As System.Windows.Forms.PaintEventArgs) _
                                    Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(_InnerBorderColour, 1)
                gp.AddRectangle(New Rectangle(1, 1, _Width - 3, _Height - 3))
                e.Graphics.DrawPath(bSb, gp)
            End Using
            Using gp As New GraphicsPath, bSb As New Pen(_BorderColour, 1)
                gp.AddRectangle(New Rectangle(0, 0, _Width - 1, _Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using
        End Sub
    
        Private Sub qInput_Resize(ByVal sender As Object, _
                                  ByVal e As System.EventArgs) _
                                  Handles Me.SizeChanged
            _Width = Me.Width
            Call SetPanelPositions()
        End Sub
    
        Private Sub SetPanelPositions()
            If (lbl_Prompt IsNot Nothing) And (txt_Entry IsNot Nothing) Then
                _PromptLeft = _InputWidth + _InputOffset + 4
                With txt_Entry
                    _InputHeight = .Height
                    .Left = _InputOffset + 2
                    .Top = 4 + _InputTop
                    .Width = _InputWidth
                End With
                With lbl_Prompt
                    _PromptHeight = .Height
                    .Left = _PromptLeft
                    .Top = 3 + _PromptTop
                    .Width = _Width - (_PromptLeft + 4)
                End With
                _Height = _PromptHeight + _PromptTop + 7
                Me.Height = _Height
            End If
        End Sub
    
    End Class
    
    
    '   New Class   qForm
    
    
    Option Strict On
    Option Explicit Off
    
    Imports System.ComponentModel
    Imports System.Drawing.Drawing2D
    
    Public Class qForm
    
    Inherits UserControl
    
        Friend WithEvents pic_Icon As System.Windows.Forms.PictureBox
        Friend WithEvents pnl_Close As System.Windows.Forms.Panel
        Friend WithEvents pnl_Header As System.Windows.Forms.Panel
    
        Private fMove As Integer
        Private Porg As Point
    
        Public Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub
    
        Private Sub InitializeComponent()
            Me.pic_Icon = New System.Windows.Forms.PictureBox()
            Me.pnl_Close = New System.Windows.Forms.Panel()
            Me.pnl_Header = New System.Windows.Forms.Panel()
            CType(Me.pic_Icon, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            'pic_Icon
            Me.pic_Icon.BackColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.pic_Icon.ErrorImage = Nothing
            Me.pic_Icon.InitialImage = Nothing
            Me.pic_Icon.Location = New System.Drawing.Point(1, 1)
            Me.pic_Icon.Name = "pic_Icon"
            Me.pic_Icon.Size = New System.Drawing.Size(31, 25)
            Me.pic_Icon.TabIndex = 2
            Me.pic_Icon.TabStop = False
            'pnl_Close
            Me.pnl_Close.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Close.BackColor = System.Drawing.Color.Red
            Me.pnl_Close.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center
            Me.pnl_Close.Location = New System.Drawing.Point(300, 1)
            Me.pnl_Close.Name = "pnl_Close"
            Me.pnl_Close.Size = New System.Drawing.Size(31, 25)
            Me.pnl_Close.TabIndex = 1
            'pnl_Header
            Me.pnl_Header.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Header.BackColor = System.Drawing.Color.Yellow
            Me.pnl_Header.Location = New System.Drawing.Point(32, 1)
            Me.pnl_Header.Name = "pnl_Header"
            Me.pnl_Header.Size = New System.Drawing.Size(268, 25)
            Me.pnl_Header.TabIndex = 3
            'qForm
            Me.AllowDrop = True
            Me.BackColor = System.Drawing.Color.LightGray
            Me.Controls.Add(Me.pic_Icon)
            Me.Controls.Add(Me.pnl_Close)
            Me.Controls.Add(Me.pnl_Header)
            Me.Name = "qForm"
            Me.Size = New System.Drawing.Size(332, 227)
            CType(Me.pic_Icon, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
        End Sub
    
        Private Sub qForm_Paint(ByVal sender As Object, _
                                ByVal e As System.Windows.Forms.PaintEventArgs) _
                                Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(Brushes.Black, 1)
                gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using    'the new GraphicsPath and Pen will be disposed when this line is executed.
        End Sub
    
        Private Sub pnl_Close_Click(ByVal sender As System.Object, _
                                    ByVal e As System.EventArgs) _
                                    Handles pnl_Close.MouseClick
            Me.Dispose()
        End Sub
    
        Private Sub pnl_Header_MouseDown(ByVal sender As Object, _
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseDown
            Me.Focus()
            fMove = 1
            Porg = e.Location
        End Sub
    
        Private Sub pnl_Header_MouseUp(ByVal sender As Object, _
                                       ByVal e As System.Windows.Forms.MouseEventArgs) _
                                       Handles pnl_Header.MouseUp
            fMove = 0
        End Sub
    
        Private Sub pnl_Header_MouseMove(ByVal sender As Object, _
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseMove
            Dim X As Integer = Me.Location.X + (e.Location.X - Porg.X)
            Dim Y As Integer = Me.Location.Y + (e.Location.Y - Porg.Y)
    
            If fMove = 1 Then
                Me.Location = New Point(X, Y)
            End If
        End Sub
    
    End Class
    

    When you run the code, by dragging the qPanels (by the yellow panel) over or under eachother, the trails appear - particularly noticeable when moving diagonally.

    The way it is used is for qForms to be dropped into Form1 which is set to being an MDI container.  qPanels and qInputs are then placed in the qForms for the final functionality.  If the qForm is replaced with a Form set to FixedToolWindow there is no trailing - but also no icon at the top left.  The qForm allows an icon (or picture) to be placed in the cyan box, uses the red box as "form close" function and the yellow panel for moving the "form".  The reason for making a .dll is that the qForm, qPanel and qInput controls can be used by various modules.

    I hope this explains the functionality.

    All the best,
                        HotIndigo.


    • Edited by HotIndigo Wednesday, May 2, 2018 8:59 PM
    Wednesday, May 2, 2018 8:55 PM
  • I altered your code so I could paste it all into a New Form as the Designer was having issues a sub that had two of the same signature. I could copy the below code into a Borderless Forms code window and it works. I do see the issue.

    Also not in the very last sub (pnl_Header_MouseMove) in the very last class I added Me.Refresh and the problem really got worse. It has something to do with painting I suppose but I have no idea what and painting during mouse move.

    See the below image. I kind of like it though!

    I also prior had set the Form to Double buffered as well as the last class to Double Buffered but it did not help so I removed that.

    Option Strict On
    
    Imports System.ComponentModel
    
    Imports System.Drawing.Drawing2D
    
    Public Class Form1
    
        Inherits System.Windows.Forms.Form
    
        Friend WithEvents QForm1 As qForm
        Friend WithEvents QForm2 As qForm
        Friend WithEvents QInput1 As qInput
        Friend WithEvents QInput2 As qInput
        Friend WithEvents QInput3 As qInput
        Friend WithEvents QInput4 As qInput
        Friend WithEvents QInput5 As qInput
        Friend WithEvents QInput6 As qInput
        Friend WithEvents QInput7 As qInput
        Friend WithEvents QInput8 As qInput
        Friend WithEvents QPanel1 As qPanel
        Friend WithEvents QPanel2 As qPanel
        Friend WithEvents QPanel3 As qPanel
        Friend WithEvents QPanel4 As qPanel
        Friend WithEvents QPanel5 As qPanel
        Friend WithEvents QPanel6 As qPanel
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim I As Integer
            Dim Ypos As Integer
            Dim Offset As Integer = 0
    
            Dim FormList(1) As qForm
            Dim PanelList(5) As qPanel
            Dim InputList(7) As qInput
    
            Me.QForm1 = New qForm()
            Me.QForm2 = New qForm()
            Me.QPanel1 = New qPanel()
            Me.QPanel2 = New qPanel()
            Me.QPanel3 = New qPanel()
            Me.QPanel4 = New qPanel()
            Me.QPanel5 = New qPanel()
            Me.QPanel6 = New qPanel()
            Me.QInput1 = New qInput()
            Me.QInput2 = New qInput()
            Me.QInput3 = New qInput()
            Me.QInput4 = New qInput()
            Me.QInput5 = New qInput()
            Me.QInput6 = New qInput()
            Me.QInput7 = New qInput()
            Me.QInput8 = New qInput()
            Me.SuspendLayout()
    
            FormList(0) = Me.QForm1
            FormList(1) = Me.QForm2
            PanelList(0) = Me.QPanel1
            PanelList(1) = Me.QPanel2
            PanelList(2) = Me.QPanel3
            PanelList(3) = Me.QPanel4
            PanelList(4) = Me.QPanel5
            PanelList(5) = Me.QPanel6
            InputList(0) = Me.QInput1
            InputList(1) = Me.QInput2
            InputList(2) = Me.QInput3
            InputList(3) = Me.QInput4
            InputList(4) = Me.QInput5
            InputList(5) = Me.QInput6
            InputList(6) = Me.QInput7
            InputList(7) = Me.QInput8
            'QForm1
            Me.QForm1.BackColor = System.Drawing.Color.LightGray
            Me.QForm1.Controls.Add(Me.QPanel1)
            Me.QForm1.Controls.Add(Me.QPanel2)
            Me.QForm1.Controls.Add(Me.QPanel3)
            Me.QForm1.Controls.Add(Me.QInput1)
            Me.QForm1.Controls.Add(Me.QInput2)
            Me.QForm1.Controls.Add(Me.QInput3)
            Me.QForm1.Controls.Add(Me.QInput4)
            Me.QForm1.Location = New System.Drawing.Point(28, 24)
            Me.QForm1.Name = "QForm1"
            Me.QForm1.Size = New System.Drawing.Size(365, 444)
            Me.QForm1.TabIndex = 1
            'QForm2
            Me.QForm2.BackColor = System.Drawing.Color.LightGray
            Me.QForm2.Controls.Add(Me.QPanel4)
            Me.QForm2.Controls.Add(Me.QPanel5)
            Me.QForm2.Controls.Add(Me.QPanel6)
            Me.QForm2.Controls.Add(Me.QInput5)
            Me.QForm2.Controls.Add(Me.QInput6)
            Me.QForm2.Controls.Add(Me.QInput7)
            Me.QForm2.Controls.Add(Me.QInput8)
            Me.QForm2.Location = New System.Drawing.Point(428, 24)
            Me.QForm2.Name = "QForm2"
            Me.QForm2.Size = New System.Drawing.Size(365, 444)
            Me.QForm2.TabIndex = 3
            'QPanels
            Offset = 50
            Ypos = 66
            For I = 0 To 5
                PanelList(I).BackColor = System.Drawing.Color.Silver
                PanelList(I).BorderColour = System.Drawing.Color.Black
                PanelList(I).ContainerColour = System.Drawing.Color.Silver
                PanelList(I).Location = New System.Drawing.Point(51, Ypos)
                PanelList(I).Name = "QPanel1"
                PanelList(I).Size = New System.Drawing.Size(250, 36)
                PanelList(I).TabIndex = 10
                If I = 2 Then
                    Ypos = 66
                Else
                    Ypos += Offset
                End If
            Next
            'QInputs
            Offset = 45
            Ypos = 243
            For I = 0 To 7
                InputList(I).BackColor = System.Drawing.Color.White
                InputList(I).BorderColour = System.Drawing.Color.Black
                InputList(I).ContainerColour = System.Drawing.Color.White
                InputList(I).InputColour = System.Drawing.Color.Black
                InputList(I).InputOffset = 2
                InputList(I).InputText = ""
                InputList(I).InputTop = 0
                InputList(I).InputWidth = 50
                InputList(I).Location = New System.Drawing.Point(51, Ypos)
                InputList(I).Name = "QInput1"
                InputList(I).Size = New System.Drawing.Size(273, 21)
                InputList(I).TabIndex = 6
                InputList(I).Tag = 0
                InputList(I).Text = " 0"
                InputList(I).PromptColour = System.Drawing.Color.Black
                InputList(I).PromptTop = 1
                If I = 3 Then
                    Ypos = 243
                Else
                    Ypos += Offset
                End If
            Next
            'Form1
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(1210, 633)
            Me.Controls.Add(Me.QForm2)
            Me.Controls.Add(Me.QForm1)
            Me.IsMdiContainer = True
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
            Me.ResumeLayout(False)
        End Sub
    
    End Class
    
    
    '   New Class   qPanel
    
    
    Public Class qPanel
    
        Inherits Panel
    
        Private _ContainerColour As Color = ColorTranslator.FromOle(&HC0C0C0)
        Private _BorderColour As Color = Color.Black
    
        Public Property BorderColour() As Color
            Get
                Return _BorderColour
            End Get
            Set(ByVal value As Color)
                _BorderColour = value
                Me.Invalidate()
            End Set
        End Property
    
        Public Property ContainerColour() As Color
            Get
                Return _ContainerColour
            End Get
            Set(ByVal value As Color)
                _ContainerColour = value
                Me.BackColor = _ContainerColour
                Me.Invalidate()
            End Set
        End Property
    
        Friend Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub
    
        Private Sub InitializeComponent()
            Me.SuspendLayout()
            'qPanel
            Me.TabStop = False
            Me.BackColor = _ContainerColour
            Me.BorderColour = Color.Black
            Me.ResizeRedraw = True            ' Set the usercontrol to redraw itself when resized.
            Me.ResumeLayout(False)
        End Sub
    
        Private Sub qPanel_Paint(ByVal sender As Object, _
                                 ByVal e As System.Windows.Forms.PaintEventArgs) _
                                 Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(_BorderColour, 1)
                gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using
        End Sub
    
    End Class
    
    
    '   New Class   qInput
    
    
    Public Class qInput
    
        Inherits Panel
    
        Friend WithEvents txt_Entry As System.Windows.Forms.TextBox
        Friend WithEvents lbl_Prompt As System.Windows.Forms.Label
    
        Private _BorderColour As Color = Color.Black    ' Input Panel Border Colour (1 pixel thick).
        Private _InnerBorderColour As Color = Color.Red ' Text Box    Border Colour (1 pixel thick).
        Private _ContainerColour As Color = Color.White ' Input Panel Background Colour.
        Private _InputText As String = "0g"
        Private _InputOffset As Integer = 2             ' Text Entry Offset from Panel LHS.
        Private _InputWidth As Integer = 50             ' Text Input Box Width.
        Private _InputTop As Integer = 0                ' Text Input Box Top relative to Panel.
        Private _InputColour As Color = Color.Black     ' Input Text Colour.
        Private _PromptText As String = "Prompt"        ' Prompt Panel Text.
        Private _PromptTop As Integer = 1               ' Prompt Panel Top.
        Private _PromptFont As Font                     ' PrPromptompt Panel Text Font.
        Private _PromptColour As Color = Color.Black    ' Prompt Panel Text Colour.
        Private _Width As Integer = 200                 ' Input Panel Width.
        Private _Height As Integer = 20                 ' Input Panel Height.
    
        Private _InputHeight As Integer     ' Text Input Box Height.
        Private _PromptHeight As Integer    ' Prompt Panel Height.
        Private _PromptLeft As Integer      ' Text Input Box LHS.
    
    #Region "Public Properties"
    
        <Description("Panel Border Colour.")> _
        Public Property BorderColour() As Color
            Get
                Return _BorderColour
            End Get
            Set(ByVal value As Color)
                _BorderColour = value
                Me.Invalidate()
            End Set
        End Property
    
        <Description("Container Colour.")> _
        Public Property ContainerColour() As Color
            Get
                Return _ContainerColour
            End Get
            Set(ByVal value As Color)
                _ContainerColour = value
                Me.BackColor = value
                lbl_Prompt.BackColor = value
                txt_Entry.BackColor = value
                Me.Invalidate()
            End Set
        End Property
    
        <Description("Text Entry panel offset from Left.")> _
        Public Property InputOffset() As Integer
            Get
                Return _InputOffset
            End Get
            Set(ByVal value As Integer)
                _InputOffset = value
                Call SetPanelPositions()
            End Set
        End Property
    
        <Description("Text Entry panel top.")> _
        Public Property InputTop() As Integer
            Get
                Return _InputTop
            End Get
            Set(ByVal value As Integer)
                _InputTop = value
                Call SetPanelPositions()
            End Set
        End Property
    
        <Description("Text Entry panel width.")> _
        Public Property InputWidth() As Integer
            Get
                Return _InputWidth
            End Get
            Set(ByVal value As Integer)
                _InputWidth = value
                Call SetPanelPositions()
            End Set
        End Property
    
        <Description("Input text.")> _
        Public Property InputText() As String
            Get
                Return _InputText
            End Get
            Set(ByVal value As String)
                _InputText = value
            End Set
        End Property
    
        <Description("Input text colour.")> _
        Public Property InputColour() As Color
            Get
                Return _InputColour
            End Get
            Set(ByVal value As Color)
                _InputColour = value
                txt_Entry.ForeColor = value
            End Set
        End Property
    
        <Description("Prompt Panel top.")> _
        Public Property PromptTop() As Integer
            Get
                Return _PromptTop
            End Get
            Set(ByVal value As Integer)
                _PromptTop = value
                Call SetPanelPositions()
            End Set
        End Property
    
        <Description("Prompt text colour.")> _
        Public Property PromptColour() As Color
            Get
                Return _PromptColour
            End Get
            Set(ByVal value As Color)
                _PromptColour = value
                lbl_Prompt.ForeColor = value
            End Set
        End Property
    
    #End Region
    
        Public Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub
    
        Private Sub InitializeComponent()
            Me.lbl_Prompt = New System.Windows.Forms.Label()
            Me.txt_Entry = New System.Windows.Forms.TextBox()
            Me.SuspendLayout()
            'lbl_Prompt
            Me.lbl_Prompt.AutoSize = True
            Me.lbl_Prompt.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(192, Byte), Integer))
            Me.lbl_Prompt.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.lbl_Prompt.Location = New System.Drawing.Point(0, 0)
            Me.lbl_Prompt.Name = "lbl_Prompt"
            Me.lbl_Prompt.Size = New System.Drawing.Size(39, 13)
            Me.lbl_Prompt.TabIndex = 0
            Me.lbl_Prompt.Text = "Label1"
            'txt_Entry
            Me.txt_Entry.BackColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.txt_Entry.BorderStyle = System.Windows.Forms.BorderStyle.None
            Me.txt_Entry.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.txt_Entry.Location = New System.Drawing.Point(0, 102)
            Me.txt_Entry.Name = "txt_Entry"
            Me.txt_Entry.Size = New System.Drawing.Size(50, 19)
            Me.txt_Entry.TabIndex = 0
            Me.txt_Entry.WordWrap = False
            'qInput
            Me.BackColor = System.Drawing.Color.Silver
            Me.Controls.Add(Me.lbl_Prompt)
            Me.Controls.Add(Me.txt_Entry)
            Me.Size = New System.Drawing.Size(152, 20)
            Me.ResumeLayout(False)
            Me.PerformLayout()
        End Sub
    
        Private Sub pnl_Input_Paint(ByVal sender As System.Object, _
                                    ByVal e As System.Windows.Forms.PaintEventArgs) _
                                    Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(_InnerBorderColour, 1)
                gp.AddRectangle(New Rectangle(1, 1, _Width - 3, _Height - 3))
                e.Graphics.DrawPath(bSb, gp)
            End Using
            Using gp As New GraphicsPath, bSb As New Pen(_BorderColour, 1)
                gp.AddRectangle(New Rectangle(0, 0, _Width - 1, _Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using
        End Sub
    
        Private Sub qInput_Resize(ByVal sender As Object, _
                                  ByVal e As System.EventArgs) _
                                  Handles Me.SizeChanged
            _Width = Me.Width
            Call SetPanelPositions()
        End Sub
    
        Private Sub SetPanelPositions()
            If (lbl_Prompt IsNot Nothing) And (txt_Entry IsNot Nothing) Then
                _PromptLeft = _InputWidth + _InputOffset + 4
                With txt_Entry
                    _InputHeight = .Height
                    .Left = _InputOffset + 2
                    .Top = 4 + _InputTop
                    .Width = _InputWidth
                End With
                With lbl_Prompt
                    _PromptHeight = .Height
                    .Left = _PromptLeft
                    .Top = 3 + _PromptTop
                    .Width = _Width - (_PromptLeft + 4)
                End With
                _Height = _PromptHeight + _PromptTop + 7
                Me.Height = _Height
            End If
        End Sub
    
    End Class
    
    
    '   New Class   qForm
    
    
    Public Class qForm
    
        Inherits UserControl
    
        Friend WithEvents pic_Icon As System.Windows.Forms.PictureBox
        Friend WithEvents pnl_Close As System.Windows.Forms.Panel
        Friend WithEvents pnl_Header As System.Windows.Forms.Panel
    
        Private fMove As Integer
        Private Porg As Point
    
        Public Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub
    
        Private Sub InitializeComponent()
            Me.pic_Icon = New System.Windows.Forms.PictureBox()
            Me.pnl_Close = New System.Windows.Forms.Panel()
            Me.pnl_Header = New System.Windows.Forms.Panel()
            CType(Me.pic_Icon, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            'pic_Icon
            Me.pic_Icon.BackColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.pic_Icon.ErrorImage = Nothing
            Me.pic_Icon.InitialImage = Nothing
            Me.pic_Icon.Location = New System.Drawing.Point(1, 1)
            Me.pic_Icon.Name = "pic_Icon"
            Me.pic_Icon.Size = New System.Drawing.Size(31, 25)
            Me.pic_Icon.TabIndex = 2
            Me.pic_Icon.TabStop = False
            'pnl_Close
            Me.pnl_Close.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Close.BackColor = System.Drawing.Color.Red
            Me.pnl_Close.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center
            Me.pnl_Close.Location = New System.Drawing.Point(300, 1)
            Me.pnl_Close.Name = "pnl_Close"
            Me.pnl_Close.Size = New System.Drawing.Size(31, 25)
            Me.pnl_Close.TabIndex = 1
            'pnl_Header
            Me.pnl_Header.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Header.BackColor = System.Drawing.Color.Yellow
            Me.pnl_Header.Location = New System.Drawing.Point(32, 1)
            Me.pnl_Header.Name = "pnl_Header"
            Me.pnl_Header.Size = New System.Drawing.Size(268, 25)
            Me.pnl_Header.TabIndex = 3
            'qForm
            Me.AllowDrop = True
            Me.BackColor = System.Drawing.Color.LightGray
            Me.Controls.Add(Me.pic_Icon)
            Me.Controls.Add(Me.pnl_Close)
            Me.Controls.Add(Me.pnl_Header)
            Me.Name = "qForm"
            Me.Size = New System.Drawing.Size(332, 227)
            CType(Me.pic_Icon, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
        End Sub
    
        Private Sub qForm_Paint(ByVal sender As Object, _
                                ByVal e As System.Windows.Forms.PaintEventArgs) _
                                Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(Brushes.Black, 1)
                gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using    'the new GraphicsPath and Pen will be disposed when this line is executed.
        End Sub
    
        Private Sub pnl_Close_Click(ByVal sender As System.Object, _
                                    ByVal e As System.EventArgs) _
                                    Handles pnl_Close.MouseClick
            Me.Dispose()
        End Sub
    
        Private Sub pnl_Header_MouseDown(ByVal sender As Object, _
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseDown
            Me.Focus()
            fMove = 1
            Porg = e.Location
        End Sub
    
        Private Sub pnl_Header_MouseUp(ByVal sender As Object, _
                                       ByVal e As System.Windows.Forms.MouseEventArgs) _
                                       Handles pnl_Header.MouseUp
            fMove = 0
        End Sub
    
        Private Sub pnl_Header_MouseMove(ByVal sender As Object, _
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseMove
            Dim X As Integer = Me.Location.X + (e.Location.X - Porg.X)
            Dim Y As Integer = Me.Location.Y + (e.Location.Y - Porg.Y)
    
            If fMove = 1 Then
                Me.Location = New Point(X, Y)
                Me.Refresh()
            End If
        End Sub
    
    End Class
    
    


    La vida loca

    Wednesday, May 2, 2018 9:25 PM
  • I altered the code which cancelled the ghosting.

    In qForm class I added a public shared boolean at the top. And its value is altered in the moused down and up events.

    The paint events in qForm, qInput and qPanel only paint if that boolean is at False.

    Option Strict On
    
    Imports System.ComponentModel
    
    Imports System.Drawing.Drawing2D
    
    Public Class Form1
    
        Inherits System.Windows.Forms.Form
    
        Friend WithEvents QForm1 As qForm
        Friend WithEvents QForm2 As qForm
        Friend WithEvents QInput1 As qInput
        Friend WithEvents QInput2 As qInput
        Friend WithEvents QInput3 As qInput
        Friend WithEvents QInput4 As qInput
        Friend WithEvents QInput5 As qInput
        Friend WithEvents QInput6 As qInput
        Friend WithEvents QInput7 As qInput
        Friend WithEvents QInput8 As qInput
        Friend WithEvents QPanel1 As qPanel
        Friend WithEvents QPanel2 As qPanel
        Friend WithEvents QPanel3 As qPanel
        Friend WithEvents QPanel4 As qPanel
        Friend WithEvents QPanel5 As qPanel
        Friend WithEvents QPanel6 As qPanel
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim I As Integer
            Dim Ypos As Integer
            Dim Offset As Integer = 0
    
            Dim FormList(1) As qForm
            Dim PanelList(5) As qPanel
            Dim InputList(7) As qInput
    
            Me.QForm1 = New qForm()
            Me.QForm2 = New qForm()
            Me.QPanel1 = New qPanel()
            Me.QPanel2 = New qPanel()
            Me.QPanel3 = New qPanel()
            Me.QPanel4 = New qPanel()
            Me.QPanel5 = New qPanel()
            Me.QPanel6 = New qPanel()
            Me.QInput1 = New qInput()
            Me.QInput2 = New qInput()
            Me.QInput3 = New qInput()
            Me.QInput4 = New qInput()
            Me.QInput5 = New qInput()
            Me.QInput6 = New qInput()
            Me.QInput7 = New qInput()
            Me.QInput8 = New qInput()
            Me.SuspendLayout()
    
            FormList(0) = Me.QForm1
            FormList(1) = Me.QForm2
            PanelList(0) = Me.QPanel1
            PanelList(1) = Me.QPanel2
            PanelList(2) = Me.QPanel3
            PanelList(3) = Me.QPanel4
            PanelList(4) = Me.QPanel5
            PanelList(5) = Me.QPanel6
            InputList(0) = Me.QInput1
            InputList(1) = Me.QInput2
            InputList(2) = Me.QInput3
            InputList(3) = Me.QInput4
            InputList(4) = Me.QInput5
            InputList(5) = Me.QInput6
            InputList(6) = Me.QInput7
            InputList(7) = Me.QInput8
            'QForm1
            Me.QForm1.BackColor = System.Drawing.Color.LightGray
            Me.QForm1.Controls.Add(Me.QPanel1)
            Me.QForm1.Controls.Add(Me.QPanel2)
            Me.QForm1.Controls.Add(Me.QPanel3)
            Me.QForm1.Controls.Add(Me.QInput1)
            Me.QForm1.Controls.Add(Me.QInput2)
            Me.QForm1.Controls.Add(Me.QInput3)
            Me.QForm1.Controls.Add(Me.QInput4)
            Me.QForm1.Location = New System.Drawing.Point(28, 24)
            Me.QForm1.Name = "QForm1"
            Me.QForm1.Size = New System.Drawing.Size(365, 444)
            Me.QForm1.TabIndex = 1
            'QForm2
            Me.QForm2.BackColor = System.Drawing.Color.LightGray
            Me.QForm2.Controls.Add(Me.QPanel4)
            Me.QForm2.Controls.Add(Me.QPanel5)
            Me.QForm2.Controls.Add(Me.QPanel6)
            Me.QForm2.Controls.Add(Me.QInput5)
            Me.QForm2.Controls.Add(Me.QInput6)
            Me.QForm2.Controls.Add(Me.QInput7)
            Me.QForm2.Controls.Add(Me.QInput8)
            Me.QForm2.Location = New System.Drawing.Point(428, 24)
            Me.QForm2.Name = "QForm2"
            Me.QForm2.Size = New System.Drawing.Size(365, 444)
            Me.QForm2.TabIndex = 3
            'QPanels
            Offset = 50
            Ypos = 66
            For I = 0 To 5
                PanelList(I).BackColor = System.Drawing.Color.Silver
                PanelList(I).BorderColour = System.Drawing.Color.Black
                PanelList(I).ContainerColour = System.Drawing.Color.Silver
                PanelList(I).Location = New System.Drawing.Point(51, Ypos)
                PanelList(I).Name = "QPanel1"
                PanelList(I).Size = New System.Drawing.Size(250, 36)
                PanelList(I).TabIndex = 10
                If I = 2 Then
                    Ypos = 66
                Else
                    Ypos += Offset
                End If
            Next
            'QInputs
            Offset = 45
            Ypos = 243
            For I = 0 To 7
                InputList(I).BackColor = System.Drawing.Color.White
                InputList(I).BorderColour = System.Drawing.Color.Black
                InputList(I).ContainerColour = System.Drawing.Color.White
                InputList(I).InputColour = System.Drawing.Color.Black
                InputList(I).InputOffset = 2
                InputList(I).InputText = ""
                InputList(I).InputTop = 0
                InputList(I).InputWidth = 50
                InputList(I).Location = New System.Drawing.Point(51, Ypos)
                InputList(I).Name = "QInput1"
                InputList(I).Size = New System.Drawing.Size(273, 21)
                InputList(I).TabIndex = 6
                InputList(I).Tag = 0
                InputList(I).Text = " 0"
                InputList(I).PromptColour = System.Drawing.Color.Black
                InputList(I).PromptTop = 1
                If I = 3 Then
                    Ypos = 243
                Else
                    Ypos += Offset
                End If
            Next
            'Form1
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(1210, 633)
            Me.Controls.Add(Me.QForm2)
            Me.Controls.Add(Me.QForm1)
            Me.IsMdiContainer = True
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
            Me.ResumeLayout(False)
        End Sub
    
    End Class
    
    
    '   New Class   qPanel
    
    
    Public Class qPanel
    
        Inherits Panel
    
        Private _ContainerColour As Color = ColorTranslator.FromOle(&HC0C0C0)
        Private _BorderColour As Color = Color.Black
    
        Public Property BorderColour() As Color
            Get
                Return _BorderColour
            End Get
            Set(ByVal value As Color)
                _BorderColour = value
                Me.Invalidate()
            End Set
        End Property
    
        Public Property ContainerColour() As Color
            Get
                Return _ContainerColour
            End Get
            Set(ByVal value As Color)
                _ContainerColour = value
                Me.BackColor = _ContainerColour
                Me.Invalidate()
            End Set
        End Property
    
        Friend Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub
    
        Private Sub InitializeComponent()
            Me.SuspendLayout()
            'qPanel
            Me.TabStop = False
            Me.BackColor = _ContainerColour
            Me.BorderColour = Color.Black
            Me.ResizeRedraw = True            ' Set the usercontrol to redraw itself when resized.
            Me.ResumeLayout(False)
        End Sub
    
        Private Sub qPanel_Paint(ByVal sender As Object, _
                                 ByVal e As System.Windows.Forms.PaintEventArgs) _
                                 Handles Me.Paint
            If qForm.Moving = False Then
                Using gp As New GraphicsPath, bSb As New Pen(_BorderColour, 1)
                    gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
                    e.Graphics.DrawPath(bSb, gp)
                End Using
            End If
        End Sub
    
    End Class
    
    
    '   New Class   qInput
    
    
    Public Class qInput
    
        Inherits Panel
    
        Friend WithEvents txt_Entry As System.Windows.Forms.TextBox
        Friend WithEvents lbl_Prompt As System.Windows.Forms.Label
    
        Private _BorderColour As Color = Color.Black    ' Input Panel Border Colour (1 pixel thick).
        Private _InnerBorderColour As Color = Color.Red ' Text Box    Border Colour (1 pixel thick).
        Private _ContainerColour As Color = Color.White ' Input Panel Background Colour.
        Private _InputText As String = "0g"
        Private _InputOffset As Integer = 2             ' Text Entry Offset from Panel LHS.
        Private _InputWidth As Integer = 50             ' Text Input Box Width.
        Private _InputTop As Integer = 0                ' Text Input Box Top relative to Panel.
        Private _InputColour As Color = Color.Black     ' Input Text Colour.
        Private _PromptText As String = "Prompt"        ' Prompt Panel Text.
        Private _PromptTop As Integer = 1               ' Prompt Panel Top.
        Private _PromptFont As Font                     ' PrPromptompt Panel Text Font.
        Private _PromptColour As Color = Color.Black    ' Prompt Panel Text Colour.
        Private _Width As Integer = 200                 ' Input Panel Width.
        Private _Height As Integer = 20                 ' Input Panel Height.
    
        Private _InputHeight As Integer     ' Text Input Box Height.
        Private _PromptHeight As Integer    ' Prompt Panel Height.
        Private _PromptLeft As Integer      ' Text Input Box LHS.
    
    #Region "Public Properties"
    
        <Description("Panel Border Colour.")> _
        Public Property BorderColour() As Color
            Get
                Return _BorderColour
            End Get
            Set(ByVal value As Color)
                _BorderColour = value
                Me.Invalidate()
            End Set
        End Property
    
        <Description("Container Colour.")> _
        Public Property ContainerColour() As Color
            Get
                Return _ContainerColour
            End Get
            Set(ByVal value As Color)
                _ContainerColour = value
                Me.BackColor = value
                lbl_Prompt.BackColor = value
                txt_Entry.BackColor = value
                Me.Invalidate()
            End Set
        End Property
    
        <Description("Text Entry panel offset from Left.")> _
        Public Property InputOffset() As Integer
            Get
                Return _InputOffset
            End Get
            Set(ByVal value As Integer)
                _InputOffset = value
                Call SetPanelPositions()
            End Set
        End Property
    
        <Description("Text Entry panel top.")> _
        Public Property InputTop() As Integer
            Get
                Return _InputTop
            End Get
            Set(ByVal value As Integer)
                _InputTop = value
                Call SetPanelPositions()
            End Set
        End Property
    
        <Description("Text Entry panel width.")> _
        Public Property InputWidth() As Integer
            Get
                Return _InputWidth
            End Get
            Set(ByVal value As Integer)
                _InputWidth = value
                Call SetPanelPositions()
            End Set
        End Property
    
        <Description("Input text.")> _
        Public Property InputText() As String
            Get
                Return _InputText
            End Get
            Set(ByVal value As String)
                _InputText = value
            End Set
        End Property
    
        <Description("Input text colour.")> _
        Public Property InputColour() As Color
            Get
                Return _InputColour
            End Get
            Set(ByVal value As Color)
                _InputColour = value
                txt_Entry.ForeColor = value
            End Set
        End Property
    
        <Description("Prompt Panel top.")> _
        Public Property PromptTop() As Integer
            Get
                Return _PromptTop
            End Get
            Set(ByVal value As Integer)
                _PromptTop = value
                Call SetPanelPositions()
            End Set
        End Property
    
        <Description("Prompt text colour.")> _
        Public Property PromptColour() As Color
            Get
                Return _PromptColour
            End Get
            Set(ByVal value As Color)
                _PromptColour = value
                lbl_Prompt.ForeColor = value
            End Set
        End Property
    
    #End Region
    
        Public Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub
    
        Private Sub InitializeComponent()
            Me.lbl_Prompt = New System.Windows.Forms.Label()
            Me.txt_Entry = New System.Windows.Forms.TextBox()
            Me.SuspendLayout()
            'lbl_Prompt
            Me.lbl_Prompt.AutoSize = True
            Me.lbl_Prompt.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(192, Byte), Integer))
            Me.lbl_Prompt.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.lbl_Prompt.Location = New System.Drawing.Point(0, 0)
            Me.lbl_Prompt.Name = "lbl_Prompt"
            Me.lbl_Prompt.Size = New System.Drawing.Size(39, 13)
            Me.lbl_Prompt.TabIndex = 0
            Me.lbl_Prompt.Text = "Label1"
            'txt_Entry
            Me.txt_Entry.BackColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.txt_Entry.BorderStyle = System.Windows.Forms.BorderStyle.None
            Me.txt_Entry.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.txt_Entry.Location = New System.Drawing.Point(0, 102)
            Me.txt_Entry.Name = "txt_Entry"
            Me.txt_Entry.Size = New System.Drawing.Size(50, 19)
            Me.txt_Entry.TabIndex = 0
            Me.txt_Entry.WordWrap = False
            'qInput
            Me.BackColor = System.Drawing.Color.Silver
            Me.Controls.Add(Me.lbl_Prompt)
            Me.Controls.Add(Me.txt_Entry)
            Me.Size = New System.Drawing.Size(152, 20)
            Me.ResumeLayout(False)
            Me.PerformLayout()
        End Sub
    
        Private Sub pnl_Input_Paint(ByVal sender As System.Object, _
                                    ByVal e As System.Windows.Forms.PaintEventArgs) _
                                    Handles Me.Paint
            If qForm.Moving = False Then
                Using gp As New GraphicsPath, bSb As New Pen(_InnerBorderColour, 1)
                    gp.AddRectangle(New Rectangle(1, 1, _Width - 3, _Height - 3))
                    e.Graphics.DrawPath(bSb, gp)
                End Using
                Using gp As New GraphicsPath, bSb As New Pen(_BorderColour, 1)
                    gp.AddRectangle(New Rectangle(0, 0, _Width - 1, _Height - 1))
                    e.Graphics.DrawPath(bSb, gp)
                End Using
            End If
        End Sub
    
        Private Sub qInput_Resize(ByVal sender As Object, _
                                  ByVal e As System.EventArgs) _
                                  Handles Me.SizeChanged
            _Width = Me.Width
            Call SetPanelPositions()
        End Sub
    
        Private Sub SetPanelPositions()
            If (lbl_Prompt IsNot Nothing) And (txt_Entry IsNot Nothing) Then
                _PromptLeft = _InputWidth + _InputOffset + 4
                With txt_Entry
                    _InputHeight = .Height
                    .Left = _InputOffset + 2
                    .Top = 4 + _InputTop
                    .Width = _InputWidth
                End With
                With lbl_Prompt
                    _PromptHeight = .Height
                    .Left = _PromptLeft
                    .Top = 3 + _PromptTop
                    .Width = _Width - (_PromptLeft + 4)
                End With
                _Height = _PromptHeight + _PromptTop + 7
                Me.Height = _Height
            End If
        End Sub
    
    End Class
    
    
    '   New Class   qForm
    
    
    Public Class qForm
    
        Inherits UserControl
    
        Friend WithEvents pic_Icon As System.Windows.Forms.PictureBox
        Friend WithEvents pnl_Close As System.Windows.Forms.Panel
        Friend WithEvents pnl_Header As System.Windows.Forms.Panel
    
        Private fMove As Integer
        Private Porg As Point
        Public Shared Moving As Boolean = False
    
        Public Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub
    
        Private Sub InitializeComponent()
            Me.pic_Icon = New System.Windows.Forms.PictureBox()
            Me.pnl_Close = New System.Windows.Forms.Panel()
            Me.pnl_Header = New System.Windows.Forms.Panel()
            CType(Me.pic_Icon, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            'pic_Icon
            Me.pic_Icon.BackColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.pic_Icon.ErrorImage = Nothing
            Me.pic_Icon.InitialImage = Nothing
            Me.pic_Icon.Location = New System.Drawing.Point(1, 1)
            Me.pic_Icon.Name = "pic_Icon"
            Me.pic_Icon.Size = New System.Drawing.Size(31, 25)
            Me.pic_Icon.TabIndex = 2
            Me.pic_Icon.TabStop = False
            'pnl_Close
            Me.pnl_Close.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Close.BackColor = System.Drawing.Color.Red
            Me.pnl_Close.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center
            Me.pnl_Close.Location = New System.Drawing.Point(300, 1)
            Me.pnl_Close.Name = "pnl_Close"
            Me.pnl_Close.Size = New System.Drawing.Size(31, 25)
            Me.pnl_Close.TabIndex = 1
            'pnl_Header
            Me.pnl_Header.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Header.BackColor = System.Drawing.Color.Yellow
            Me.pnl_Header.Location = New System.Drawing.Point(32, 1)
            Me.pnl_Header.Name = "pnl_Header"
            Me.pnl_Header.Size = New System.Drawing.Size(268, 25)
            Me.pnl_Header.TabIndex = 3
            'qForm
            Me.AllowDrop = True
            Me.BackColor = System.Drawing.Color.LightGray
            Me.Controls.Add(Me.pic_Icon)
            Me.Controls.Add(Me.pnl_Close)
            Me.Controls.Add(Me.pnl_Header)
            Me.Name = "qForm"
            Me.Size = New System.Drawing.Size(332, 227)
            CType(Me.pic_Icon, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
        End Sub
    
        Private Sub qForm_Paint(ByVal sender As Object, _
                                ByVal e As System.Windows.Forms.PaintEventArgs) _
                                Handles Me.Paint
            If Moving = False Then
                Using gp As New GraphicsPath, bSb As New Pen(Brushes.Black, 1)
                    gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
                    e.Graphics.DrawPath(bSb, gp)
                End Using    'the new GraphicsPath and Pen will be disposed when this line is executed.
            End If
        End Sub
    
        Private Sub pnl_Close_Click(ByVal sender As System.Object, _
                                    ByVal e As System.EventArgs) _
                                    Handles pnl_Close.MouseClick
            Me.Dispose()
        End Sub
    
        Private Sub pnl_Header_MouseDown(ByVal sender As Object, _
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseDown
            Moving = True
            Me.Focus()
            fMove = 1
            Porg = e.Location
        End Sub
    
        Private Sub pnl_Header_MouseUp(ByVal sender As Object, _
                                       ByVal e As System.Windows.Forms.MouseEventArgs) _
                                       Handles pnl_Header.MouseUp
            fMove = 0
            Moving = False
        End Sub
    
        Private Sub pnl_Header_MouseMove(ByVal sender As Object, _
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseMove
            Dim X As Integer = Me.Location.X + (e.Location.X - Porg.X)
            Dim Y As Integer = Me.Location.Y + (e.Location.Y - Porg.Y)
    
            If fMove = 1 Then
                Me.Location = New Point(X, Y)
            End If
        End Sub
    
    End Class
    
    


    La vida loca

    Wednesday, May 2, 2018 9:36 PM
  •  Your problem with the streaks is caused from placing your controls in an MdiContainer.  Is there a specific reason you need to use an MdiContainer form?  If not,  then set the IsMdiContainer property of the main form to false.  That will stop the streaking.

    EDIT:  If you really need to use an MdiContainer form for some reason,  then you should be creating your 'qPanel' controls from a Borderless Form class and setting them as MdiChildren of the MdiContainer form,  not a Panel


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Thursday, May 3, 2018 12:43 AM
    Thursday, May 3, 2018 12:18 AM
  •  As I stated in my last post above this one,  if you have a reason for using an MdiContainer form then you should be creating your 'qPanel' control as a Form instead of a Panel.  Below is a simple example you can test in a new form project.

     Create a new form project and then add a secondary form to it (Form2).  Then in Form1's code view,  add this code...

    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.IsMdiContainer = True
    
            Dim child1 As New Form2
            child1.MdiParent = Me
            child1.Show()
            child1.Location = New Point(20, 10)
        End Sub
    
    End Class
    
     

     Now in Form2's code view add the code below.  Then you can simply add the controls you want to Form2 in the designer window.  I added a few TextBoxes and a few Panels.  The caption area of the form is all drawn and handled in the code below.

    Public Class Form2
        Private Const HTCAPTION As Integer = &H2
        Private Const HTCLOSE As Integer = &H14
        Private Const WM_NCHITTEST As Integer = &H84
        Private Const WM_NCLBUTTONDOWN As Integer = &HA1
    
        Private CloseButtonRect As Rectangle = Rectangle.Empty
    
        Public Sub New()
            InitializeComponent()
    
            Me.DoubleBuffered = True
            Me.FormBorderStyle = FormBorderStyle.None
            Me.BackColor = Color.Gainsboro
        End Sub
    
        Protected Overrides Sub OnPaint(e As PaintEventArgs)
            MyBase.OnPaint(e)
            CloseButtonRect = New Rectangle(Me.Width - 30, 0, 30, 30)
            With e.Graphics
                .FillRectangle(Brushes.Yellow, 0, 0, Me.Width, 30)
                .FillRectangle(Brushes.Red, CloseButtonRect)
                .DrawRectangle(Pens.Black, 0, 0, Me.Width - 1, Me.Height - 1)
            End With
        End Sub
    
        Protected Overrides Sub WndProc(ByRef m As Message)
            If m.Msg = WM_NCLBUTTONDOWN Then
                If m.WParam.ToInt32 = HTCLOSE Then
                    Me.Close()
                End If
            ElseIf m.Msg = WM_NCHITTEST Then
                Dim loc As Point = Me.PointToClient(MousePosition)
                If CloseButtonRect.Contains(loc) Then
                    m.Result = CType(HTCLOSE, IntPtr)
                    Return
                ElseIf loc.Y <= 30 Then
                    m.Result = CType(HTCAPTION, IntPtr)
                    Return
                End If
            End If
            MyBase.WndProc(m)
        End Sub
    End Class
     

     Here you can see it does not leave streaks and the caption area allows you to move it.  The close button (red square) allows you to close the form.


    If you say it can`t be done then i`ll try it

    Thursday, May 3, 2018 1:41 AM
  • Hi,

    what exactly do you want to do? Generate a moveable Panel in a MDI Application with custom Background etc?

    If so, handle the paint event for the MdiClient object:

    Option Strict On
    Imports System.Drawing.Drawing2D
    
    Partial Public Class Form1
        Inherits Form
    
        Private _r As Rectangle = New Rectangle()
        Private _f As MdiClient = Nothing
        Private _b As Boolean = False
        Private p As Panel = Nothing
        Private _x As Integer = 0
        Private _y As Integer = 0
    
        Public Sub New()
            InitializeComponent()
            Me.IsMdiContainer = True
            Me.Size = New Size(1024, 768)
            AddHandler Me.Resize, New System.EventHandler(AddressOf Form1_Resize)
            AddHandler Me.Load, New System.EventHandler(AddressOf Me.Form1_Load)
            _r = Screen.GetWorkingArea(Me)
            For Each c As Control In Me.Controls
                Try
                    _f = CType(c, MdiClient)
                    Exit For
                Catch
                End Try
            Next
    
            _f.BackColor = Color.Maroon
            AddHandler _f.Paint, AddressOf _f_Paint
            AddHandler _f.Click, AddressOf _f_Click
        End Sub
    
        Private Sub _f_Paint(ByVal sender As Object, ByVal e As PaintEventArgs)
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
            Using l As LinearGradientBrush = New LinearGradientBrush(_r, Color.Red, Color.Blue, LinearGradientMode.ForwardDiagonal)
                e.Graphics.FillRectangle(l, _r)
            End Using
        End Sub
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            Dim f As Form = New Form()
            AddHandler f.Click, AddressOf f_Click
            f.BackColor = Color.MediumBlue
            f.MdiParent = Me
            f.Show()
            Dim ff As Form = New Form()
            ff.BackColor = Color.MediumBlue
            ff.MdiParent = Me
            ff.Show()
            p = New Panel()
            p.Size = New Size(200, 200)
            AddHandler p.MouseDown, AddressOf P_MouseDown
            AddHandler p.MouseMove, AddressOf P_MouseMove
            p.BackColor = Color.Green
            Me.Controls.Add(p)
        End Sub
    
        Private Sub P_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
            If e.Button = MouseButtons.Left Then
                p.Location = New Point(p.Left + e.X - _x, p.Top + e.Y - _y)
            End If
        End Sub
    
        Private Sub P_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
            If e.Button = MouseButtons.Left Then
                _x = e.X
                _y = e.Y
            End If
        End Sub
    
        Private Sub Form1_Resize(ByVal sender As Object, ByVal e As EventArgs)
        End Sub
    
        Private Sub f_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim f As Form = CType(sender, Form)
            f.ControlBox = Not f.ControlBox
            If f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None Then f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable Else f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        End Sub
    
        Private Sub _f_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim f As Form = CType((CType(sender, MdiClient)).Parent, Form)
            f.ControlBox = Not f.ControlBox
            If f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None Then f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable Else f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        End Sub
    End Class

    Regards,

      Thorsten


    Thursday, May 3, 2018 4:44 AM
  • My guess is OP wants a transparent hole in the mdi panel too?

    Thursday, May 3, 2018 9:39 AM
  • Hi IronRazerz,

      The IsMdiContainer is an overhang from when I used Mdi child forms to implement the forms containing the qPanels - lazy really as I never though of switching it off!  IsMdiContainer = false clears up the qForm trailing but there are still some traces of trailing on the qInputs.

      Is there a way to make qForm be a true container so that I can drop the qPanels and qInputs into it from the designer?  When I try this, at present, the "q's" go into the Form1.

    All the best,
                      HotIndigo.

    Thursday, May 3, 2018 10:28 AM

  •   Is there a way to make qForm be a true container so that I can drop the qPanels and qInputs into it from the designer?  When I try this, at present, the "q's" go into the Form1.

    All the best,
                      HotIndigo.

    Hi,

    using Mr.Monkeyboys code from above, I changed the qForm to: (the declaring line inherits and the constructor), then I set IsMDIContainer to false... (You can treat a form as a control as long as its not a top-level control)

    Public Class qForm
        Inherits Form
    
        Friend WithEvents pic_Icon As System.Windows.Forms.PictureBox
        Friend WithEvents pnl_Close As System.Windows.Forms.Panel
        Friend WithEvents pnl_Header As System.Windows.Forms.Panel
    
        Private fMove As Integer
        Private Porg As Point
    
        Public Sub New()
            MyBase.New()
            Me.SetTopLevel(False)
            Me.FormBorderStyle = FormBorderStyle.None
            InitializeComponent()
            Me.Show()
        End Sub
    
        Private Sub InitializeComponent()
            Me.pic_Icon = New System.Windows.Forms.PictureBox()
            Me.pnl_Close = New System.Windows.Forms.Panel()
            Me.pnl_Header = New System.Windows.Forms.Panel()
            CType(Me.pic_Icon, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            'pic_Icon
            Me.pic_Icon.BackColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.pic_Icon.ErrorImage = Nothing
            Me.pic_Icon.InitialImage = Nothing
            Me.pic_Icon.Location = New System.Drawing.Point(1, 1)
            Me.pic_Icon.Name = "pic_Icon"
            Me.pic_Icon.Size = New System.Drawing.Size(31, 25)
            Me.pic_Icon.TabIndex = 2
            Me.pic_Icon.TabStop = False
            'pnl_Close
            Me.pnl_Close.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Close.BackColor = System.Drawing.Color.Red
            Me.pnl_Close.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center
            Me.pnl_Close.Location = New System.Drawing.Point(300, 1)
            Me.pnl_Close.Name = "pnl_Close"
            Me.pnl_Close.Size = New System.Drawing.Size(31, 25)
            Me.pnl_Close.TabIndex = 1
            'pnl_Header
            Me.pnl_Header.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Header.BackColor = System.Drawing.Color.Yellow
            Me.pnl_Header.Location = New System.Drawing.Point(32, 1)
            Me.pnl_Header.Name = "pnl_Header"
            Me.pnl_Header.Size = New System.Drawing.Size(268, 25)
            Me.pnl_Header.TabIndex = 3
            'qForm
            Me.AllowDrop = True
            Me.BackColor = System.Drawing.Color.LightGray
            Me.Controls.Add(Me.pic_Icon)
            Me.Controls.Add(Me.pnl_Close)
            Me.Controls.Add(Me.pnl_Header)
            Me.Name = "qForm"
            Me.Size = New System.Drawing.Size(332, 227)
            CType(Me.pic_Icon, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
        End Sub
    
        Private Sub qForm_Paint(ByVal sender As Object,
                                ByVal e As System.Windows.Forms.PaintEventArgs) _
                                Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(Brushes.Black, 1)
                gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using    'the new GraphicsPath and Pen will be disposed when this line is executed.
        End Sub
    
        Private Sub pnl_Close_Click(ByVal sender As System.Object,
                                    ByVal e As System.EventArgs) _
                                    Handles pnl_Close.MouseClick
            Me.Dispose()
        End Sub
    
        Private Sub pnl_Header_MouseDown(ByVal sender As Object,
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseDown
            Me.Focus()
            fMove = 1
            Porg = e.Location
        End Sub
    
        Private Sub pnl_Header_MouseUp(ByVal sender As Object,
                                       ByVal e As System.Windows.Forms.MouseEventArgs) _
                                       Handles pnl_Header.MouseUp
            fMove = 0
        End Sub
    
        Private Sub pnl_Header_MouseMove(ByVal sender As Object,
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseMove
            Dim X As Integer = Me.Location.X + (e.Location.X - Porg.X)
            Dim Y As Integer = Me.Location.Y + (e.Location.Y - Porg.Y)
    
            If fMove = 1 Then
                Me.Location = New Point(X, Y)
                Me.Refresh()
            End If
        End Sub
    
    End Class

    Regards,

      Thorsten


    Thursday, May 3, 2018 12:10 PM
  • Hi All,

       Thanks for all the suggestions.  I have put a number of these into practice and eliminated the qForm trailing but there is still trailing in the qPanel (this version is a bit more complex) and qInput.

      I have attached the latest code including modifications to the InitializeComponent part of the .designer files.  This version is tidier and allows you to modify the "q's" more easily.

    ' --------------   Form1 Code  --------------
    
    Public Class Form1
    
    Inherits Form
    
        Private Sub Form1_Load(sender As Object, _
                               e As EventArgs) _
                               Handles MyBase.Load
            Dim qForm1 As New qForm
            qForm1.MdiParent = Me
            qForm1.Show()
        End Sub
    
        Private Sub mnu_New_Click(sender As Object, _
                                  e As EventArgs) _
                                  Handles mnu_New.Click
            Dim NewForm As New qForm
            NewForm.MdiParent = Me
            NewForm.Show()
        End Sub
    
    End Class
    
    ' --------------   Form1 Designer InitializeComponent  --------------
    
        Private Sub InitializeComponent()
            Me.MenuStrip1 = New System.Windows.Forms.MenuStrip()
            Me.mnu_New = New System.Windows.Forms.ToolStripMenuItem()
            Me.MenuStrip1.SuspendLayout()
            Me.SuspendLayout()
            '
            'MenuStrip1
            '
            Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnu_New, Me.mnu_Window})
            Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
            Me.MenuStrip1.Name = "MenuStrip1"
            Me.MenuStrip1.Size = New System.Drawing.Size(624, 24)
            Me.MenuStrip1.TabIndex = 4
            Me.MenuStrip1.Text = "MenuStrip1"
            '
            'mnu_New
            '
            Me.mnu_New.Name = "mnu_New"
            Me.mnu_New.Size = New System.Drawing.Size(43, 20)
            Me.mnu_New.Text = "New"
            '
            'Form1
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(624, 482)
            Me.Controls.Add(Me.QPanel1)
            Me.Controls.Add(Me.MenuStrip1)
            Me.IsMdiContainer = True
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
            Me.MenuStrip1.ResumeLayout(False)
            Me.MenuStrip1.PerformLayout()
            Me.ResumeLayout(False)
            Me.PerformLayout()
    
    End Sub
     Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
     Friend WithEvents mnu_New As System.Windows.Forms.ToolStripMenuItem
     
     ' --------------   qPanel Code  --------------
    
    Option Strict On
    Option Explicit Off
    
    Imports System.ComponentModel
    Imports System.Drawing.Drawing2D
    
    Public Class qPanel
    
        Private Sub qPanel_Paint(ByVal sender As Object, _
                                 ByVal e As System.Windows.Forms.PaintEventArgs) _
                                 Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(Brushes.Black, 1)
                gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using    'the new GraphicsPath and Pen will be disposed when this line is executed.
        End Sub
    End Class
    
    ' --------------   qPanel Designer InitializeComponent  --------------
    
        Private Sub InitializeComponent()
            Me.Label1 = New System.Windows.Forms.Label()
            Me.Label2 = New System.Windows.Forms.Label()
            Me.Label3 = New System.Windows.Forms.Label()
            Me.SuspendLayout()
            '
            'Label1
            '
            Me.Label1.BackColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(192, Byte), Integer))
            Me.Label1.Location = New System.Drawing.Point(1, 1)
            Me.Label1.Name = "Label1"
            Me.Label1.Size = New System.Drawing.Size(120, 20)
            Me.Label1.TabIndex = 0
            Me.Label1.Text = "Text 1"
            Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
            '
            'Label2
            '
            Me.Label2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.Label2.BackColor = System.Drawing.Color.FromArgb(CType(CType(128, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.Label2.Location = New System.Drawing.Point(120, 1)
            Me.Label2.Name = "Label2"
            Me.Label2.Size = New System.Drawing.Size(177, 20)
            Me.Label2.TabIndex = 1
            Me.Label2.Text = "Text 2"
            Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
            '
            'Label3
            '
            Me.Label3.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.Label3.BackColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.Label3.Location = New System.Drawing.Point(296, 1)
            Me.Label3.Name = "Label3"
            Me.Label3.Size = New System.Drawing.Size(127, 20)
            Me.Label3.TabIndex = 2
            Me.Label3.Text = "Text 3"
            Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
            '
            'qPanel
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.Controls.Add(Me.Label3)
            Me.Controls.Add(Me.Label2)
            Me.Controls.Add(Me.Label1)
            Me.Name = "qPanel"
            Me.Size = New System.Drawing.Size(426, 30)
            Me.ResumeLayout(False)
    
    End Sub
        Friend WithEvents Label1 As System.Windows.Forms.Label
        Friend WithEvents Label2 As System.Windows.Forms.Label
        Friend WithEvents Label3 As System.Windows.Forms.Label
    
     ' --------------   qInput Code  --------------
    
    Option Strict On
    Option Explicit Off
    
    Imports System.ComponentModel
    Imports System.Drawing.Drawing2D
    
    Public Class qInput
    
        Private _BorderColour As Color = Color.Black    ' Input Panel Border Colour (1 pixel thick).
        Private _InnerBorderColour As Color = Color.Red    ' Text Box    Border Colour (1 pixel thick).
        Private _ContainerColour As Color = Color.White    ' Input Panel Background Colour.
        Private _InputText As String = "0g"
        Private _InputOffset As Integer = 2                ' Text Entry Offset from Panel LHS.
        Private _InputWidth As Integer = 50                ' Text Input Box Width.
        Private _InputTop As Integer = 0                ' Text Input Box Top relative to Panel.
        Private _InputColour As Color = Color.Black        ' Input Text Colour.
        Private _PromptText As String = "Prompt"        ' Prompt Panel Text.
        Private _PromptTop As Integer = 5                ' Prompt Panel Top.
        Private _PromptFont As Font                        ' PrPromptompt Panel Text Font.
        Private _PromptColour As Color = Color.Black    ' Prompt Panel Text Colour.
        Private _Width As Integer = 200                    ' Input Panel Width.
        Private _Height As Integer = 20                    ' Input Panel Height.
    
        Private _InputHeight As Integer                    ' Text Input Box Height.
        Private _PromptHeight As Integer                ' Prompt Panel Height.
        Private _PromptLeft As Integer                    ' Text Input Box LHS.
    
    #Region "Public Properties"
    
        <Description("Panel Border Colour.")> _
        Public Property BorderColour() As Color
            Get
                Return _BorderColour
            End Get
            Set(ByVal value As Color)
                _BorderColour = value
                Do_InnerBorder = False
                Me.Invalidate()
           End Set
        End Property
    
        <Description("Container Colour.")> _
        Public Property ContainerColour() As Color
            Get
                Return _ContainerColour
            End Get
            Set(ByVal value As Color)
                _ContainerColour = value
                Me.BackColor = value
                lbl_Prompt.BackColor = value
                txt_Entry.BackColor = value
                Do_InnerBorder = False
                Me.Invalidate()
           End Set
        End Property
    
        <Description("Text Entry panel offset from Left.")> _
        Public Property InputOffset() As Integer
            Get
                Return _InputOffset
            End Get
            Set(ByVal value As Integer)
                _InputOffset = value
                Call SetPanelPositions()
           End Set
        End Property
    
        <Description("Text Entry panel top.")> _
        Public Property InputTop() As Integer
            Get
                Return _InputTop
            End Get
            Set(ByVal value As Integer)
                _InputTop = value
                Call SetPanelPositions()
           End Set
        End Property
    
        <Description("Text Entry panel width.")> _
        Public Property InputWidth() As Integer
            Get
                Return _InputWidth
            End Get
            Set(ByVal value As Integer)
                _InputWidth = value
                Call SetPanelPositions()
           End Set
        End Property
    
        <Description("Input text.")> _
        Public Property InputText() As String
            Get
                Return _InputText
            End Get
            Set(ByVal value As String)
                _InputText = value
           End Set
        End Property
    
        <Description("Input text colour.")> _
        Public Property InputColour() As Color
            Get
                Return _InputColour
            End Get
            Set(ByVal value As Color)
                _InputColour = value
                txt_Entry.ForeColor = value
           End Set
        End Property
    
        <Description("Prompt Panel top.")> _
        Public Property PromptTop() As Integer
            Get
                Return _PromptTop
            End Get
            Set(ByVal value As Integer)
                _PromptTop = value
                Call SetPanelPositions()
           End Set
        End Property
    
        <Description("Prompt text colour.")> _
        Public Property PromptColour() As Color
            Get
                Return _PromptColour
            End Get
            Set(ByVal value As Color)
                _PromptColour = value
                lbl_Prompt.ForeColor = value
           End Set
        End Property
    
    #End Region
    
        Private Sub pnl_Input_Paint(ByVal sender As System.Object, _
                                    ByVal e As System.Windows.Forms.PaintEventArgs) _
                                    Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(_InnerBorderColour, 1)
                gp.AddRectangle(New Rectangle(1, 1, _Width - 3, _Height - 3))
                e.Graphics.DrawPath(bSb, gp)
            End Using
            Using gp As New GraphicsPath, bSb As New Pen(_BorderColour, 1)
                gp.AddRectangle(New Rectangle(0, 0, _Width - 1, _Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using
        End Sub
    
        Private Sub qInput_Resize(ByVal sender As Object, _
                                  ByVal e As System.EventArgs) _
                                  Handles Me.SizeChanged
            _Width = Me.Width
            Call SetPanelPositions()
        End Sub
    
        Private Sub SetPanelPositions()
            If (lbl_Prompt IsNot Nothing) And (txt_Entry IsNot Nothing) Then
                _PromptLeft = _InputWidth + _InputOffset + 4
                With txt_Entry
                    _InputHeight = .Height
                    .Left = _InputOffset + 2
                    .Top = 4 + _InputTop
                    .Width = _InputWidth
                End With
                With lbl_Prompt
                    _PromptHeight = .Height
                    .Left = _PromptLeft
                    .Top = 3 + _PromptTop
                    .Width = _Width - (_PromptLeft + 4)
                End With
                _Height = _PromptHeight + 15
                Me.Height = _Height
            End If
        End Sub
    End Class
    
    ' --------------   qInput Designer InitializeComponent  --------------
    
        Private Sub InitializeComponent()
            Me.txt_Entry = New System.Windows.Forms.TextBox()
            Me.lbl_Prompt = New System.Windows.Forms.Label()
            Me.SuspendLayout()
            '
            'txt_Entry
            '
            Me.txt_Entry.Location = New System.Drawing.Point(7, 24)
            Me.txt_Entry.Name = "txt_Entry"
            Me.txt_Entry.Size = New System.Drawing.Size(127, 20)
            Me.txt_Entry.TabIndex = 0
            '
            'lbl_Prompt
            '
            Me.lbl_Prompt.AutoSize = True
            Me.lbl_Prompt.Location = New System.Drawing.Point(156, 29)
            Me.lbl_Prompt.Name = "lbl_Prompt"
            Me.lbl_Prompt.Size = New System.Drawing.Size(39, 13)
            Me.lbl_Prompt.TabIndex = 1
            Me.lbl_Prompt.Text = "Label1"
            '
            'qInput
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.Controls.Add(Me.lbl_Prompt)
            Me.Controls.Add(Me.txt_Entry)
            Me.Name = "qInput"
            Me.Size = New System.Drawing.Size(327, 134)
            Me.ResumeLayout(False)
            Me.PerformLayout()
    End Sub
        Friend WithEvents txt_Entry As System.Windows.Forms.TextBox
        Friend WithEvents lbl_Prompt As System.Windows.Forms.Label
    
     ' --------------   qForm Code  --------------
    
    Option Strict On
    Option Explicit Off
    
    Imports System.Drawing.Drawing2D
    
    Public Class qForm
    
    Inherits Form
    
        Private fMove As Integer
        Private Porg As Point
    
        Private Sub qForm_Paint(ByVal sender As Object, _
                                ByVal e As System.Windows.Forms.PaintEventArgs) _
                                Handles Me.Paint
            Using gp As New GraphicsPath, bSb As New Pen(Brushes.Black, 1)
                gp.AddRectangle(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
                e.Graphics.DrawPath(bSb, gp)
            End Using    'the new GraphicsPath and Pen will be disposed when this line is executed.
        End Sub
    
        Private Sub pnl_Close_Click(ByVal sender As System.Object, _
                                    ByVal e As System.EventArgs) _
                                    Handles pnl_Close.MouseClick
            Me.Dispose()
        End Sub
    
        Private Sub pnl_Header_MouseDown(ByVal sender As Object, _
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseDown
            fMove = 1
            Porg = e.Location
        End Sub
    
        Private Sub pnl_Header_MouseUp(ByVal sender As Object, _
                                       ByVal e As System.Windows.Forms.MouseEventArgs) _
                                       Handles pnl_Header.MouseUp
            fMove = 0
        End Sub
    
        Private Sub pnl_Header_MouseMove(ByVal sender As Object, _
                                         ByVal e As System.Windows.Forms.MouseEventArgs) _
                                         Handles pnl_Header.MouseMove
            Dim X As Integer = Me.Location.X + (e.Location.X - Porg.X)
            Dim Y As Integer = Me.Location.Y + (e.Location.Y - Porg.Y)
            If fMove = 1 Then
                Me.Location = New Point(X, Y)
            End If
        End Sub
    End Class
    
    ' --------------   qForm Designer InitializeComponent  --------------
    
        Private Sub InitializeComponent()
            Me.pnl_Header = New System.Windows.Forms.Panel()
            Me.pnl_Close = New System.Windows.Forms.Panel()
            Me.QPanel1 = New TestForm.qPanel()
            Me.QPanel2 = New TestForm.qPanel()
            Me.QPanel3 = New TestForm.qPanel()
            Me.QPanel4 = New TestForm.qPanel()
            Me.QInput1 = New TestForm.qInput()
            Me.QInput2 = New TestForm.qInput()
            Me.QInput3 = New TestForm.qInput()
            Me.QInput4 = New TestForm.qInput()
            Me.SuspendLayout()
            '
            'pnl_Header
            '
            Me.pnl_Header.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Header.BackColor = System.Drawing.Color.Yellow
            Me.pnl_Header.Location = New System.Drawing.Point(1, 1)
            Me.pnl_Header.Name = "pnl_Header"
            Me.pnl_Header.Size = New System.Drawing.Size(402, 25)
            Me.pnl_Header.TabIndex = 0
            '
            'pnl_Close
            '
            Me.pnl_Close.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.pnl_Close.BackColor = System.Drawing.Color.Red
            Me.pnl_Close.Location = New System.Drawing.Point(402, 1)
            Me.pnl_Close.Name = "pnl_Close"
            Me.pnl_Close.Size = New System.Drawing.Size(31, 25)
            Me.pnl_Close.TabIndex = 1
            '
            'QPanel1
            '
            Me.QPanel1.BackColor = System.Drawing.Color.Gainsboro
            Me.QPanel1.Location = New System.Drawing.Point(18, 52)
            Me.QPanel1.Name = "QPanel1"
            Me.QPanel1.Size = New System.Drawing.Size(370, 22)
            Me.QPanel1.TabIndex = 2
            '
            'QPanel2
            '
            Me.QPanel2.BackColor = System.Drawing.Color.Gainsboro
            Me.QPanel2.Location = New System.Drawing.Point(18, 80)
            Me.QPanel2.Name = "QPanel2"
            Me.QPanel2.Size = New System.Drawing.Size(370, 22)
            Me.QPanel2.TabIndex = 3
            '
            'QPanel3
            '
            Me.QPanel3.BackColor = System.Drawing.Color.Gainsboro
            Me.QPanel3.Location = New System.Drawing.Point(18, 108)
            Me.QPanel3.Name = "QPanel3"
            Me.QPanel3.Size = New System.Drawing.Size(370, 22)
            Me.QPanel3.TabIndex = 4
            '
            'QPanel4
            '
            Me.QPanel4.BackColor = System.Drawing.Color.Gainsboro
            Me.QPanel4.Location = New System.Drawing.Point(18, 136)
            Me.QPanel4.Name = "QPanel4"
            Me.QPanel4.Size = New System.Drawing.Size(370, 22)
            Me.QPanel4.TabIndex = 5
            '
            'QInput1
            '
            Me.QInput1.BackColor = System.Drawing.Color.White
            Me.QInput1.BorderColour = System.Drawing.Color.Black
            Me.QInput1.ContainerColour = System.Drawing.Color.White
            Me.QInput1.InputColour = System.Drawing.Color.Black
            Me.QInput1.InputOffset = 4
            Me.QInput1.InputText = "0g"
            Me.QInput1.InputTop = 0
            Me.QInput1.InputWidth = 50
            Me.QInput1.Location = New System.Drawing.Point(18, 173)
            Me.QInput1.Name = "QInput1"
            Me.QInput1.PromptColour = System.Drawing.Color.Black
            Me.QInput1.PromptTop = 5
            Me.QInput1.Size = New System.Drawing.Size(370, 28)
            Me.QInput1.TabIndex = 6
            '
            'QInput2
            '
            Me.QInput2.BackColor = System.Drawing.Color.White
            Me.QInput2.BorderColour = System.Drawing.Color.Black
            Me.QInput2.ContainerColour = System.Drawing.Color.White
            Me.QInput2.InputColour = System.Drawing.Color.Black
            Me.QInput2.InputOffset = 2
            Me.QInput2.InputText = "0g"
            Me.QInput2.InputTop = 0
            Me.QInput2.InputWidth = 50
            Me.QInput2.Location = New System.Drawing.Point(18, 206)
            Me.QInput2.Name = "QInput2"
            Me.QInput2.PromptColour = System.Drawing.Color.Black
            Me.QInput2.PromptTop = 1
            Me.QInput2.Size = New System.Drawing.Size(370, 28)
            Me.QInput2.TabIndex = 7
            '
            'QInput3
            '
            Me.QInput3.BackColor = System.Drawing.Color.White
            Me.QInput3.BorderColour = System.Drawing.Color.Black
            Me.QInput3.ContainerColour = System.Drawing.Color.White
            Me.QInput3.InputColour = System.Drawing.Color.Black
            Me.QInput3.InputOffset = 2
            Me.QInput3.InputText = "0g"
            Me.QInput3.InputTop = 0
            Me.QInput3.InputWidth = 50
            Me.QInput3.Location = New System.Drawing.Point(18, 239)
            Me.QInput3.Name = "QInput3"
            Me.QInput3.PromptColour = System.Drawing.Color.Black
            Me.QInput3.PromptTop = 1
            Me.QInput3.Size = New System.Drawing.Size(370, 28)
            Me.QInput3.TabIndex = 8
            '
            'QInput4
            '
            Me.QInput4.BackColor = System.Drawing.Color.White
            Me.QInput4.BorderColour = System.Drawing.Color.Black
            Me.QInput4.ContainerColour = System.Drawing.Color.White
            Me.QInput4.InputColour = System.Drawing.Color.Black
            Me.QInput4.InputOffset = 2
            Me.QInput4.InputText = "0g"
            Me.QInput4.InputTop = 0
            Me.QInput4.InputWidth = 50
            Me.QInput4.Location = New System.Drawing.Point(18, 272)
            Me.QInput4.Name = "QInput4"
            Me.QInput4.PromptColour = System.Drawing.Color.Black
            Me.QInput4.PromptTop = 1
            Me.QInput4.Size = New System.Drawing.Size(370, 28)
            Me.QInput4.TabIndex = 9
            '
            'qForm
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(434, 340)
            Me.Controls.Add(Me.QInput4)
            Me.Controls.Add(Me.QInput3)
            Me.Controls.Add(Me.QInput2)
            Me.Controls.Add(Me.QInput1)
            Me.Controls.Add(Me.QPanel4)
            Me.Controls.Add(Me.QPanel3)
            Me.Controls.Add(Me.QPanel2)
            Me.Controls.Add(Me.QPanel1)
            Me.Controls.Add(Me.pnl_Close)
            Me.Controls.Add(Me.pnl_Header)
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
            Me.Name = "qForm"
            Me.Text = "qForm"
            Me.ResumeLayout(False)
    End Sub
        Friend WithEvents pnl_Header As System.Windows.Forms.Panel
        Friend WithEvents pnl_Close As System.Windows.Forms.Panel
     Friend WithEvents QPanel1 As TestForm.qPanel
     Friend WithEvents QPanel2 As TestForm.qPanel
     Friend WithEvents QPanel3 As TestForm.qPanel
     Friend WithEvents QPanel4 As TestForm.qPanel
     Friend WithEvents QInput1 As TestForm.qInput
     Friend WithEvents QInput2 As TestForm.qInput
     Friend WithEvents QInput3 As TestForm.qInput
     Friend WithEvents QInput4 As TestForm.qInput
    
    

    Create a new Windows Form application (Form1) add another Windows Form and rename it qForm.  Then add 2 User Controls and name them qPanel and qInput.  Drop the above code sections into each .vb code file and replace the Sub InitializeComponent() part of the .designer files with the appropriate InitializeComponent from above.  When you run this code you can create as many qForms as you like by clicking on the New item on the Menu Panel.

    If you change the qForm.FormBorderStyle to a FixedToolWindow, all the trailing disappears!  So the real question is what is causing the component trailing on the "native" form.  Does having mutliple elements in each control affect the repainting mechanism?  I've tried all sorts of things but to no avail.  Any clues would be very welcome.

    The purpose of the qPanel is to have a plain form with a "close" button and an Icon on the top left.  The other "q" controls are part of a project I am working on.  Ultimately it would be nice to have the "q" controls in a .dll for easy re-useablility.

    All the best,
                       HotIndigo.

    Friday, May 4, 2018 2:22 PM
  • All I can say is that by not allowing painting during movement, dragging with mouse, the problem goes away for me. Did you try using the code changes I provided where a boolean is set at mouse down and mouse up so during dragging the paint events won't paint?

    La vida loca

    Friday, May 4, 2018 4:59 PM
  • Hi Mr. MB,

       I haven't tried it with the old code but with the new code all it does is remove the qForm border!  I will try the old code later.  Thanks.

       I tried it with the old code and - yes - the trails disappear, but so do all the "q" borders!  There has to be a clue here.  How can we make the borders "stick"?

    HotIndigo.


    • Edited by HotIndigo Friday, May 4, 2018 8:15 PM
    Friday, May 4, 2018 5:54 PM
  • Hi Mr.MB,

       I just tried your Borderless Form with a red rectangle - works really well as is.  I then tried another experiment and dropped in a dozen qPanels (made up of a UserControl with 3 panels inserted side by side - I used different colours on each element to identify them) below your Text1 .  I then created a Form1 with a MenuStrip and inserted a MenuStripItem which I called mnu_New. I then used your Form 2 inside it.  This is the essential code for Form1.

    Public Class Form1
    
    Inherits Form
    
        Private Sub Form1_Load(sender As Object, _
                               e As EventArgs) _
                               Handles MyBase.Load
            Dim qForm1 As New Form2
            qForm1.MdiParent = Me
            qForm1.Show()
        End Sub
    
        Private Sub mnu_New_Click(sender As Object, _
                                  e As EventArgs) _
                                  Handles mnu_New.Click
            Dim NewForm As New Form2
            NewForm.MdiParent = Me
            NewForm.Show()
        End Sub
    
    End Class
    
    

       When you run Form 1 and click New it will insert some of your, now modified, Form2's.  When you move these around, over eachother, you get trailing!

       Where it gets very interesting is if you make your Form2 into a FixedToolWindow and comment out the Protected Overrides Sub WndProc(ByRef m As Message) routine and then run Form1, you get no trailing!  It appears the problem may very well lie in the move routines.

       I am now open to other suggestions on this.

    All the best,
                      HotIndigo.

    Sunday, May 6, 2018 7:25 PM
  • Well I would suggest not painting at all really. And placing panels in appropriate locations such that their backcolor supports the layout rather than painting.

    For example for a colored border on the Form place a panel on it that extends from the center to however you want the borders to appear on the Form.

    Other than that I can only suggest stopping painting as the Form is moved.

    Here's some drawing I did once following a moving transparent panel gaining opacity.


    La vida loca

    Sunday, May 6, 2018 8:21 PM