Please help, more scrollbar questions. CODE INCLUDED.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Colin McGuire

    Please help, more scrollbar questions. CODE INCLUDED.

    I apologize for posting yet another scrollbar question. Here is my
    code. All I want is for a diagonal line to appear from coordinates
    (0,0) to (width,height) in a usercontrol regardless of whether the
    user autoscrolls the usercontrol (other things that are on the
    usercontrol I want to scroll, but haven't included any here).

    Here are the steps to reproduce my problem.

    1. Launch Visual Studio and create a new Windows
    application with "Form1".
    2. Paste the following in (remember to include
    your "Windows Form Designer generated code).
    3. Run - instructions are in the program that runs.

    I am using "Microsoft Development Environment 2003, Version 7.1.3088".
    I am using "Microsoft .NET Framework 1.1, Version 1.1.4322"

    Thank you for your patience with me.
    Colin



    Public Class Form1
    Inherits System.Windows. Forms.Form

    '============== ========
    ' Windows Form Designer generated code
    ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
    '============== ========

    Public Class UserControl1
    Inherits System.Windows. Forms.UserContr ol
    Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
    MyBase.OnPaint( p)
    p.Graphics.Draw Line(New Pen(Color.Black ), _
    clientRectangle .Width, _
    ClientRectangle .Height, _
    0, 0)
    End Sub

    Private Sub UserControl1_Lo ad(ByVal sender As System.Object, _
    ByVal e As System.EventArg s) _
    Handles MyBase.Load
    Me.BackColor = Color.Yellow
    End Sub
    End Class


    Private Sub Form1_Load(ByVa l sender As System.Object, _
    ByVal e As System.EventArg s) Handles MyBase.Load
    Dim uc As New UserControl1
    uc.Location = New Point(0, 0)
    uc.Size = New System.Drawing. Size(New Point(100, 100))
    uc.BackColor = Color.Yellow
    uc.AutoScroll = True
    uc.AutoScrollMi nSize = New Size(New Point(200, 300))
    uc.Visible = True
    Me.Controls.Add (uc)
    Size = New Size(New Point(300, 300))

    Dim lb As New Label
    lb.Location = New Point(0, 150)
    lb.Size = New Size(290, 80)
    lb.Text = "1.Move the scrollbars,the diagonal line isn't" + _
    " drawn from(0,0) to (width,height). 2.Minimize" + _
    " this form. 3. Restore the form size,now the " + _
    "line does go from (0,0) to (width,height). " + _
    "Why, why isn't the diagonal line and " + _
    "control background cleared as you scroll?"
    Me.Controls.Add (lb)
    End Sub
    End Class
  • One Handed Man

    #2
    Re: Please help, more scrollbar questions. CODE INCLUDED.

    What happens then ?


    Colin McGuire wrote:[color=blue]
    > I apologize for posting yet another scrollbar question. Here is my
    > code. All I want is for a diagonal line to appear from coordinates
    > (0,0) to (width,height) in a usercontrol regardless of whether the
    > user autoscrolls the usercontrol (other things that are on the
    > usercontrol I want to scroll, but haven't included any here).
    >
    > Here are the steps to reproduce my problem.
    >
    > 1. Launch Visual Studio and create a new Windows
    > application with "Form1".
    > 2. Paste the following in (remember to include
    > your "Windows Form Designer generated code).
    > 3. Run - instructions are in the program that runs.
    >
    > I am using "Microsoft Development Environment 2003, Version 7.1.3088".
    > I am using "Microsoft .NET Framework 1.1, Version 1.1.4322"
    >
    > Thank you for your patience with me.
    > Colin
    >
    >
    >
    > Public Class Form1
    > Inherits System.Windows. Forms.Form
    >
    > '============== ========
    > ' Windows Form Designer generated code
    > ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
    > '============== ========
    >
    > Public Class UserControl1
    > Inherits System.Windows. Forms.UserContr ol
    > Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
    > MyBase.OnPaint( p)
    > p.Graphics.Draw Line(New Pen(Color.Black ), _
    > clientRectangle .Width, _
    > ClientRectangle .Height, _
    > 0, 0)
    > End Sub
    >
    > Private Sub UserControl1_Lo ad(ByVal sender As System.Object, _
    > ByVal e As System.EventArg s) _
    > Handles MyBase.Load
    > Me.BackColor = Color.Yellow
    > End Sub
    > End Class
    >
    >
    > Private Sub Form1_Load(ByVa l sender As System.Object, _
    > ByVal e As System.EventArg s) Handles MyBase.Load
    > Dim uc As New UserControl1
    > uc.Location = New Point(0, 0)
    > uc.Size = New System.Drawing. Size(New Point(100, 100))
    > uc.BackColor = Color.Yellow
    > uc.AutoScroll = True
    > uc.AutoScrollMi nSize = New Size(New Point(200, 300))
    > uc.Visible = True
    > Me.Controls.Add (uc)
    > Size = New Size(New Point(300, 300))
    >
    > Dim lb As New Label
    > lb.Location = New Point(0, 150)
    > lb.Size = New Size(290, 80)
    > lb.Text = "1.Move the scrollbars,the diagonal line isn't" + _
    > " drawn from(0,0) to (width,height). 2.Minimize" + _
    > " this form. 3. Restore the form size,now the " + _
    > "line does go from (0,0) to (width,height). " + _
    > "Why, why isn't the diagonal line and " + _
    > "control background cleared as you scroll?"
    > Me.Controls.Add (lb)
    > End Sub
    > End Class[/color]


    Comment

    • Colin McGuire

      #3
      Re: Please help, more scrollbar questions. CODE INCLUDED.

      You're not going to make me thank you again I hope :)

      Here is some more elaboration of my problem.

      What I see is:

      1. When I move the vertical scrollbar by clicking "in"
      the scrollbar (ie between the up arrow and down arrow),
      the diagonal line is drawn properly (diagram below).

      +----------+
      |\ |
      | \ |
      | \ |
      | \ |
      | \ |
      | \ |
      | \ |
      | \ |
      | \ |
      | \|
      +----------+

      2. When I click the "down arrow" button on the vertical
      scrollbar, the diagonal scrolls, but I can see a tiny
      bit of the new diagonal showing up - sort of looks like

      +---\-------+
      | \ |
      | \ |
      | \ |
      | \ |
      | \ |
      | \ |
      | \|
      | |
      | |
      | \|
      +-----------+

      3. When I add a Debug.WriteLine ("OnPaint") inside
      the OnPaint method, both clicking "in" the scrollbar
      and clicking the up or down arrow of the scrollbar
      appear produce "OnPaint" in the IDE debug window.

      4. When I minimise this (corrupted window, step 2), then
      maximize it again, then it redraws properly with
      the diagonal from (0,0) to (width,height) as shown
      in Step 1.

      BTW: I forgot to paste in the

      p.Graphics.Clea r(BackColor)

      in my original post before the
      p.Graphics.Draw Line .... but
      it doesn't make any difference if I do.

      Thank you
      Colin






      "One Handed Man" <Bombay@Duck.ne t> wrote in message
      news:blh02f$kg9 $1@hercules.bti nternet.com...[color=blue]
      > What happens then ?
      >
      >
      > Colin McGuire wrote:[color=green]
      > > I apologize for posting yet another scrollbar question. Here is my
      > > code. All I want is for a diagonal line to appear from coordinates
      > > (0,0) to (width,height) in a usercontrol regardless of whether the
      > > user autoscrolls the usercontrol (other things that are on the
      > > usercontrol I want to scroll, but haven't included any here).
      > >
      > > Here are the steps to reproduce my problem.
      > >
      > > 1. Launch Visual Studio and create a new Windows
      > > application with "Form1".
      > > 2. Paste the following in (remember to include
      > > your "Windows Form Designer generated code).
      > > 3. Run - instructions are in the program that runs.
      > >
      > > I am using "Microsoft Development Environment 2003, Version 7.1.3088".
      > > I am using "Microsoft .NET Framework 1.1, Version 1.1.4322"
      > >
      > > Thank you for your patience with me.
      > > Colin
      > >
      > >
      > >
      > > Public Class Form1
      > > Inherits System.Windows. Forms.Form
      > >
      > > '============== ========
      > > ' Windows Form Designer generated code
      > > ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
      > > '============== ========
      > >
      > > Public Class UserControl1
      > > Inherits System.Windows. Forms.UserContr ol
      > > Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
      > > MyBase.OnPaint( p)
      > > p.Graphics.Draw Line(New Pen(Color.Black ), _
      > > clientRectangle .Width, _
      > > ClientRectangle .Height, _
      > > 0, 0)
      > > End Sub
      > >
      > > Private Sub UserControl1_Lo ad(ByVal sender As System.Object, _
      > > ByVal e As System.EventArg s) _
      > > Handles MyBase.Load
      > > Me.BackColor = Color.Yellow
      > > End Sub
      > > End Class
      > >
      > >
      > > Private Sub Form1_Load(ByVa l sender As System.Object, _
      > > ByVal e As System.EventArg s) Handles MyBase.Load
      > > Dim uc As New UserControl1
      > > uc.Location = New Point(0, 0)
      > > uc.Size = New System.Drawing. Size(New Point(100, 100))
      > > uc.BackColor = Color.Yellow
      > > uc.AutoScroll = True
      > > uc.AutoScrollMi nSize = New Size(New Point(200, 300))
      > > uc.Visible = True
      > > Me.Controls.Add (uc)
      > > Size = New Size(New Point(300, 300))
      > >
      > > Dim lb As New Label
      > > lb.Location = New Point(0, 150)
      > > lb.Size = New Size(290, 80)
      > > lb.Text = "1.Move the scrollbars,the diagonal line isn't" + _
      > > " drawn from(0,0) to (width,height). 2.Minimize" + _
      > > " this form. 3. Restore the form size,now the " + _
      > > "line does go from (0,0) to (width,height). " + _
      > > "Why, why isn't the diagonal line and " + _
      > > "control background cleared as you scroll?"
      > > Me.Controls.Add (lb)
      > > End Sub
      > > End Class[/color]
      >
      >[/color]

      Comment

      • One Handed Man

        #4
        Re: Please help, more scrollbar questions. CODE INCLUDED.

        You need to repaint on VScroll. Your user control inherits from Scrollable
        class and this event is protected so as you have inherited this you should
        be able to add a handler and force the control to repaint.






        Colin McGuire wrote:[color=blue]
        > You're not going to make me thank you again I hope :)
        >
        > Here is some more elaboration of my problem.
        >
        > What I see is:
        >
        > 1. When I move the vertical scrollbar by clicking "in"
        > the scrollbar (ie between the up arrow and down arrow),
        > the diagonal line is drawn properly (diagram below).
        >
        > +----------+
        > |\ |
        > | \ |
        > | \ |
        > | \ |
        > | \ |
        > | \ |
        > | \ |
        > | \ |
        > | \ |
        > | \|
        > +----------+
        >
        > 2. When I click the "down arrow" button on the vertical
        > scrollbar, the diagonal scrolls, but I can see a tiny
        > bit of the new diagonal showing up - sort of looks like
        >
        > +---\-------+
        > | \ |
        > | \ |
        > | \ |
        > | \ |
        > | \ |
        > | \ |
        > | \|
        > | |
        > | |
        > | \|
        > +-----------+
        >
        > 3. When I add a Debug.WriteLine ("OnPaint") inside
        > the OnPaint method, both clicking "in" the scrollbar
        > and clicking the up or down arrow of the scrollbar
        > appear produce "OnPaint" in the IDE debug window.
        >
        > 4. When I minimise this (corrupted window, step 2), then
        > maximize it again, then it redraws properly with
        > the diagonal from (0,0) to (width,height) as shown
        > in Step 1.
        >
        > BTW: I forgot to paste in the
        >
        > p.Graphics.Clea r(BackColor)
        >
        > in my original post before the
        > p.Graphics.Draw Line .... but
        > it doesn't make any difference if I do.
        >
        > Thank you
        > Colin
        >
        >
        >
        >
        >
        >
        > "One Handed Man" <Bombay@Duck.ne t> wrote in message
        > news:blh02f$kg9 $1@hercules.bti nternet.com...[color=green]
        >> What happens then ?
        >>
        >>
        >> Colin McGuire wrote:[color=darkred]
        >>> I apologize for posting yet another scrollbar question. Here is my
        >>> code. All I want is for a diagonal line to appear from coordinates
        >>> (0,0) to (width,height) in a usercontrol regardless of whether the
        >>> user autoscrolls the usercontrol (other things that are on the
        >>> usercontrol I want to scroll, but haven't included any here).
        >>>
        >>> Here are the steps to reproduce my problem.
        >>>
        >>> 1. Launch Visual Studio and create a new Windows
        >>> application with "Form1".
        >>> 2. Paste the following in (remember to include
        >>> your "Windows Form Designer generated code).
        >>> 3. Run - instructions are in the program that runs.
        >>>
        >>> I am using "Microsoft Development Environment 2003, Version
        >>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
        >>> 1.1.4322"
        >>>
        >>> Thank you for your patience with me.
        >>> Colin
        >>>
        >>>
        >>>
        >>> Public Class Form1
        >>> Inherits System.Windows. Forms.Form
        >>>
        >>> '============== ========
        >>> ' Windows Form Designer generated code
        >>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
        >>> '============== ========
        >>>
        >>> Public Class UserControl1
        >>> Inherits System.Windows. Forms.UserContr ol
        >>> Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
        >>> MyBase.OnPaint( p)
        >>> p.Graphics.Draw Line(New Pen(Color.Black ), _
        >>> clientRectangle .Width, _
        >>> ClientRectangle .Height, _
        >>> 0, 0)
        >>> End Sub
        >>>
        >>> Private Sub UserControl1_Lo ad(ByVal sender As
        >>> System.Object, _ ByVal e As System.EventArg s) _
        >>> Handles MyBase.Load
        >>> Me.BackColor = Color.Yellow
        >>> End Sub
        >>> End Class
        >>>
        >>>
        >>> Private Sub Form1_Load(ByVa l sender As System.Object, _
        >>> ByVal e As System.EventArg s) Handles MyBase.Load
        >>> Dim uc As New UserControl1
        >>> uc.Location = New Point(0, 0)
        >>> uc.Size = New System.Drawing. Size(New Point(100, 100))
        >>> uc.BackColor = Color.Yellow
        >>> uc.AutoScroll = True
        >>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
        >>> uc.Visible = True
        >>> Me.Controls.Add (uc)
        >>> Size = New Size(New Point(300, 300))
        >>>
        >>> Dim lb As New Label
        >>> lb.Location = New Point(0, 150)
        >>> lb.Size = New Size(290, 80)
        >>> lb.Text = "1.Move the scrollbars,the diagonal line isn't" +
        >>> _ " drawn from(0,0) to (width,height).
        >>> 2.Minimize" + _ " this form. 3. Restore the form
        >>> size,now the " + _ "line does go from (0,0) to
        >>> (width,height). " + _ "Why, why isn't the
        >>> diagonal line and " + _ "control background
        >>> cleared as you scroll?" Me.Controls.Add (lb)
        >>> End Sub
        >>> End Class[/color][/color][/color]


        Comment

        • Colin McGuire

          #5
          Re: Please help, more scrollbar questions. CODE INCLUDED.

          OHM, I am sorry - I have seen this mentioned before and have never
          understood it. I know I'm close and the cigar eludes me. Any chance of
          coaching me on just a little further?


          Here is what I think what you mean from your latest post, and as I have
          implemented it is wrong because I get an a box showing up in my IDE saying
          "'VScroll' is not an event of WindowsApplicat ion15.Form1.Use rControl1'".

          What I did to my original code was

          Step 1: Added the following to UserControl1_Lo ad

          AddHandler VScroll, AddressOf capturedVScroll

          Step 2: Added the following to the code in UserControl1

          Private Sub capturedVScroll (ByVal sender As Object, _
          ByVal e As System.EventArg s)
          Debug.WriteLine ("capturedVScro ll")
          End Sub


          My final code therefore looks like this, but just one more tweak is
          necessary before I can get it to compile and work.

          Colin

          Public Class Form1
          Inherits System.Windows. Forms.Form

          '============== ========
          ' Windows Form Designer generated code
          ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
          '============== ========

          Public Class UserControl1
          Inherits System.Windows. Forms.UserContr ol
          Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
          MyBase.OnPaint( p)
          p.Graphics.Clea r(BackColor)
          p.Graphics.Draw Line(New Pen(Color.Black ), _
          clientRectangle .Width, _
          ClientRectangle .Height, _
          0, 0)
          End Sub

          Private Sub UserControl1_Lo ad(ByVal sender As System.Object, _
          ByVal e As System.EventArg s) _
          Handles MyBase.Load
          Me.BackColor = Color.Yellow
          AddHandler VScroll, AddressOf capturedVScroll 'ERROR HERE
          End Sub

          Private Sub capturedVScroll (ByVal sender As Object, _
          ByVal e As System.EventArg s)
          Debug.WriteLine ("capturedVScro ll")
          End Sub

          End Class


          Private Sub Form1_Load(ByVa l sender As System.Object, _
          ByVal e As System.EventArg s) Handles MyBase.Load
          Dim uc As New UserControl1
          uc.Location = New Point(0, 0)
          uc.Size = New System.Drawing. Size(New Point(100, 100))
          uc.BackColor = Color.Yellow
          uc.AutoScroll = True
          uc.AutoScrollMi nSize = New Size(New Point(200, 300))
          uc.Visible = True
          Me.Controls.Add (uc)
          Size = New Size(New Point(300, 300))

          Dim lb As New Label
          lb.Location = New Point(0, 150)
          lb.Size = New Size(290, 80)
          lb.Text = "1.Move the scrollbars,the diagonal line isn't" + _
          " drawn from(0,0) to (width,height). 2.Minimize" + _
          " this form. 3. Restore the form size,now the " + _
          "line does go from (0,0) to (width,height). " + _
          "Why, why isn't the diagonal line and " + _
          "control background cleared as you scroll?"
          Me.Controls.Add (lb)
          End Sub
          End Class



          "One Handed Man" <Bombay@Duck.ne t> wrote in message
          news:blh8sf$k5k $1@titan.btinte rnet.com...[color=blue]
          > You need to repaint on VScroll. Your user control inherits from[/color]
          Scrollable[color=blue]
          > class and this event is protected so as you have inherited this you should
          > be able to add a handler and force the control to repaint.
          >
          >
          >
          >
          >
          >
          > Colin McGuire wrote:[color=green]
          > > You're not going to make me thank you again I hope :)
          > >
          > > Here is some more elaboration of my problem.
          > >
          > > What I see is:
          > >
          > > 1. When I move the vertical scrollbar by clicking "in"
          > > the scrollbar (ie between the up arrow and down arrow),
          > > the diagonal line is drawn properly (diagram below).
          > >
          > > +----------+
          > > |\ |
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \|
          > > +----------+
          > >
          > > 2. When I click the "down arrow" button on the vertical
          > > scrollbar, the diagonal scrolls, but I can see a tiny
          > > bit of the new diagonal showing up - sort of looks like
          > >
          > > +---\-------+
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \ |
          > > | \|
          > > | |
          > > | |
          > > | \|
          > > +-----------+
          > >
          > > 3. When I add a Debug.WriteLine ("OnPaint") inside
          > > the OnPaint method, both clicking "in" the scrollbar
          > > and clicking the up or down arrow of the scrollbar
          > > appear produce "OnPaint" in the IDE debug window.
          > >
          > > 4. When I minimise this (corrupted window, step 2), then
          > > maximize it again, then it redraws properly with
          > > the diagonal from (0,0) to (width,height) as shown
          > > in Step 1.
          > >
          > > BTW: I forgot to paste in the
          > >
          > > p.Graphics.Clea r(BackColor)
          > >
          > > in my original post before the
          > > p.Graphics.Draw Line .... but
          > > it doesn't make any difference if I do.
          > >
          > > Thank you
          > > Colin
          > >
          > >
          > >
          > >
          > >
          > >
          > > "One Handed Man" <Bombay@Duck.ne t> wrote in message
          > > news:blh02f$kg9 $1@hercules.bti nternet.com...[color=darkred]
          > >> What happens then ?
          > >>
          > >>
          > >> Colin McGuire wrote:
          > >>> I apologize for posting yet another scrollbar question. Here is my
          > >>> code. All I want is for a diagonal line to appear from coordinates
          > >>> (0,0) to (width,height) in a usercontrol regardless of whether the
          > >>> user autoscrolls the usercontrol (other things that are on the
          > >>> usercontrol I want to scroll, but haven't included any here).
          > >>>
          > >>> Here are the steps to reproduce my problem.
          > >>>
          > >>> 1. Launch Visual Studio and create a new Windows
          > >>> application with "Form1".
          > >>> 2. Paste the following in (remember to include
          > >>> your "Windows Form Designer generated code).
          > >>> 3. Run - instructions are in the program that runs.
          > >>>
          > >>> I am using "Microsoft Development Environment 2003, Version
          > >>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
          > >>> 1.1.4322"
          > >>>
          > >>> Thank you for your patience with me.
          > >>> Colin
          > >>>
          > >>>
          > >>>
          > >>> Public Class Form1
          > >>> Inherits System.Windows. Forms.Form
          > >>>
          > >>> '============== ========
          > >>> ' Windows Form Designer generated code
          > >>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
          > >>> '============== ========
          > >>>
          > >>> Public Class UserControl1
          > >>> Inherits System.Windows. Forms.UserContr ol
          > >>> Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
          > >>> MyBase.OnPaint( p)
          > >>> p.Graphics.Draw Line(New Pen(Color.Black ), _
          > >>> clientRectangle .Width, _
          > >>> ClientRectangle .Height, _
          > >>> 0, 0)
          > >>> End Sub
          > >>>
          > >>> Private Sub UserControl1_Lo ad(ByVal sender As
          > >>> System.Object, _ ByVal e As System.EventArg s) _
          > >>> Handles MyBase.Load
          > >>> Me.BackColor = Color.Yellow
          > >>> End Sub
          > >>> End Class
          > >>>
          > >>>
          > >>> Private Sub Form1_Load(ByVa l sender As System.Object, _
          > >>> ByVal e As System.EventArg s) Handles MyBase.Load
          > >>> Dim uc As New UserControl1
          > >>> uc.Location = New Point(0, 0)
          > >>> uc.Size = New System.Drawing. Size(New Point(100, 100))
          > >>> uc.BackColor = Color.Yellow
          > >>> uc.AutoScroll = True
          > >>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
          > >>> uc.Visible = True
          > >>> Me.Controls.Add (uc)
          > >>> Size = New Size(New Point(300, 300))
          > >>>
          > >>> Dim lb As New Label
          > >>> lb.Location = New Point(0, 150)
          > >>> lb.Size = New Size(290, 80)
          > >>> lb.Text = "1.Move the scrollbars,the diagonal line isn't" +
          > >>> _ " drawn from(0,0) to (width,height).
          > >>> 2.Minimize" + _ " this form. 3. Restore the form
          > >>> size,now the " + _ "line does go from (0,0) to
          > >>> (width,height). " + _ "Why, why isn't the
          > >>> diagonal line and " + _ "control background
          > >>> cleared as you scroll?" Me.Controls.Add (lb)
          > >>> End Sub
          > >>> End Class[/color][/color]
          >
          >[/color]

          Comment

          • One Handed Man

            #6
            Re: Please help, more scrollbar questions. CODE INCLUDED.

            Actually, I was wrong. It is not an event. However, logic tells us that an
            event has taken place because otherwise it could not have scrolled.

            I suggest you post this exact question as a new thread and this will get you
            your answer. I dont know it at present.





            Colin McGuire wrote:[color=blue]
            > OHM, I am sorry - I have seen this mentioned before and have never
            > understood it. I know I'm close and the cigar eludes me. Any chance of
            > coaching me on just a little further?
            >
            >
            > Here is what I think what you mean from your latest post, and as I
            > have implemented it is wrong because I get an a box showing up in my
            > IDE saying "'VScroll' is not an event of
            > WindowsApplicat ion15.Form1.Use rControl1'".
            >
            > What I did to my original code was
            >
            > Step 1: Added the following to UserControl1_Lo ad
            >
            > AddHandler VScroll, AddressOf capturedVScroll
            >
            > Step 2: Added the following to the code in UserControl1
            >
            > Private Sub capturedVScroll (ByVal sender As Object, _
            > ByVal e As System.EventArg s)
            > Debug.WriteLine ("capturedVScro ll")
            > End Sub
            >
            >
            > My final code therefore looks like this, but just one more tweak is
            > necessary before I can get it to compile and work.
            >
            > Colin
            >
            > Public Class Form1
            > Inherits System.Windows. Forms.Form
            >
            > '============== ========
            > ' Windows Form Designer generated code
            > ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
            > '============== ========
            >
            > Public Class UserControl1
            > Inherits System.Windows. Forms.UserContr ol
            > Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
            > MyBase.OnPaint( p)
            > p.Graphics.Clea r(BackColor)
            > p.Graphics.Draw Line(New Pen(Color.Black ), _
            > clientRectangle .Width, _
            > ClientRectangle .Height, _
            > 0, 0)
            > End Sub
            >
            > Private Sub UserControl1_Lo ad(ByVal sender As System.Object, _
            > ByVal e As System.EventArg s) _
            > Handles MyBase.Load
            > Me.BackColor = Color.Yellow
            > AddHandler VScroll, AddressOf capturedVScroll 'ERROR HERE
            > End Sub
            >
            > Private Sub capturedVScroll (ByVal sender As Object, _
            > ByVal e As System.EventArg s)
            > Debug.WriteLine ("capturedVScro ll")
            > End Sub
            >
            > End Class
            >
            >
            > Private Sub Form1_Load(ByVa l sender As System.Object, _
            > ByVal e As System.EventArg s) Handles MyBase.Load
            > Dim uc As New UserControl1
            > uc.Location = New Point(0, 0)
            > uc.Size = New System.Drawing. Size(New Point(100, 100))
            > uc.BackColor = Color.Yellow
            > uc.AutoScroll = True
            > uc.AutoScrollMi nSize = New Size(New Point(200, 300))
            > uc.Visible = True
            > Me.Controls.Add (uc)
            > Size = New Size(New Point(300, 300))
            >
            > Dim lb As New Label
            > lb.Location = New Point(0, 150)
            > lb.Size = New Size(290, 80)
            > lb.Text = "1.Move the scrollbars,the diagonal line isn't" + _
            > " drawn from(0,0) to (width,height). 2.Minimize" + _
            > " this form. 3. Restore the form size,now the " + _
            > "line does go from (0,0) to (width,height). " + _
            > "Why, why isn't the diagonal line and " + _
            > "control background cleared as you scroll?"
            > Me.Controls.Add (lb)
            > End Sub
            > End Class
            >
            >
            >
            > "One Handed Man" <Bombay@Duck.ne t> wrote in message
            > news:blh8sf$k5k $1@titan.btinte rnet.com...[color=green]
            >> You need to repaint on VScroll. Your user control inherits from
            >> Scrollable class and this event is protected so as you have
            >> inherited this you should be able to add a handler and force the
            >> control to repaint.
            >>
            >>
            >>
            >>
            >>
            >>
            >> Colin McGuire wrote:[color=darkred]
            >>> You're not going to make me thank you again I hope :)
            >>>
            >>> Here is some more elaboration of my problem.
            >>>
            >>> What I see is:
            >>>
            >>> 1. When I move the vertical scrollbar by clicking "in"
            >>> the scrollbar (ie between the up arrow and down arrow),
            >>> the diagonal line is drawn properly (diagram below).
            >>>
            >>> +----------+
            >>> |\ |
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \|
            >>> +----------+
            >>>
            >>> 2. When I click the "down arrow" button on the vertical
            >>> scrollbar, the diagonal scrolls, but I can see a tiny
            >>> bit of the new diagonal showing up - sort of looks like
            >>>
            >>> +---\-------+
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \ |
            >>> | \|
            >>> | |
            >>> | |
            >>> | \|
            >>> +-----------+
            >>>
            >>> 3. When I add a Debug.WriteLine ("OnPaint") inside
            >>> the OnPaint method, both clicking "in" the scrollbar
            >>> and clicking the up or down arrow of the scrollbar
            >>> appear produce "OnPaint" in the IDE debug window.
            >>>
            >>> 4. When I minimise this (corrupted window, step 2), then
            >>> maximize it again, then it redraws properly with
            >>> the diagonal from (0,0) to (width,height) as shown
            >>> in Step 1.
            >>>
            >>> BTW: I forgot to paste in the
            >>>
            >>> p.Graphics.Clea r(BackColor)
            >>>
            >>> in my original post before the
            >>> p.Graphics.Draw Line .... but
            >>> it doesn't make any difference if I do.
            >>>
            >>> Thank you
            >>> Colin
            >>>
            >>>
            >>>
            >>>
            >>>
            >>>
            >>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
            >>> news:blh02f$kg9 $1@hercules.bti nternet.com...
            >>>> What happens then ?
            >>>>
            >>>>
            >>>> Colin McGuire wrote:
            >>>>> I apologize for posting yet another scrollbar question. Here is my
            >>>>> code. All I want is for a diagonal line to appear from coordinates
            >>>>> (0,0) to (width,height) in a usercontrol regardless of whether the
            >>>>> user autoscrolls the usercontrol (other things that are on the
            >>>>> usercontrol I want to scroll, but haven't included any here).
            >>>>>
            >>>>> Here are the steps to reproduce my problem.
            >>>>>
            >>>>> 1. Launch Visual Studio and create a new Windows
            >>>>> application with "Form1".
            >>>>> 2. Paste the following in (remember to include
            >>>>> your "Windows Form Designer generated code).
            >>>>> 3. Run - instructions are in the program that runs.
            >>>>>
            >>>>> I am using "Microsoft Development Environment 2003, Version
            >>>>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
            >>>>> 1.1.4322"
            >>>>>
            >>>>> Thank you for your patience with me.
            >>>>> Colin
            >>>>>
            >>>>>
            >>>>>
            >>>>> Public Class Form1
            >>>>> Inherits System.Windows. Forms.Form
            >>>>>
            >>>>> '============== ========
            >>>>> ' Windows Form Designer generated code
            >>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
            >>>>> '============== ========
            >>>>>
            >>>>> Public Class UserControl1
            >>>>> Inherits System.Windows. Forms.UserContr ol
            >>>>> Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
            >>>>> MyBase.OnPaint( p)
            >>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
            >>>>> clientRectangle .Width, _
            >>>>> ClientRectangle .Height, _
            >>>>> 0, 0)
            >>>>> End Sub
            >>>>>
            >>>>> Private Sub UserControl1_Lo ad(ByVal sender As
            >>>>> System.Object, _ ByVal e As System.EventArg s) _
            >>>>> Handles MyBase.Load
            >>>>> Me.BackColor = Color.Yellow
            >>>>> End Sub
            >>>>> End Class
            >>>>>
            >>>>>
            >>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
            >>>>> ByVal e As System.EventArg s) Handles MyBase.Load
            >>>>> Dim uc As New UserControl1
            >>>>> uc.Location = New Point(0, 0)
            >>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
            >>>>> uc.BackColor = Color.Yellow
            >>>>> uc.AutoScroll = True
            >>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
            >>>>> uc.Visible = True
            >>>>> Me.Controls.Add (uc)
            >>>>> Size = New Size(New Point(300, 300))
            >>>>>
            >>>>> Dim lb As New Label
            >>>>> lb.Location = New Point(0, 150)
            >>>>> lb.Size = New Size(290, 80)
            >>>>> lb.Text = "1.Move the scrollbars,the diagonal line isn't"
            >>>>> + _ " drawn from(0,0) to (width,height).
            >>>>> 2.Minimize" + _ " this form. 3. Restore the form
            >>>>> size,now the " + _ "line does go from (0,0) to
            >>>>> (width,height). " + _ "Why, why isn't the
            >>>>> diagonal line and " + _ "control background
            >>>>> cleared as you scroll?" Me.Controls.Add (lb)
            >>>>> End Sub
            >>>>> End Class[/color][/color][/color]


            Comment

            • hexathioorthooxalate

              #7
              Re: Please help, more scrollbar questions. CODE INCLUDED.

              Paste the following code into UserControl1
              Hexathioorthoox alate


              'Putting a Debug.WriteLine (m.ToString) in the subroutine below
              'shows that the order that messages are received/processed is
              'WM_PAINT and then WM_XSCROLL. The usercontrol appears to be
              'being painted first, and then scrolled, and this is why you
              'are not seeing the diagonal. This code will ensure that
              'after a scroll, a repaint (through Invalidate()) will
              'occur - messy and probably overkill but I cannot currently
              'see another way around your dilemma.

              Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
              MyBase.WndProc( m)
              '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
              If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
              End Sub




              "One Handed Man" <Bombay@Duck.ne t> wrote in message
              news:blhd4a$hv6 $1@hercules.bti nternet.com...[color=blue]
              > Actually, I was wrong. It is not an event. However, logic tells us that an
              > event has taken place because otherwise it could not have scrolled.
              >
              > I suggest you post this exact question as a new thread and this will get[/color]
              you[color=blue]
              > your answer. I dont know it at present.
              >
              >
              >
              >
              >
              > Colin McGuire wrote:[color=green]
              > > OHM, I am sorry - I have seen this mentioned before and have never
              > > understood it. I know I'm close and the cigar eludes me. Any chance of
              > > coaching me on just a little further?
              > >
              > >
              > > Here is what I think what you mean from your latest post, and as I
              > > have implemented it is wrong because I get an a box showing up in my
              > > IDE saying "'VScroll' is not an event of
              > > WindowsApplicat ion15.Form1.Use rControl1'".
              > >
              > > What I did to my original code was
              > >
              > > Step 1: Added the following to UserControl1_Lo ad
              > >
              > > AddHandler VScroll, AddressOf capturedVScroll
              > >
              > > Step 2: Added the following to the code in UserControl1
              > >
              > > Private Sub capturedVScroll (ByVal sender As Object, _
              > > ByVal e As System.EventArg s)
              > > Debug.WriteLine ("capturedVScro ll")
              > > End Sub
              > >
              > >
              > > My final code therefore looks like this, but just one more tweak is
              > > necessary before I can get it to compile and work.
              > >
              > > Colin
              > >
              > > Public Class Form1
              > > Inherits System.Windows. Forms.Form
              > >
              > > '============== ========
              > > ' Windows Form Designer generated code
              > > ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
              > > '============== ========
              > >
              > > Public Class UserControl1
              > > Inherits System.Windows. Forms.UserContr ol
              > > Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
              > > MyBase.OnPaint( p)
              > > p.Graphics.Clea r(BackColor)
              > > p.Graphics.Draw Line(New Pen(Color.Black ), _
              > > clientRectangle .Width, _
              > > ClientRectangle .Height, _
              > > 0, 0)
              > > End Sub
              > >
              > > Private Sub UserControl1_Lo ad(ByVal sender As System.Object, _
              > > ByVal e As System.EventArg s) _
              > > Handles MyBase.Load
              > > Me.BackColor = Color.Yellow
              > > AddHandler VScroll, AddressOf capturedVScroll 'ERROR HERE
              > > End Sub
              > >
              > > Private Sub capturedVScroll (ByVal sender As Object, _
              > > ByVal e As System.EventArg s)
              > > Debug.WriteLine ("capturedVScro ll")
              > > End Sub
              > >
              > > End Class
              > >
              > >
              > > Private Sub Form1_Load(ByVa l sender As System.Object, _
              > > ByVal e As System.EventArg s) Handles MyBase.Load
              > > Dim uc As New UserControl1
              > > uc.Location = New Point(0, 0)
              > > uc.Size = New System.Drawing. Size(New Point(100, 100))
              > > uc.BackColor = Color.Yellow
              > > uc.AutoScroll = True
              > > uc.AutoScrollMi nSize = New Size(New Point(200, 300))
              > > uc.Visible = True
              > > Me.Controls.Add (uc)
              > > Size = New Size(New Point(300, 300))
              > >
              > > Dim lb As New Label
              > > lb.Location = New Point(0, 150)
              > > lb.Size = New Size(290, 80)
              > > lb.Text = "1.Move the scrollbars,the diagonal line isn't" + _
              > > " drawn from(0,0) to (width,height). 2.Minimize" + _
              > > " this form. 3. Restore the form size,now the " + _
              > > "line does go from (0,0) to (width,height). " + _
              > > "Why, why isn't the diagonal line and " + _
              > > "control background cleared as you scroll?"
              > > Me.Controls.Add (lb)
              > > End Sub
              > > End Class
              > >
              > >
              > >
              > > "One Handed Man" <Bombay@Duck.ne t> wrote in message
              > > news:blh8sf$k5k $1@titan.btinte rnet.com...[color=darkred]
              > >> You need to repaint on VScroll. Your user control inherits from
              > >> Scrollable class and this event is protected so as you have
              > >> inherited this you should be able to add a handler and force the
              > >> control to repaint.
              > >>
              > >>
              > >>
              > >>
              > >>
              > >>
              > >> Colin McGuire wrote:
              > >>> You're not going to make me thank you again I hope :)
              > >>>
              > >>> Here is some more elaboration of my problem.
              > >>>
              > >>> What I see is:
              > >>>
              > >>> 1. When I move the vertical scrollbar by clicking "in"
              > >>> the scrollbar (ie between the up arrow and down arrow),
              > >>> the diagonal line is drawn properly (diagram below).
              > >>>
              > >>> +----------+
              > >>> |\ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \|
              > >>> +----------+
              > >>>
              > >>> 2. When I click the "down arrow" button on the vertical
              > >>> scrollbar, the diagonal scrolls, but I can see a tiny
              > >>> bit of the new diagonal showing up - sort of looks like
              > >>>
              > >>> +---\-------+
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \ |
              > >>> | \|
              > >>> | |
              > >>> | |
              > >>> | \|
              > >>> +-----------+
              > >>>
              > >>> 3. When I add a Debug.WriteLine ("OnPaint") inside
              > >>> the OnPaint method, both clicking "in" the scrollbar
              > >>> and clicking the up or down arrow of the scrollbar
              > >>> appear produce "OnPaint" in the IDE debug window.
              > >>>
              > >>> 4. When I minimise this (corrupted window, step 2), then
              > >>> maximize it again, then it redraws properly with
              > >>> the diagonal from (0,0) to (width,height) as shown
              > >>> in Step 1.
              > >>>
              > >>> BTW: I forgot to paste in the
              > >>>
              > >>> p.Graphics.Clea r(BackColor)
              > >>>
              > >>> in my original post before the
              > >>> p.Graphics.Draw Line .... but
              > >>> it doesn't make any difference if I do.
              > >>>
              > >>> Thank you
              > >>> Colin
              > >>>
              > >>>
              > >>>
              > >>>
              > >>>
              > >>>
              > >>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
              > >>> news:blh02f$kg9 $1@hercules.bti nternet.com...
              > >>>> What happens then ?
              > >>>>
              > >>>>
              > >>>> Colin McGuire wrote:
              > >>>>> I apologize for posting yet another scrollbar question. Here is my
              > >>>>> code. All I want is for a diagonal line to appear from coordinates
              > >>>>> (0,0) to (width,height) in a usercontrol regardless of whether the
              > >>>>> user autoscrolls the usercontrol (other things that are on the
              > >>>>> usercontrol I want to scroll, but haven't included any here).
              > >>>>>
              > >>>>> Here are the steps to reproduce my problem.
              > >>>>>
              > >>>>> 1. Launch Visual Studio and create a new Windows
              > >>>>> application with "Form1".
              > >>>>> 2. Paste the following in (remember to include
              > >>>>> your "Windows Form Designer generated code).
              > >>>>> 3. Run - instructions are in the program that runs.
              > >>>>>
              > >>>>> I am using "Microsoft Development Environment 2003, Version
              > >>>>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
              > >>>>> 1.1.4322"
              > >>>>>
              > >>>>> Thank you for your patience with me.
              > >>>>> Colin
              > >>>>>
              > >>>>>
              > >>>>>
              > >>>>> Public Class Form1
              > >>>>> Inherits System.Windows. Forms.Form
              > >>>>>
              > >>>>> '============== ========
              > >>>>> ' Windows Form Designer generated code
              > >>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
              > >>>>> '============== ========
              > >>>>>
              > >>>>> Public Class UserControl1
              > >>>>> Inherits System.Windows. Forms.UserContr ol
              > >>>>> Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
              > >>>>> MyBase.OnPaint( p)
              > >>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
              > >>>>> clientRectangle .Width, _
              > >>>>> ClientRectangle .Height, _
              > >>>>> 0, 0)
              > >>>>> End Sub
              > >>>>>
              > >>>>> Private Sub UserControl1_Lo ad(ByVal sender As
              > >>>>> System.Object, _ ByVal e As System.EventArg s) _
              > >>>>> Handles MyBase.Load
              > >>>>> Me.BackColor = Color.Yellow
              > >>>>> End Sub
              > >>>>> End Class
              > >>>>>
              > >>>>>
              > >>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
              > >>>>> ByVal e As System.EventArg s) Handles MyBase.Load
              > >>>>> Dim uc As New UserControl1
              > >>>>> uc.Location = New Point(0, 0)
              > >>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
              > >>>>> uc.BackColor = Color.Yellow
              > >>>>> uc.AutoScroll = True
              > >>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
              > >>>>> uc.Visible = True
              > >>>>> Me.Controls.Add (uc)
              > >>>>> Size = New Size(New Point(300, 300))
              > >>>>>
              > >>>>> Dim lb As New Label
              > >>>>> lb.Location = New Point(0, 150)
              > >>>>> lb.Size = New Size(290, 80)
              > >>>>> lb.Text = "1.Move the scrollbars,the diagonal line isn't"
              > >>>>> + _ " drawn from(0,0) to (width,height).
              > >>>>> 2.Minimize" + _ " this form. 3. Restore the form
              > >>>>> size,now the " + _ "line does go from (0,0) to
              > >>>>> (width,height). " + _ "Why, why isn't the
              > >>>>> diagonal line and " + _ "control background
              > >>>>> cleared as you scroll?" Me.Controls.Add (lb)
              > >>>>> End Sub
              > >>>>> End Class[/color][/color]
              >
              >[/color]

              Comment

              • One Handed Man

                #8
                Re: Please help, more scrollbar questions. CODE INCLUDED.

                This is not a workable solution. The reason being that once you invalidate ,
                it causes a paint event, which causes . . . . Flashing forms, lines etc

                Recursive.

                OHM


                hexathioorthoox alate wrote:[color=blue]
                > Paste the following code into UserControl1
                > Hexathioorthoox alate
                >
                >
                > 'Putting a Debug.WriteLine (m.ToString) in the subroutine below
                > 'shows that the order that messages are received/processed is
                > 'WM_PAINT and then WM_XSCROLL. The usercontrol appears to be
                > 'being painted first, and then scrolled, and this is why you
                > 'are not seeing the diagonal. This code will ensure that
                > 'after a scroll, a repaint (through Invalidate()) will
                > 'occur - messy and probably overkill but I cannot currently
                > 'see another way around your dilemma.
                >
                > Protected Overrides Sub WndProc(ByRef m As
                > System.Windows. Forms.Message) MyBase.WndProc( m)
                > '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                > If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                > End Sub
                >
                >
                >
                >
                > "One Handed Man" <Bombay@Duck.ne t> wrote in message
                > news:blhd4a$hv6 $1@hercules.bti nternet.com...[color=green]
                >> Actually, I was wrong. It is not an event. However, logic tells us
                >> that an event has taken place because otherwise it could not have
                >> scrolled.
                >>
                >> I suggest you post this exact question as a new thread and this will
                >> get you your answer. I dont know it at present.
                >>
                >>
                >>
                >>
                >>
                >> Colin McGuire wrote:[color=darkred]
                >>> OHM, I am sorry - I have seen this mentioned before and have never
                >>> understood it. I know I'm close and the cigar eludes me. Any chance
                >>> of coaching me on just a little further?
                >>>
                >>>
                >>> Here is what I think what you mean from your latest post, and as I
                >>> have implemented it is wrong because I get an a box showing up in my
                >>> IDE saying "'VScroll' is not an event of
                >>> WindowsApplicat ion15.Form1.Use rControl1'".
                >>>
                >>> What I did to my original code was
                >>>
                >>> Step 1: Added the following to UserControl1_Lo ad
                >>>
                >>> AddHandler VScroll, AddressOf capturedVScroll
                >>>
                >>> Step 2: Added the following to the code in UserControl1
                >>>
                >>> Private Sub capturedVScroll (ByVal sender As Object, _
                >>> ByVal e As System.EventArg s)
                >>> Debug.WriteLine ("capturedVScro ll")
                >>> End Sub
                >>>
                >>>
                >>> My final code therefore looks like this, but just one more tweak is
                >>> necessary before I can get it to compile and work.
                >>>
                >>> Colin
                >>>
                >>> Public Class Form1
                >>> Inherits System.Windows. Forms.Form
                >>>
                >>> '============== ========
                >>> ' Windows Form Designer generated code
                >>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                >>> '============== ========
                >>>
                >>> Public Class UserControl1
                >>> Inherits System.Windows. Forms.UserContr ol
                >>> Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
                >>> MyBase.OnPaint( p)
                >>> p.Graphics.Clea r(BackColor)
                >>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                >>> clientRectangle .Width, _
                >>> ClientRectangle .Height, _
                >>> 0, 0)
                >>> End Sub
                >>>
                >>> Private Sub UserControl1_Lo ad(ByVal sender As
                >>> System.Object, _ ByVal e As System.EventArg s) _
                >>> Handles MyBase.Load
                >>> Me.BackColor = Color.Yellow
                >>> AddHandler VScroll, AddressOf capturedVScroll 'ERROR
                >>> HERE End Sub
                >>>
                >>> Private Sub capturedVScroll (ByVal sender As Object, _
                >>> ByVal e As System.EventArg s)
                >>> Debug.WriteLine ("capturedVScro ll")
                >>> End Sub
                >>>
                >>> End Class
                >>>
                >>>
                >>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                >>> ByVal e As System.EventArg s) Handles MyBase.Load
                >>> Dim uc As New UserControl1
                >>> uc.Location = New Point(0, 0)
                >>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                >>> uc.BackColor = Color.Yellow
                >>> uc.AutoScroll = True
                >>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                >>> uc.Visible = True
                >>> Me.Controls.Add (uc)
                >>> Size = New Size(New Point(300, 300))
                >>>
                >>> Dim lb As New Label
                >>> lb.Location = New Point(0, 150)
                >>> lb.Size = New Size(290, 80)
                >>> lb.Text = "1.Move the scrollbars,the diagonal line isn't" +
                >>> _ " drawn from(0,0) to (width,height).
                >>> 2.Minimize" + _ " this form. 3. Restore the form
                >>> size,now the " + _ "line does go from (0,0) to
                >>> (width,height). " + _ "Why, why isn't the
                >>> diagonal line and " + _ "control background
                >>> cleared as you scroll?" Me.Controls.Add (lb)
                >>> End Sub
                >>> End Class
                >>>
                >>>
                >>>
                >>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                >>> news:blh8sf$k5k $1@titan.btinte rnet.com...
                >>>> You need to repaint on VScroll. Your user control inherits from
                >>>> Scrollable class and this event is protected so as you have
                >>>> inherited this you should be able to add a handler and force the
                >>>> control to repaint.
                >>>>
                >>>>
                >>>>
                >>>>
                >>>>
                >>>>
                >>>> Colin McGuire wrote:
                >>>>> You're not going to make me thank you again I hope :)
                >>>>>
                >>>>> Here is some more elaboration of my problem.
                >>>>>
                >>>>> What I see is:
                >>>>>
                >>>>> 1. When I move the vertical scrollbar by clicking "in"
                >>>>> the scrollbar (ie between the up arrow and down arrow),
                >>>>> the diagonal line is drawn properly (diagram below).
                >>>>>
                >>>>> +----------+
                >>>>> |\ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \|
                >>>>> +----------+
                >>>>>
                >>>>> 2. When I click the "down arrow" button on the vertical
                >>>>> scrollbar, the diagonal scrolls, but I can see a tiny
                >>>>> bit of the new diagonal showing up - sort of looks like
                >>>>>
                >>>>> +---\-------+
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \ |
                >>>>> | \|
                >>>>> | |
                >>>>> | |
                >>>>> | \|
                >>>>> +-----------+
                >>>>>
                >>>>> 3. When I add a Debug.WriteLine ("OnPaint") inside
                >>>>> the OnPaint method, both clicking "in" the scrollbar
                >>>>> and clicking the up or down arrow of the scrollbar
                >>>>> appear produce "OnPaint" in the IDE debug window.
                >>>>>
                >>>>> 4. When I minimise this (corrupted window, step 2), then
                >>>>> maximize it again, then it redraws properly with
                >>>>> the diagonal from (0,0) to (width,height) as shown
                >>>>> in Step 1.
                >>>>>
                >>>>> BTW: I forgot to paste in the
                >>>>>
                >>>>> p.Graphics.Clea r(BackColor)
                >>>>>
                >>>>> in my original post before the
                >>>>> p.Graphics.Draw Line .... but
                >>>>> it doesn't make any difference if I do.
                >>>>>
                >>>>> Thank you
                >>>>> Colin
                >>>>>
                >>>>>
                >>>>>
                >>>>>
                >>>>>
                >>>>>
                >>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                >>>>> news:blh02f$kg9 $1@hercules.bti nternet.com...
                >>>>>> What happens then ?
                >>>>>>
                >>>>>>
                >>>>>> Colin McGuire wrote:
                >>>>>>> I apologize for posting yet another scrollbar question. Here is
                >>>>>>> my code. All I want is for a diagonal line to appear from
                >>>>>>> coordinates (0,0) to (width,height) in a usercontrol regardless
                >>>>>>> of whether the user autoscrolls the usercontrol (other things
                >>>>>>> that are on the usercontrol I want to scroll, but haven't
                >>>>>>> included any here).
                >>>>>>>
                >>>>>>> Here are the steps to reproduce my problem.
                >>>>>>>
                >>>>>>> 1. Launch Visual Studio and create a new Windows
                >>>>>>> application with "Form1".
                >>>>>>> 2. Paste the following in (remember to include
                >>>>>>> your "Windows Form Designer generated code).
                >>>>>>> 3. Run - instructions are in the program that runs.
                >>>>>>>
                >>>>>>> I am using "Microsoft Development Environment 2003, Version
                >>>>>>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
                >>>>>>> 1.1.4322"
                >>>>>>>
                >>>>>>> Thank you for your patience with me.
                >>>>>>> Colin
                >>>>>>>
                >>>>>>>
                >>>>>>>
                >>>>>>> Public Class Form1
                >>>>>>> Inherits System.Windows. Forms.Form
                >>>>>>>
                >>>>>>> '============== ========
                >>>>>>> ' Windows Form Designer generated code
                >>>>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                >>>>>>> '============== ========
                >>>>>>>
                >>>>>>> Public Class UserControl1
                >>>>>>> Inherits System.Windows. Forms.UserContr ol
                >>>>>>> Protected Overrides Sub OnPaint(ByVal p As
                >>>>>>> PaintEventArgs) MyBase.OnPaint( p)
                >>>>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                >>>>>>> clientRectangle .Width, _
                >>>>>>> ClientRectangle .Height, _
                >>>>>>> 0, 0)
                >>>>>>> End Sub
                >>>>>>>
                >>>>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                >>>>>>> System.Object, _ ByVal e As System.EventArg s) _
                >>>>>>> Handles MyBase.Load
                >>>>>>> Me.BackColor = Color.Yellow
                >>>>>>> End Sub
                >>>>>>> End Class
                >>>>>>>
                >>>>>>>
                >>>>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                >>>>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                >>>>>>> Dim uc As New UserControl1
                >>>>>>> uc.Location = New Point(0, 0)
                >>>>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                >>>>>>> uc.BackColor = Color.Yellow
                >>>>>>> uc.AutoScroll = True
                >>>>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                >>>>>>> uc.Visible = True
                >>>>>>> Me.Controls.Add (uc)
                >>>>>>> Size = New Size(New Point(300, 300))
                >>>>>>>
                >>>>>>> Dim lb As New Label
                >>>>>>> lb.Location = New Point(0, 150)
                >>>>>>> lb.Size = New Size(290, 80)
                >>>>>>> lb.Text = "1.Move the scrollbars,the diagonal line
                >>>>>>> isn't" + _ " drawn from(0,0) to
                >>>>>>> (width,height).
                >>>>>>> 2.Minimize" + _ " this form. 3. Restore the
                >>>>>>> form size,now the " + _ "line does go from
                >>>>>>> (0,0) to (width,height). " + _ "Why, why
                >>>>>>> isn't the diagonal line and " + _ "control
                >>>>>>> background cleared as you scroll?" Me.Controls.Add (lb)
                >>>>>>> End Sub
                >>>>>>> End Class[/color][/color][/color]


                Comment

                • Brian

                  #9
                  Re: Please help, more scrollbar questions. CODE INCLUDED.

                  Colin, put this in your New()

                  Me.SetStyle(Con trolStyles.Doub leBuffer, True)
                  Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
                  Me.SetStyle(Con trolStyles.AllP aintingInWmPain t, True)
                  Me.SetStyle(Con trolStyles.User Paint, True)



                  Tihis will force the control to repaint the entire surface. What is
                  happening is that your control is painting only the uncover part and not the
                  whole window.







                  "Colin McGuire" <colinandkaren@ lycos.co.uk> wrote in message
                  news:ab6cea37.0 310020025.411e8 137@posting.goo gle.com...[color=blue]
                  > I apologize for posting yet another scrollbar question. Here is my
                  > code. All I want is for a diagonal line to appear from coordinates
                  > (0,0) to (width,height) in a usercontrol regardless of whether the
                  > user autoscrolls the usercontrol (other things that are on the
                  > usercontrol I want to scroll, but haven't included any here).
                  >
                  > Here are the steps to reproduce my problem.
                  >
                  > 1. Launch Visual Studio and create a new Windows
                  > application with "Form1".
                  > 2. Paste the following in (remember to include
                  > your "Windows Form Designer generated code).
                  > 3. Run - instructions are in the program that runs.
                  >
                  > I am using "Microsoft Development Environment 2003, Version 7.1.3088".
                  > I am using "Microsoft .NET Framework 1.1, Version 1.1.4322"
                  >
                  > Thank you for your patience with me.
                  > Colin
                  >
                  >
                  >
                  > Public Class Form1
                  > Inherits System.Windows. Forms.Form
                  >
                  > '============== ========
                  > ' Windows Form Designer generated code
                  > ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                  > '============== ========
                  >
                  > Public Class UserControl1
                  > Inherits System.Windows. Forms.UserContr ol
                  > Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
                  > MyBase.OnPaint( p)
                  > p.Graphics.Draw Line(New Pen(Color.Black ), _
                  > clientRectangle .Width, _
                  > ClientRectangle .Height, _
                  > 0, 0)
                  > End Sub
                  >
                  > Private Sub UserControl1_Lo ad(ByVal sender As System.Object, _
                  > ByVal e As System.EventArg s) _
                  > Handles MyBase.Load
                  > Me.BackColor = Color.Yellow
                  > End Sub
                  > End Class
                  >
                  >
                  > Private Sub Form1_Load(ByVa l sender As System.Object, _
                  > ByVal e As System.EventArg s) Handles MyBase.Load
                  > Dim uc As New UserControl1
                  > uc.Location = New Point(0, 0)
                  > uc.Size = New System.Drawing. Size(New Point(100, 100))
                  > uc.BackColor = Color.Yellow
                  > uc.AutoScroll = True
                  > uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                  > uc.Visible = True
                  > Me.Controls.Add (uc)
                  > Size = New Size(New Point(300, 300))
                  >
                  > Dim lb As New Label
                  > lb.Location = New Point(0, 150)
                  > lb.Size = New Size(290, 80)
                  > lb.Text = "1.Move the scrollbars,the diagonal line isn't" + _
                  > " drawn from(0,0) to (width,height). 2.Minimize" + _
                  > " this form. 3. Restore the form size,now the " + _
                  > "line does go from (0,0) to (width,height). " + _
                  > "Why, why isn't the diagonal line and " + _
                  > "control background cleared as you scroll?"
                  > Me.Controls.Add (lb)
                  > End Sub
                  > End Class[/color]


                  Comment

                  • hexathioorthooxalate

                    #10
                    Re: Please help, more scrollbar questions. CODE INCLUDED.

                    Flickering: reverse the methods (modified below)
                    Recursive: no.


                    Protected Overrides Sub WndProc(ByRef m As _
                    System.Windows. Forms.Message)

                    '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                    If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                    MyBase.WndProc( m)
                    End Sub



                    "One Handed Man" <Bombay@Duck.ne t> wrote in message
                    news:blhjeg$1ql $1@hercules.bti nternet.com...[color=blue]
                    > This is not a workable solution. The reason being that once you invalidate[/color]
                    ,[color=blue]
                    > it causes a paint event, which causes . . . . Flashing forms, lines etc
                    >
                    > Recursive.
                    >
                    > OHM
                    >
                    >
                    > hexathioorthoox alate wrote:[color=green]
                    > > Paste the following code into UserControl1
                    > > Hexathioorthoox alate
                    > >
                    > >
                    > > 'Putting a Debug.WriteLine (m.ToString) in the subroutine below
                    > > 'shows that the order that messages are received/processed is
                    > > 'WM_PAINT and then WM_XSCROLL. The usercontrol appears to be
                    > > 'being painted first, and then scrolled, and this is why you
                    > > 'are not seeing the diagonal. This code will ensure that
                    > > 'after a scroll, a repaint (through Invalidate()) will
                    > > 'occur - messy and probably overkill but I cannot currently
                    > > 'see another way around your dilemma.
                    > >
                    > > Protected Overrides Sub WndProc(ByRef m As
                    > > System.Windows. Forms.Message) MyBase.WndProc( m)
                    > > '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                    > > If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                    > > End Sub
                    > >
                    > >
                    > >
                    > >
                    > > "One Handed Man" <Bombay@Duck.ne t> wrote in message
                    > > news:blhd4a$hv6 $1@hercules.bti nternet.com...[color=darkred]
                    > >> Actually, I was wrong. It is not an event. However, logic tells us
                    > >> that an event has taken place because otherwise it could not have
                    > >> scrolled.
                    > >>
                    > >> I suggest you post this exact question as a new thread and this will
                    > >> get you your answer. I dont know it at present.
                    > >>
                    > >>
                    > >>
                    > >>
                    > >>
                    > >> Colin McGuire wrote:
                    > >>> OHM, I am sorry - I have seen this mentioned before and have never
                    > >>> understood it. I know I'm close and the cigar eludes me. Any chance
                    > >>> of coaching me on just a little further?
                    > >>>
                    > >>>
                    > >>> Here is what I think what you mean from your latest post, and as I
                    > >>> have implemented it is wrong because I get an a box showing up in my
                    > >>> IDE saying "'VScroll' is not an event of
                    > >>> WindowsApplicat ion15.Form1.Use rControl1'".
                    > >>>
                    > >>> What I did to my original code was
                    > >>>
                    > >>> Step 1: Added the following to UserControl1_Lo ad
                    > >>>
                    > >>> AddHandler VScroll, AddressOf capturedVScroll
                    > >>>
                    > >>> Step 2: Added the following to the code in UserControl1
                    > >>>
                    > >>> Private Sub capturedVScroll (ByVal sender As Object, _
                    > >>> ByVal e As System.EventArg s)
                    > >>> Debug.WriteLine ("capturedVScro ll")
                    > >>> End Sub
                    > >>>
                    > >>>
                    > >>> My final code therefore looks like this, but just one more tweak is
                    > >>> necessary before I can get it to compile and work.
                    > >>>
                    > >>> Colin
                    > >>>
                    > >>> Public Class Form1
                    > >>> Inherits System.Windows. Forms.Form
                    > >>>
                    > >>> '============== ========
                    > >>> ' Windows Form Designer generated code
                    > >>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                    > >>> '============== ========
                    > >>>
                    > >>> Public Class UserControl1
                    > >>> Inherits System.Windows. Forms.UserContr ol
                    > >>> Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
                    > >>> MyBase.OnPaint( p)
                    > >>> p.Graphics.Clea r(BackColor)
                    > >>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                    > >>> clientRectangle .Width, _
                    > >>> ClientRectangle .Height, _
                    > >>> 0, 0)
                    > >>> End Sub
                    > >>>
                    > >>> Private Sub UserControl1_Lo ad(ByVal sender As
                    > >>> System.Object, _ ByVal e As System.EventArg s) _
                    > >>> Handles MyBase.Load
                    > >>> Me.BackColor = Color.Yellow
                    > >>> AddHandler VScroll, AddressOf capturedVScroll 'ERROR
                    > >>> HERE End Sub
                    > >>>
                    > >>> Private Sub capturedVScroll (ByVal sender As Object, _
                    > >>> ByVal e As System.EventArg s)
                    > >>> Debug.WriteLine ("capturedVScro ll")
                    > >>> End Sub
                    > >>>
                    > >>> End Class
                    > >>>
                    > >>>
                    > >>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                    > >>> ByVal e As System.EventArg s) Handles MyBase.Load
                    > >>> Dim uc As New UserControl1
                    > >>> uc.Location = New Point(0, 0)
                    > >>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                    > >>> uc.BackColor = Color.Yellow
                    > >>> uc.AutoScroll = True
                    > >>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                    > >>> uc.Visible = True
                    > >>> Me.Controls.Add (uc)
                    > >>> Size = New Size(New Point(300, 300))
                    > >>>
                    > >>> Dim lb As New Label
                    > >>> lb.Location = New Point(0, 150)
                    > >>> lb.Size = New Size(290, 80)
                    > >>> lb.Text = "1.Move the scrollbars,the diagonal line isn't" +
                    > >>> _ " drawn from(0,0) to (width,height).
                    > >>> 2.Minimize" + _ " this form. 3. Restore the form
                    > >>> size,now the " + _ "line does go from (0,0) to
                    > >>> (width,height). " + _ "Why, why isn't the
                    > >>> diagonal line and " + _ "control background
                    > >>> cleared as you scroll?" Me.Controls.Add (lb)
                    > >>> End Sub
                    > >>> End Class
                    > >>>
                    > >>>
                    > >>>
                    > >>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                    > >>> news:blh8sf$k5k $1@titan.btinte rnet.com...
                    > >>>> You need to repaint on VScroll. Your user control inherits from
                    > >>>> Scrollable class and this event is protected so as you have
                    > >>>> inherited this you should be able to add a handler and force the
                    > >>>> control to repaint.
                    > >>>>
                    > >>>>
                    > >>>>
                    > >>>>
                    > >>>>
                    > >>>>
                    > >>>> Colin McGuire wrote:
                    > >>>>> You're not going to make me thank you again I hope :)
                    > >>>>>
                    > >>>>> Here is some more elaboration of my problem.
                    > >>>>>
                    > >>>>> What I see is:
                    > >>>>>
                    > >>>>> 1. When I move the vertical scrollbar by clicking "in"
                    > >>>>> the scrollbar (ie between the up arrow and down arrow),
                    > >>>>> the diagonal line is drawn properly (diagram below).
                    > >>>>>
                    > >>>>> +----------+
                    > >>>>> |\ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \|
                    > >>>>> +----------+
                    > >>>>>
                    > >>>>> 2. When I click the "down arrow" button on the vertical
                    > >>>>> scrollbar, the diagonal scrolls, but I can see a tiny
                    > >>>>> bit of the new diagonal showing up - sort of looks like
                    > >>>>>
                    > >>>>> +---\-------+
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \ |
                    > >>>>> | \|
                    > >>>>> | |
                    > >>>>> | |
                    > >>>>> | \|
                    > >>>>> +-----------+
                    > >>>>>
                    > >>>>> 3. When I add a Debug.WriteLine ("OnPaint") inside
                    > >>>>> the OnPaint method, both clicking "in" the scrollbar
                    > >>>>> and clicking the up or down arrow of the scrollbar
                    > >>>>> appear produce "OnPaint" in the IDE debug window.
                    > >>>>>
                    > >>>>> 4. When I minimise this (corrupted window, step 2), then
                    > >>>>> maximize it again, then it redraws properly with
                    > >>>>> the diagonal from (0,0) to (width,height) as shown
                    > >>>>> in Step 1.
                    > >>>>>
                    > >>>>> BTW: I forgot to paste in the
                    > >>>>>
                    > >>>>> p.Graphics.Clea r(BackColor)
                    > >>>>>
                    > >>>>> in my original post before the
                    > >>>>> p.Graphics.Draw Line .... but
                    > >>>>> it doesn't make any difference if I do.
                    > >>>>>
                    > >>>>> Thank you
                    > >>>>> Colin
                    > >>>>>
                    > >>>>>
                    > >>>>>
                    > >>>>>
                    > >>>>>
                    > >>>>>
                    > >>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                    > >>>>> news:blh02f$kg9 $1@hercules.bti nternet.com...
                    > >>>>>> What happens then ?
                    > >>>>>>
                    > >>>>>>
                    > >>>>>> Colin McGuire wrote:
                    > >>>>>>> I apologize for posting yet another scrollbar question. Here is
                    > >>>>>>> my code. All I want is for a diagonal line to appear from
                    > >>>>>>> coordinates (0,0) to (width,height) in a usercontrol regardless
                    > >>>>>>> of whether the user autoscrolls the usercontrol (other things
                    > >>>>>>> that are on the usercontrol I want to scroll, but haven't
                    > >>>>>>> included any here).
                    > >>>>>>>
                    > >>>>>>> Here are the steps to reproduce my problem.
                    > >>>>>>>
                    > >>>>>>> 1. Launch Visual Studio and create a new Windows
                    > >>>>>>> application with "Form1".
                    > >>>>>>> 2. Paste the following in (remember to include
                    > >>>>>>> your "Windows Form Designer generated code).
                    > >>>>>>> 3. Run - instructions are in the program that runs.
                    > >>>>>>>
                    > >>>>>>> I am using "Microsoft Development Environment 2003, Version
                    > >>>>>>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
                    > >>>>>>> 1.1.4322"
                    > >>>>>>>
                    > >>>>>>> Thank you for your patience with me.
                    > >>>>>>> Colin
                    > >>>>>>>
                    > >>>>>>>
                    > >>>>>>>
                    > >>>>>>> Public Class Form1
                    > >>>>>>> Inherits System.Windows. Forms.Form
                    > >>>>>>>
                    > >>>>>>> '============== ========
                    > >>>>>>> ' Windows Form Designer generated code
                    > >>>>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                    > >>>>>>> '============== ========
                    > >>>>>>>
                    > >>>>>>> Public Class UserControl1
                    > >>>>>>> Inherits System.Windows. Forms.UserContr ol
                    > >>>>>>> Protected Overrides Sub OnPaint(ByVal p As
                    > >>>>>>> PaintEventArgs) MyBase.OnPaint( p)
                    > >>>>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                    > >>>>>>> clientRectangle .Width, _
                    > >>>>>>> ClientRectangle .Height, _
                    > >>>>>>> 0, 0)
                    > >>>>>>> End Sub
                    > >>>>>>>
                    > >>>>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                    > >>>>>>> System.Object, _ ByVal e As System.EventArg s) _
                    > >>>>>>> Handles MyBase.Load
                    > >>>>>>> Me.BackColor = Color.Yellow
                    > >>>>>>> End Sub
                    > >>>>>>> End Class
                    > >>>>>>>
                    > >>>>>>>
                    > >>>>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                    > >>>>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                    > >>>>>>> Dim uc As New UserControl1
                    > >>>>>>> uc.Location = New Point(0, 0)
                    > >>>>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                    > >>>>>>> uc.BackColor = Color.Yellow
                    > >>>>>>> uc.AutoScroll = True
                    > >>>>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                    > >>>>>>> uc.Visible = True
                    > >>>>>>> Me.Controls.Add (uc)
                    > >>>>>>> Size = New Size(New Point(300, 300))
                    > >>>>>>>
                    > >>>>>>> Dim lb As New Label
                    > >>>>>>> lb.Location = New Point(0, 150)
                    > >>>>>>> lb.Size = New Size(290, 80)
                    > >>>>>>> lb.Text = "1.Move the scrollbars,the diagonal line
                    > >>>>>>> isn't" + _ " drawn from(0,0) to
                    > >>>>>>> (width,height).
                    > >>>>>>> 2.Minimize" + _ " this form. 3. Restore the
                    > >>>>>>> form size,now the " + _ "line does go from
                    > >>>>>>> (0,0) to (width,height). " + _ "Why, why
                    > >>>>>>> isn't the diagonal line and " + _ "control
                    > >>>>>>> background cleared as you scroll?" Me.Controls.Add (lb)
                    > >>>>>>> End Sub
                    > >>>>>>> End Class[/color][/color]
                    >
                    >[/color]

                    Comment

                    • hexathioorthooxalate

                      #11
                      Re: Please help, more scrollbar questions. CODE INCLUDED.

                      Yes, a much better solution.


                      "Brian" <nospam@prairie .lakes.com> wrote in message
                      news:vnokfgm6sl vpa9@corp.super news.com...[color=blue]
                      > Colin, put this in your New()
                      >
                      > Me.SetStyle(Con trolStyles.Doub leBuffer, True)
                      > Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
                      > Me.SetStyle(Con trolStyles.AllP aintingInWmPain t, True)
                      > Me.SetStyle(Con trolStyles.User Paint, True)
                      >
                      >
                      >
                      > Tihis will force the control to repaint the entire surface. What is
                      > happening is that your control is painting only the uncover part and not[/color]
                      the[color=blue]
                      > whole window.
                      >
                      >
                      >
                      >
                      >
                      >
                      >
                      > "Colin McGuire" <colinandkaren@ lycos.co.uk> wrote in message
                      > news:ab6cea37.0 310020025.411e8 137@posting.goo gle.com...[color=green]
                      > > I apologize for posting yet another scrollbar question. Here is my
                      > > code. All I want is for a diagonal line to appear from coordinates
                      > > (0,0) to (width,height) in a usercontrol regardless of whether the
                      > > user autoscrolls the usercontrol (other things that are on the
                      > > usercontrol I want to scroll, but haven't included any here).
                      > >
                      > > Here are the steps to reproduce my problem.
                      > >
                      > > 1. Launch Visual Studio and create a new Windows
                      > > application with "Form1".
                      > > 2. Paste the following in (remember to include
                      > > your "Windows Form Designer generated code).
                      > > 3. Run - instructions are in the program that runs.
                      > >
                      > > I am using "Microsoft Development Environment 2003, Version 7.1.3088".
                      > > I am using "Microsoft .NET Framework 1.1, Version 1.1.4322"
                      > >
                      > > Thank you for your patience with me.
                      > > Colin
                      > >
                      > >
                      > >
                      > > Public Class Form1
                      > > Inherits System.Windows. Forms.Form
                      > >
                      > > '============== ========
                      > > ' Windows Form Designer generated code
                      > > ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                      > > '============== ========
                      > >
                      > > Public Class UserControl1
                      > > Inherits System.Windows. Forms.UserContr ol
                      > > Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
                      > > MyBase.OnPaint( p)
                      > > p.Graphics.Draw Line(New Pen(Color.Black ), _
                      > > clientRectangle .Width, _
                      > > ClientRectangle .Height, _
                      > > 0, 0)
                      > > End Sub
                      > >
                      > > Private Sub UserControl1_Lo ad(ByVal sender As System.Object, _
                      > > ByVal e As System.EventArg s) _
                      > > Handles MyBase.Load
                      > > Me.BackColor = Color.Yellow
                      > > End Sub
                      > > End Class
                      > >
                      > >
                      > > Private Sub Form1_Load(ByVa l sender As System.Object, _
                      > > ByVal e As System.EventArg s) Handles MyBase.Load
                      > > Dim uc As New UserControl1
                      > > uc.Location = New Point(0, 0)
                      > > uc.Size = New System.Drawing. Size(New Point(100, 100))
                      > > uc.BackColor = Color.Yellow
                      > > uc.AutoScroll = True
                      > > uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                      > > uc.Visible = True
                      > > Me.Controls.Add (uc)
                      > > Size = New Size(New Point(300, 300))
                      > >
                      > > Dim lb As New Label
                      > > lb.Location = New Point(0, 150)
                      > > lb.Size = New Size(290, 80)
                      > > lb.Text = "1.Move the scrollbars,the diagonal line isn't" + _
                      > > " drawn from(0,0) to (width,height). 2.Minimize" + _
                      > > " this form. 3. Restore the form size,now the " + _
                      > > "line does go from (0,0) to (width,height). " + _
                      > > "Why, why isn't the diagonal line and " + _
                      > > "control background cleared as you scroll?"
                      > > Me.Controls.Add (lb)
                      > > End Sub
                      > > End Class[/color]
                      >
                      >[/color]

                      Comment

                      • One Handed Man

                        #12
                        Re: Please help, more scrollbar questions. CODE INCLUDED.

                        Nope sorry. The line flickes all the time because the paint events are
                        continually firing.

                        OHM

                        hexathioorthoox alate wrote:[color=blue]
                        > Flickering: reverse the methods (modified below)
                        > Recursive: no.
                        >
                        >
                        > Protected Overrides Sub WndProc(ByRef m As _
                        > System.Windows. Forms.Message)
                        >
                        > '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                        > If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                        > MyBase.WndProc( m)
                        > End Sub
                        >
                        >
                        >
                        > "One Handed Man" <Bombay@Duck.ne t> wrote in message
                        > news:blhjeg$1ql $1@hercules.bti nternet.com...[color=green]
                        >> This is not a workable solution. The reason being that once you
                        >> invalidate , it causes a paint event, which causes . . . . Flashing
                        >> forms, lines etc
                        >>
                        >> Recursive.
                        >>
                        >> OHM
                        >>
                        >>
                        >> hexathioorthoox alate wrote:[color=darkred]
                        >>> Paste the following code into UserControl1
                        >>> Hexathioorthoox alate
                        >>>
                        >>>
                        >>> 'Putting a Debug.WriteLine (m.ToString) in the subroutine below
                        >>> 'shows that the order that messages are received/processed is
                        >>> 'WM_PAINT and then WM_XSCROLL. The usercontrol appears to be
                        >>> 'being painted first, and then scrolled, and this is why you
                        >>> 'are not seeing the diagonal. This code will ensure that
                        >>> 'after a scroll, a repaint (through Invalidate()) will
                        >>> 'occur - messy and probably overkill but I cannot currently
                        >>> 'see another way around your dilemma.
                        >>>
                        >>> Protected Overrides Sub WndProc(ByRef m As
                        >>> System.Windows. Forms.Message) MyBase.WndProc( m)
                        >>> '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                        >>> If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                        >>> End Sub
                        >>>
                        >>>
                        >>>
                        >>>
                        >>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                        >>> news:blhd4a$hv6 $1@hercules.bti nternet.com...
                        >>>> Actually, I was wrong. It is not an event. However, logic tells us
                        >>>> that an event has taken place because otherwise it could not have
                        >>>> scrolled.
                        >>>>
                        >>>> I suggest you post this exact question as a new thread and this
                        >>>> will get you your answer. I dont know it at present.
                        >>>>
                        >>>>
                        >>>>
                        >>>>
                        >>>>
                        >>>> Colin McGuire wrote:
                        >>>>> OHM, I am sorry - I have seen this mentioned before and have never
                        >>>>> understood it. I know I'm close and the cigar eludes me. Any
                        >>>>> chance of coaching me on just a little further?
                        >>>>>
                        >>>>>
                        >>>>> Here is what I think what you mean from your latest post, and as I
                        >>>>> have implemented it is wrong because I get an a box showing up in
                        >>>>> my IDE saying "'VScroll' is not an event of
                        >>>>> WindowsApplicat ion15.Form1.Use rControl1'".
                        >>>>>
                        >>>>> What I did to my original code was
                        >>>>>
                        >>>>> Step 1: Added the following to UserControl1_Lo ad
                        >>>>>
                        >>>>> AddHandler VScroll, AddressOf capturedVScroll
                        >>>>>
                        >>>>> Step 2: Added the following to the code in UserControl1
                        >>>>>
                        >>>>> Private Sub capturedVScroll (ByVal sender As Object, _
                        >>>>> ByVal e As System.EventArg s)
                        >>>>> Debug.WriteLine ("capturedVScro ll")
                        >>>>> End Sub
                        >>>>>
                        >>>>>
                        >>>>> My final code therefore looks like this, but just one more tweak
                        >>>>> is necessary before I can get it to compile and work.
                        >>>>>
                        >>>>> Colin
                        >>>>>
                        >>>>> Public Class Form1
                        >>>>> Inherits System.Windows. Forms.Form
                        >>>>>
                        >>>>> '============== ========
                        >>>>> ' Windows Form Designer generated code
                        >>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                        >>>>> '============== ========
                        >>>>>
                        >>>>> Public Class UserControl1
                        >>>>> Inherits System.Windows. Forms.UserContr ol
                        >>>>> Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
                        >>>>> MyBase.OnPaint( p)
                        >>>>> p.Graphics.Clea r(BackColor)
                        >>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                        >>>>> clientRectangle .Width, _
                        >>>>> ClientRectangle .Height, _
                        >>>>> 0, 0)
                        >>>>> End Sub
                        >>>>>
                        >>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                        >>>>> System.Object, _ ByVal e As System.EventArg s) _
                        >>>>> Handles MyBase.Load
                        >>>>> Me.BackColor = Color.Yellow
                        >>>>> AddHandler VScroll, AddressOf capturedVScroll 'ERROR
                        >>>>> HERE End Sub
                        >>>>>
                        >>>>> Private Sub capturedVScroll (ByVal sender As Object, _
                        >>>>> ByVal e As System.EventArg s)
                        >>>>> Debug.WriteLine ("capturedVScro ll")
                        >>>>> End Sub
                        >>>>>
                        >>>>> End Class
                        >>>>>
                        >>>>>
                        >>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                        >>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                        >>>>> Dim uc As New UserControl1
                        >>>>> uc.Location = New Point(0, 0)
                        >>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                        >>>>> uc.BackColor = Color.Yellow
                        >>>>> uc.AutoScroll = True
                        >>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                        >>>>> uc.Visible = True
                        >>>>> Me.Controls.Add (uc)
                        >>>>> Size = New Size(New Point(300, 300))
                        >>>>>
                        >>>>> Dim lb As New Label
                        >>>>> lb.Location = New Point(0, 150)
                        >>>>> lb.Size = New Size(290, 80)
                        >>>>> lb.Text = "1.Move the scrollbars,the diagonal line isn't"
                        >>>>> + _ " drawn from(0,0) to (width,height).
                        >>>>> 2.Minimize" + _ " this form. 3. Restore the form
                        >>>>> size,now the " + _ "line does go from (0,0) to
                        >>>>> (width,height). " + _ "Why, why isn't the
                        >>>>> diagonal line and " + _ "control background
                        >>>>> cleared as you scroll?" Me.Controls.Add (lb)
                        >>>>> End Sub
                        >>>>> End Class
                        >>>>>
                        >>>>>
                        >>>>>
                        >>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                        >>>>> news:blh8sf$k5k $1@titan.btinte rnet.com...
                        >>>>>> You need to repaint on VScroll. Your user control inherits from
                        >>>>>> Scrollable class and this event is protected so as you have
                        >>>>>> inherited this you should be able to add a handler and force the
                        >>>>>> control to repaint.
                        >>>>>>
                        >>>>>>
                        >>>>>>
                        >>>>>>
                        >>>>>>
                        >>>>>>
                        >>>>>> Colin McGuire wrote:
                        >>>>>>> You're not going to make me thank you again I hope :)
                        >>>>>>>
                        >>>>>>> Here is some more elaboration of my problem.
                        >>>>>>>
                        >>>>>>> What I see is:
                        >>>>>>>
                        >>>>>>> 1. When I move the vertical scrollbar by clicking "in"
                        >>>>>>> the scrollbar (ie between the up arrow and down arrow),
                        >>>>>>> the diagonal line is drawn properly (diagram below).
                        >>>>>>>
                        >>>>>>> +----------+
                        >>>>>>> |\ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \|
                        >>>>>>> +----------+
                        >>>>>>>
                        >>>>>>> 2. When I click the "down arrow" button on the vertical
                        >>>>>>> scrollbar, the diagonal scrolls, but I can see a tiny
                        >>>>>>> bit of the new diagonal showing up - sort of looks like
                        >>>>>>>
                        >>>>>>> +---\-------+
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \ |
                        >>>>>>> | \|
                        >>>>>>> | |
                        >>>>>>> | |
                        >>>>>>> | \|
                        >>>>>>> +-----------+
                        >>>>>>>
                        >>>>>>> 3. When I add a Debug.WriteLine ("OnPaint") inside
                        >>>>>>> the OnPaint method, both clicking "in" the scrollbar
                        >>>>>>> and clicking the up or down arrow of the scrollbar
                        >>>>>>> appear produce "OnPaint" in the IDE debug window.
                        >>>>>>>
                        >>>>>>> 4. When I minimise this (corrupted window, step 2), then
                        >>>>>>> maximize it again, then it redraws properly with
                        >>>>>>> the diagonal from (0,0) to (width,height) as shown
                        >>>>>>> in Step 1.
                        >>>>>>>
                        >>>>>>> BTW: I forgot to paste in the
                        >>>>>>>
                        >>>>>>> p.Graphics.Clea r(BackColor)
                        >>>>>>>
                        >>>>>>> in my original post before the
                        >>>>>>> p.Graphics.Draw Line .... but
                        >>>>>>> it doesn't make any difference if I do.
                        >>>>>>>
                        >>>>>>> Thank you
                        >>>>>>> Colin
                        >>>>>>>
                        >>>>>>>
                        >>>>>>>
                        >>>>>>>
                        >>>>>>>
                        >>>>>>>
                        >>>>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                        >>>>>>> news:blh02f$kg9 $1@hercules.bti nternet.com...
                        >>>>>>>> What happens then ?
                        >>>>>>>>
                        >>>>>>>>
                        >>>>>>>> Colin McGuire wrote:
                        >>>>>>>>> I apologize for posting yet another scrollbar question. Here
                        >>>>>>>>> is my code. All I want is for a diagonal line to appear from
                        >>>>>>>>> coordinates (0,0) to (width,height) in a usercontrol
                        >>>>>>>>> regardless of whether the user autoscrolls the usercontrol
                        >>>>>>>>> (other things that are on the usercontrol I want to scroll,
                        >>>>>>>>> but haven't included any here).
                        >>>>>>>>>
                        >>>>>>>>> Here are the steps to reproduce my problem.
                        >>>>>>>>>
                        >>>>>>>>> 1. Launch Visual Studio and create a new Windows
                        >>>>>>>>> application with "Form1".
                        >>>>>>>>> 2. Paste the following in (remember to include
                        >>>>>>>>> your "Windows Form Designer generated code).
                        >>>>>>>>> 3. Run - instructions are in the program that runs.
                        >>>>>>>>>
                        >>>>>>>>> I am using "Microsoft Development Environment 2003, Version
                        >>>>>>>>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
                        >>>>>>>>> 1.1.4322"
                        >>>>>>>>>
                        >>>>>>>>> Thank you for your patience with me.
                        >>>>>>>>> Colin
                        >>>>>>>>>
                        >>>>>>>>>
                        >>>>>>>>>
                        >>>>>>>>> Public Class Form1
                        >>>>>>>>> Inherits System.Windows. Forms.Form
                        >>>>>>>>>
                        >>>>>>>>> '============== ========
                        >>>>>>>>> ' Windows Form Designer generated code
                        >>>>>>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                        >>>>>>>>> '============== ========
                        >>>>>>>>>
                        >>>>>>>>> Public Class UserControl1
                        >>>>>>>>> Inherits System.Windows. Forms.UserContr ol
                        >>>>>>>>> Protected Overrides Sub OnPaint(ByVal p As
                        >>>>>>>>> PaintEventArgs) MyBase.OnPaint( p)
                        >>>>>>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                        >>>>>>>>> clientRectangle .Width, _
                        >>>>>>>>> ClientRectangle .Height, _
                        >>>>>>>>> 0, 0)
                        >>>>>>>>> End Sub
                        >>>>>>>>>
                        >>>>>>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                        >>>>>>>>> System.Object, _ ByVal e As System.EventArg s) _
                        >>>>>>>>> Handles MyBase.Load
                        >>>>>>>>> Me.BackColor = Color.Yellow
                        >>>>>>>>> End Sub
                        >>>>>>>>> End Class
                        >>>>>>>>>
                        >>>>>>>>>
                        >>>>>>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                        >>>>>>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                        >>>>>>>>> Dim uc As New UserControl1
                        >>>>>>>>> uc.Location = New Point(0, 0)
                        >>>>>>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                        >>>>>>>>> uc.BackColor = Color.Yellow
                        >>>>>>>>> uc.AutoScroll = True
                        >>>>>>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                        >>>>>>>>> uc.Visible = True
                        >>>>>>>>> Me.Controls.Add (uc)
                        >>>>>>>>> Size = New Size(New Point(300, 300))
                        >>>>>>>>>
                        >>>>>>>>> Dim lb As New Label
                        >>>>>>>>> lb.Location = New Point(0, 150)
                        >>>>>>>>> lb.Size = New Size(290, 80)
                        >>>>>>>>> lb.Text = "1.Move the scrollbars,the diagonal line
                        >>>>>>>>> isn't" + _ " drawn from(0,0) to
                        >>>>>>>>> (width,height).
                        >>>>>>>>> 2.Minimize" + _ " this form. 3. Restore the
                        >>>>>>>>> form size,now the " + _ "line does go from
                        >>>>>>>>> (0,0) to (width,height). " + _ "Why, why
                        >>>>>>>>> isn't the diagonal line and " + _ "control
                        >>>>>>>>> background cleared as you scroll?" Me.Controls.Add (lb)
                        >>>>>>>>> End Sub
                        >>>>>>>>> End Class[/color][/color][/color]


                        Comment

                        • One Handed Man

                          #13
                          Re: Please help, more scrollbar questions. CODE INCLUDED.

                          Sorry, I forgot to take out a refresh in the paint event.


                          Yes, it works a treat. Thanks for your help


                          Regards OHM


                          One Handed Man wrote:[color=blue]
                          > Nope sorry. The line flickes all the time because the paint events are
                          > continually firing.
                          >
                          > OHM
                          >
                          > hexathioorthoox alate wrote:[color=green]
                          >> Flickering: reverse the methods (modified below)
                          >> Recursive: no.
                          >>
                          >>
                          >> Protected Overrides Sub WndProc(ByRef m As _
                          >> System.Windows. Forms.Message)
                          >>
                          >> '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                          >> If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                          >> MyBase.WndProc( m)
                          >> End Sub
                          >>
                          >>
                          >>
                          >> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                          >> news:blhjeg$1ql $1@hercules.bti nternet.com...[color=darkred]
                          >>> This is not a workable solution. The reason being that once you
                          >>> invalidate , it causes a paint event, which causes . . . . Flashing
                          >>> forms, lines etc
                          >>>
                          >>> Recursive.
                          >>>
                          >>> OHM
                          >>>
                          >>>
                          >>> hexathioorthoox alate wrote:
                          >>>> Paste the following code into UserControl1
                          >>>> Hexathioorthoox alate
                          >>>>
                          >>>>
                          >>>> 'Putting a Debug.WriteLine (m.ToString) in the subroutine below
                          >>>> 'shows that the order that messages are received/processed is
                          >>>> 'WM_PAINT and then WM_XSCROLL. The usercontrol appears to be
                          >>>> 'being painted first, and then scrolled, and this is why you
                          >>>> 'are not seeing the diagonal. This code will ensure that
                          >>>> 'after a scroll, a repaint (through Invalidate()) will
                          >>>> 'occur - messy and probably overkill but I cannot currently
                          >>>> 'see another way around your dilemma.
                          >>>>
                          >>>> Protected Overrides Sub WndProc(ByRef m As
                          >>>> System.Windows. Forms.Message) MyBase.WndProc( m)
                          >>>> '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                          >>>> If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                          >>>> End Sub
                          >>>>
                          >>>>
                          >>>>
                          >>>>
                          >>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                          >>>> news:blhd4a$hv6 $1@hercules.bti nternet.com...
                          >>>>> Actually, I was wrong. It is not an event. However, logic tells us
                          >>>>> that an event has taken place because otherwise it could not have
                          >>>>> scrolled.
                          >>>>>
                          >>>>> I suggest you post this exact question as a new thread and this
                          >>>>> will get you your answer. I dont know it at present.
                          >>>>>
                          >>>>>
                          >>>>>
                          >>>>>
                          >>>>>
                          >>>>> Colin McGuire wrote:
                          >>>>>> OHM, I am sorry - I have seen this mentioned before and have
                          >>>>>> never understood it. I know I'm close and the cigar eludes me.
                          >>>>>> Any chance of coaching me on just a little further?
                          >>>>>>
                          >>>>>>
                          >>>>>> Here is what I think what you mean from your latest post, and as
                          >>>>>> I have implemented it is wrong because I get an a box showing up
                          >>>>>> in my IDE saying "'VScroll' is not an event of
                          >>>>>> WindowsApplicat ion15.Form1.Use rControl1'".
                          >>>>>>
                          >>>>>> What I did to my original code was
                          >>>>>>
                          >>>>>> Step 1: Added the following to UserControl1_Lo ad
                          >>>>>>
                          >>>>>> AddHandler VScroll, AddressOf capturedVScroll
                          >>>>>>
                          >>>>>> Step 2: Added the following to the code in UserControl1
                          >>>>>>
                          >>>>>> Private Sub capturedVScroll (ByVal sender As Object, _
                          >>>>>> ByVal e As System.EventArg s)
                          >>>>>> Debug.WriteLine ("capturedVScro ll")
                          >>>>>> End Sub
                          >>>>>>
                          >>>>>>
                          >>>>>> My final code therefore looks like this, but just one more tweak
                          >>>>>> is necessary before I can get it to compile and work.
                          >>>>>>
                          >>>>>> Colin
                          >>>>>>
                          >>>>>> Public Class Form1
                          >>>>>> Inherits System.Windows. Forms.Form
                          >>>>>>
                          >>>>>> '============== ========
                          >>>>>> ' Windows Form Designer generated code
                          >>>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                          >>>>>> '============== ========
                          >>>>>>
                          >>>>>> Public Class UserControl1
                          >>>>>> Inherits System.Windows. Forms.UserContr ol
                          >>>>>> Protected Overrides Sub OnPaint(ByVal p As
                          >>>>>> PaintEventArgs) MyBase.OnPaint( p)
                          >>>>>> p.Graphics.Clea r(BackColor)
                          >>>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                          >>>>>> clientRectangle .Width, _
                          >>>>>> ClientRectangle .Height, _
                          >>>>>> 0, 0)
                          >>>>>> End Sub
                          >>>>>>
                          >>>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                          >>>>>> System.Object, _ ByVal e As System.EventArg s) _
                          >>>>>> Handles MyBase.Load
                          >>>>>> Me.BackColor = Color.Yellow
                          >>>>>> AddHandler VScroll, AddressOf capturedVScroll 'ERROR
                          >>>>>> HERE End Sub
                          >>>>>>
                          >>>>>> Private Sub capturedVScroll (ByVal sender As Object, _
                          >>>>>> ByVal e As System.EventArg s)
                          >>>>>> Debug.WriteLine ("capturedVScro ll")
                          >>>>>> End Sub
                          >>>>>>
                          >>>>>> End Class
                          >>>>>>
                          >>>>>>
                          >>>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                          >>>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                          >>>>>> Dim uc As New UserControl1
                          >>>>>> uc.Location = New Point(0, 0)
                          >>>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                          >>>>>> uc.BackColor = Color.Yellow
                          >>>>>> uc.AutoScroll = True
                          >>>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                          >>>>>> uc.Visible = True
                          >>>>>> Me.Controls.Add (uc)
                          >>>>>> Size = New Size(New Point(300, 300))
                          >>>>>>
                          >>>>>> Dim lb As New Label
                          >>>>>> lb.Location = New Point(0, 150)
                          >>>>>> lb.Size = New Size(290, 80)
                          >>>>>> lb.Text = "1.Move the scrollbars,the diagonal line isn't"
                          >>>>>> + _ " drawn from(0,0) to (width,height).
                          >>>>>> 2.Minimize" + _ " this form. 3. Restore the
                          >>>>>> form size,now the " + _ "line does go from
                          >>>>>> (0,0) to (width,height). " + _ "Why, why isn't
                          >>>>>> the diagonal line and " + _ "control background
                          >>>>>> cleared as you scroll?" Me.Controls.Add (lb)
                          >>>>>> End Sub
                          >>>>>> End Class
                          >>>>>>
                          >>>>>>
                          >>>>>>
                          >>>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                          >>>>>> news:blh8sf$k5k $1@titan.btinte rnet.com...
                          >>>>>>> You need to repaint on VScroll. Your user control inherits
                          >>>>>>> from Scrollable class and this event is protected so as you have
                          >>>>>>> inherited this you should be able to add a handler and force the
                          >>>>>>> control to repaint.
                          >>>>>>>
                          >>>>>>>
                          >>>>>>>
                          >>>>>>>
                          >>>>>>>
                          >>>>>>>
                          >>>>>>> Colin McGuire wrote:
                          >>>>>>>> You're not going to make me thank you again I hope :)
                          >>>>>>>>
                          >>>>>>>> Here is some more elaboration of my problem.
                          >>>>>>>>
                          >>>>>>>> What I see is:
                          >>>>>>>>
                          >>>>>>>> 1. When I move the vertical scrollbar by clicking "in"
                          >>>>>>>> the scrollbar (ie between the up arrow and down arrow),
                          >>>>>>>> the diagonal line is drawn properly (diagram below).
                          >>>>>>>>
                          >>>>>>>> +----------+
                          >>>>>>>> |\ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \|
                          >>>>>>>> +----------+
                          >>>>>>>>
                          >>>>>>>> 2. When I click the "down arrow" button on the vertical
                          >>>>>>>> scrollbar, the diagonal scrolls, but I can see a tiny
                          >>>>>>>> bit of the new diagonal showing up - sort of looks like
                          >>>>>>>>
                          >>>>>>>> +---\-------+
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \ |
                          >>>>>>>> | \|
                          >>>>>>>> | |
                          >>>>>>>> | |
                          >>>>>>>> | \|
                          >>>>>>>> +-----------+
                          >>>>>>>>
                          >>>>>>>> 3. When I add a Debug.WriteLine ("OnPaint") inside
                          >>>>>>>> the OnPaint method, both clicking "in" the scrollbar
                          >>>>>>>> and clicking the up or down arrow of the scrollbar
                          >>>>>>>> appear produce "OnPaint" in the IDE debug window.
                          >>>>>>>>
                          >>>>>>>> 4. When I minimise this (corrupted window, step 2), then
                          >>>>>>>> maximize it again, then it redraws properly with
                          >>>>>>>> the diagonal from (0,0) to (width,height) as shown
                          >>>>>>>> in Step 1.
                          >>>>>>>>
                          >>>>>>>> BTW: I forgot to paste in the
                          >>>>>>>>
                          >>>>>>>> p.Graphics.Clea r(BackColor)
                          >>>>>>>>
                          >>>>>>>> in my original post before the
                          >>>>>>>> p.Graphics.Draw Line .... but
                          >>>>>>>> it doesn't make any difference if I do.
                          >>>>>>>>
                          >>>>>>>> Thank you
                          >>>>>>>> Colin
                          >>>>>>>>
                          >>>>>>>>
                          >>>>>>>>
                          >>>>>>>>
                          >>>>>>>>
                          >>>>>>>>
                          >>>>>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                          >>>>>>>> news:blh02f$kg9 $1@hercules.bti nternet.com...
                          >>>>>>>>> What happens then ?
                          >>>>>>>>>
                          >>>>>>>>>
                          >>>>>>>>> Colin McGuire wrote:
                          >>>>>>>>>> I apologize for posting yet another scrollbar question. Here
                          >>>>>>>>>> is my code. All I want is for a diagonal line to appear from
                          >>>>>>>>>> coordinates (0,0) to (width,height) in a usercontrol
                          >>>>>>>>>> regardless of whether the user autoscrolls the usercontrol
                          >>>>>>>>>> (other things that are on the usercontrol I want to scroll,
                          >>>>>>>>>> but haven't included any here).
                          >>>>>>>>>>
                          >>>>>>>>>> Here are the steps to reproduce my problem.
                          >>>>>>>>>>
                          >>>>>>>>>> 1. Launch Visual Studio and create a new Windows
                          >>>>>>>>>> application with "Form1".
                          >>>>>>>>>> 2. Paste the following in (remember to include
                          >>>>>>>>>> your "Windows Form Designer generated code).
                          >>>>>>>>>> 3. Run - instructions are in the program that runs.
                          >>>>>>>>>>
                          >>>>>>>>>> I am using "Microsoft Development Environment 2003, Version
                          >>>>>>>>>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
                          >>>>>>>>>> 1.1.4322"
                          >>>>>>>>>>
                          >>>>>>>>>> Thank you for your patience with me.
                          >>>>>>>>>> Colin
                          >>>>>>>>>>
                          >>>>>>>>>>
                          >>>>>>>>>>
                          >>>>>>>>>> Public Class Form1
                          >>>>>>>>>> Inherits System.Windows. Forms.Form
                          >>>>>>>>>>
                          >>>>>>>>>> '============== ========
                          >>>>>>>>>> ' Windows Form Designer generated code
                          >>>>>>>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                          >>>>>>>>>> '============== ========
                          >>>>>>>>>>
                          >>>>>>>>>> Public Class UserControl1
                          >>>>>>>>>> Inherits System.Windows. Forms.UserContr ol
                          >>>>>>>>>> Protected Overrides Sub OnPaint(ByVal p As
                          >>>>>>>>>> PaintEventArgs) MyBase.OnPaint( p)
                          >>>>>>>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                          >>>>>>>>>> clientRectangle .Width, _
                          >>>>>>>>>> ClientRectangle .Height, _
                          >>>>>>>>>> 0, 0)
                          >>>>>>>>>> End Sub
                          >>>>>>>>>>
                          >>>>>>>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                          >>>>>>>>>> System.Object, _ ByVal e As System.EventArg s) _
                          >>>>>>>>>> Handles MyBase.Load
                          >>>>>>>>>> Me.BackColor = Color.Yellow
                          >>>>>>>>>> End Sub
                          >>>>>>>>>> End Class
                          >>>>>>>>>>
                          >>>>>>>>>>
                          >>>>>>>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                          >>>>>>>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                          >>>>>>>>>> Dim uc As New UserControl1
                          >>>>>>>>>> uc.Location = New Point(0, 0)
                          >>>>>>>>>> uc.Size = New System.Drawing. Size(New Point(100,
                          >>>>>>>>>> 100)) uc.BackColor = Color.Yellow
                          >>>>>>>>>> uc.AutoScroll = True
                          >>>>>>>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                          >>>>>>>>>> uc.Visible = True
                          >>>>>>>>>> Me.Controls.Add (uc)
                          >>>>>>>>>> Size = New Size(New Point(300, 300))
                          >>>>>>>>>>
                          >>>>>>>>>> Dim lb As New Label
                          >>>>>>>>>> lb.Location = New Point(0, 150)
                          >>>>>>>>>> lb.Size = New Size(290, 80)
                          >>>>>>>>>> lb.Text = "1.Move the scrollbars,the diagonal line
                          >>>>>>>>>> isn't" + _ " drawn from(0,0) to
                          >>>>>>>>>> (width,height).
                          >>>>>>>>>> 2.Minimize" + _ " this form. 3. Restore the
                          >>>>>>>>>> form size,now the " + _ "line does go from
                          >>>>>>>>>> (0,0) to (width,height). " + _ "Why, why
                          >>>>>>>>>> isn't the diagonal line and " + _ "control
                          >>>>>>>>>> background cleared as you scroll?"
                          >>>>>>>>>> Me.Controls.Add (lb) End Sub
                          >>>>>>>>>> End Class[/color][/color][/color]


                          Comment

                          • hexathioorthooxalate

                            #14
                            Re: Please help, more scrollbar questions. CODE INCLUDED.

                            Are you sure? Not for me? You might be right but I can't see it. Why would
                            continually refresh?
                            The WndProc only causes a repaint when via WM_VSCROLL and WM_HSCROLL
                            messages are detected, which isn't every time. I don't see how it can be
                            continually firing.


                            "One Handed Man" <Bombay@Duck.ne t> wrote in message
                            news:blhm1n$742 $1@hercules.bti nternet.com...[color=blue]
                            > Nope sorry. The line flickes all the time because the paint events are
                            > continually firing.
                            >
                            > OHM
                            >
                            > hexathioorthoox alate wrote:[color=green]
                            > > Flickering: reverse the methods (modified below)
                            > > Recursive: no.
                            > >
                            > >
                            > > Protected Overrides Sub WndProc(ByRef m As _
                            > > System.Windows. Forms.Message)
                            > >
                            > > '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                            > > If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                            > > MyBase.WndProc( m)
                            > > End Sub
                            > >
                            > >
                            > >
                            > > "One Handed Man" <Bombay@Duck.ne t> wrote in message
                            > > news:blhjeg$1ql $1@hercules.bti nternet.com...[color=darkred]
                            > >> This is not a workable solution. The reason being that once you
                            > >> invalidate , it causes a paint event, which causes . . . . Flashing
                            > >> forms, lines etc
                            > >>
                            > >> Recursive.
                            > >>
                            > >> OHM
                            > >>
                            > >>
                            > >> hexathioorthoox alate wrote:
                            > >>> Paste the following code into UserControl1
                            > >>> Hexathioorthoox alate
                            > >>>
                            > >>>
                            > >>> 'Putting a Debug.WriteLine (m.ToString) in the subroutine below
                            > >>> 'shows that the order that messages are received/processed is
                            > >>> 'WM_PAINT and then WM_XSCROLL. The usercontrol appears to be
                            > >>> 'being painted first, and then scrolled, and this is why you
                            > >>> 'are not seeing the diagonal. This code will ensure that
                            > >>> 'after a scroll, a repaint (through Invalidate()) will
                            > >>> 'occur - messy and probably overkill but I cannot currently
                            > >>> 'see another way around your dilemma.
                            > >>>
                            > >>> Protected Overrides Sub WndProc(ByRef m As
                            > >>> System.Windows. Forms.Message) MyBase.WndProc( m)
                            > >>> '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                            > >>> If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                            > >>> End Sub
                            > >>>
                            > >>>
                            > >>>
                            > >>>
                            > >>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                            > >>> news:blhd4a$hv6 $1@hercules.bti nternet.com...
                            > >>>> Actually, I was wrong. It is not an event. However, logic tells us
                            > >>>> that an event has taken place because otherwise it could not have
                            > >>>> scrolled.
                            > >>>>
                            > >>>> I suggest you post this exact question as a new thread and this
                            > >>>> will get you your answer. I dont know it at present.
                            > >>>>
                            > >>>>
                            > >>>>
                            > >>>>
                            > >>>>
                            > >>>> Colin McGuire wrote:
                            > >>>>> OHM, I am sorry - I have seen this mentioned before and have never
                            > >>>>> understood it. I know I'm close and the cigar eludes me. Any
                            > >>>>> chance of coaching me on just a little further?
                            > >>>>>
                            > >>>>>
                            > >>>>> Here is what I think what you mean from your latest post, and as I
                            > >>>>> have implemented it is wrong because I get an a box showing up in
                            > >>>>> my IDE saying "'VScroll' is not an event of
                            > >>>>> WindowsApplicat ion15.Form1.Use rControl1'".
                            > >>>>>
                            > >>>>> What I did to my original code was
                            > >>>>>
                            > >>>>> Step 1: Added the following to UserControl1_Lo ad
                            > >>>>>
                            > >>>>> AddHandler VScroll, AddressOf capturedVScroll
                            > >>>>>
                            > >>>>> Step 2: Added the following to the code in UserControl1
                            > >>>>>
                            > >>>>> Private Sub capturedVScroll (ByVal sender As Object, _
                            > >>>>> ByVal e As System.EventArg s)
                            > >>>>> Debug.WriteLine ("capturedVScro ll")
                            > >>>>> End Sub
                            > >>>>>
                            > >>>>>
                            > >>>>> My final code therefore looks like this, but just one more tweak
                            > >>>>> is necessary before I can get it to compile and work.
                            > >>>>>
                            > >>>>> Colin
                            > >>>>>
                            > >>>>> Public Class Form1
                            > >>>>> Inherits System.Windows. Forms.Form
                            > >>>>>
                            > >>>>> '============== ========
                            > >>>>> ' Windows Form Designer generated code
                            > >>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                            > >>>>> '============== ========
                            > >>>>>
                            > >>>>> Public Class UserControl1
                            > >>>>> Inherits System.Windows. Forms.UserContr ol
                            > >>>>> Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
                            > >>>>> MyBase.OnPaint( p)
                            > >>>>> p.Graphics.Clea r(BackColor)
                            > >>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                            > >>>>> clientRectangle .Width, _
                            > >>>>> ClientRectangle .Height, _
                            > >>>>> 0, 0)
                            > >>>>> End Sub
                            > >>>>>
                            > >>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                            > >>>>> System.Object, _ ByVal e As System.EventArg s) _
                            > >>>>> Handles MyBase.Load
                            > >>>>> Me.BackColor = Color.Yellow
                            > >>>>> AddHandler VScroll, AddressOf capturedVScroll 'ERROR
                            > >>>>> HERE End Sub
                            > >>>>>
                            > >>>>> Private Sub capturedVScroll (ByVal sender As Object, _
                            > >>>>> ByVal e As System.EventArg s)
                            > >>>>> Debug.WriteLine ("capturedVScro ll")
                            > >>>>> End Sub
                            > >>>>>
                            > >>>>> End Class
                            > >>>>>
                            > >>>>>
                            > >>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                            > >>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                            > >>>>> Dim uc As New UserControl1
                            > >>>>> uc.Location = New Point(0, 0)
                            > >>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                            > >>>>> uc.BackColor = Color.Yellow
                            > >>>>> uc.AutoScroll = True
                            > >>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                            > >>>>> uc.Visible = True
                            > >>>>> Me.Controls.Add (uc)
                            > >>>>> Size = New Size(New Point(300, 300))
                            > >>>>>
                            > >>>>> Dim lb As New Label
                            > >>>>> lb.Location = New Point(0, 150)
                            > >>>>> lb.Size = New Size(290, 80)
                            > >>>>> lb.Text = "1.Move the scrollbars,the diagonal line isn't"
                            > >>>>> + _ " drawn from(0,0) to (width,height).
                            > >>>>> 2.Minimize" + _ " this form. 3. Restore the form
                            > >>>>> size,now the " + _ "line does go from (0,0) to
                            > >>>>> (width,height). " + _ "Why, why isn't the
                            > >>>>> diagonal line and " + _ "control background
                            > >>>>> cleared as you scroll?" Me.Controls.Add (lb)
                            > >>>>> End Sub
                            > >>>>> End Class
                            > >>>>>
                            > >>>>>
                            > >>>>>
                            > >>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                            > >>>>> news:blh8sf$k5k $1@titan.btinte rnet.com...
                            > >>>>>> You need to repaint on VScroll. Your user control inherits from
                            > >>>>>> Scrollable class and this event is protected so as you have
                            > >>>>>> inherited this you should be able to add a handler and force the
                            > >>>>>> control to repaint.
                            > >>>>>>
                            > >>>>>>
                            > >>>>>>
                            > >>>>>>
                            > >>>>>>
                            > >>>>>>
                            > >>>>>> Colin McGuire wrote:
                            > >>>>>>> You're not going to make me thank you again I hope :)
                            > >>>>>>>
                            > >>>>>>> Here is some more elaboration of my problem.
                            > >>>>>>>
                            > >>>>>>> What I see is:
                            > >>>>>>>
                            > >>>>>>> 1. When I move the vertical scrollbar by clicking "in"
                            > >>>>>>> the scrollbar (ie between the up arrow and down arrow),
                            > >>>>>>> the diagonal line is drawn properly (diagram below).
                            > >>>>>>>
                            > >>>>>>> +----------+
                            > >>>>>>> |\ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \|
                            > >>>>>>> +----------+
                            > >>>>>>>
                            > >>>>>>> 2. When I click the "down arrow" button on the vertical
                            > >>>>>>> scrollbar, the diagonal scrolls, but I can see a tiny
                            > >>>>>>> bit of the new diagonal showing up - sort of looks like
                            > >>>>>>>
                            > >>>>>>> +---\-------+
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \ |
                            > >>>>>>> | \|
                            > >>>>>>> | |
                            > >>>>>>> | |
                            > >>>>>>> | \|
                            > >>>>>>> +-----------+
                            > >>>>>>>
                            > >>>>>>> 3. When I add a Debug.WriteLine ("OnPaint") inside
                            > >>>>>>> the OnPaint method, both clicking "in" the scrollbar
                            > >>>>>>> and clicking the up or down arrow of the scrollbar
                            > >>>>>>> appear produce "OnPaint" in the IDE debug window.
                            > >>>>>>>
                            > >>>>>>> 4. When I minimise this (corrupted window, step 2), then
                            > >>>>>>> maximize it again, then it redraws properly with
                            > >>>>>>> the diagonal from (0,0) to (width,height) as shown
                            > >>>>>>> in Step 1.
                            > >>>>>>>
                            > >>>>>>> BTW: I forgot to paste in the
                            > >>>>>>>
                            > >>>>>>> p.Graphics.Clea r(BackColor)
                            > >>>>>>>
                            > >>>>>>> in my original post before the
                            > >>>>>>> p.Graphics.Draw Line .... but
                            > >>>>>>> it doesn't make any difference if I do.
                            > >>>>>>>
                            > >>>>>>> Thank you
                            > >>>>>>> Colin
                            > >>>>>>>
                            > >>>>>>>
                            > >>>>>>>
                            > >>>>>>>
                            > >>>>>>>
                            > >>>>>>>
                            > >>>>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                            > >>>>>>> news:blh02f$kg9 $1@hercules.bti nternet.com...
                            > >>>>>>>> What happens then ?
                            > >>>>>>>>
                            > >>>>>>>>
                            > >>>>>>>> Colin McGuire wrote:
                            > >>>>>>>>> I apologize for posting yet another scrollbar question. Here
                            > >>>>>>>>> is my code. All I want is for a diagonal line to appear from
                            > >>>>>>>>> coordinates (0,0) to (width,height) in a usercontrol
                            > >>>>>>>>> regardless of whether the user autoscrolls the usercontrol
                            > >>>>>>>>> (other things that are on the usercontrol I want to scroll,
                            > >>>>>>>>> but haven't included any here).
                            > >>>>>>>>>
                            > >>>>>>>>> Here are the steps to reproduce my problem.
                            > >>>>>>>>>
                            > >>>>>>>>> 1. Launch Visual Studio and create a new Windows
                            > >>>>>>>>> application with "Form1".
                            > >>>>>>>>> 2. Paste the following in (remember to include
                            > >>>>>>>>> your "Windows Form Designer generated code).
                            > >>>>>>>>> 3. Run - instructions are in the program that runs.
                            > >>>>>>>>>
                            > >>>>>>>>> I am using "Microsoft Development Environment 2003, Version
                            > >>>>>>>>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
                            > >>>>>>>>> 1.1.4322"
                            > >>>>>>>>>
                            > >>>>>>>>> Thank you for your patience with me.
                            > >>>>>>>>> Colin
                            > >>>>>>>>>
                            > >>>>>>>>>
                            > >>>>>>>>>
                            > >>>>>>>>> Public Class Form1
                            > >>>>>>>>> Inherits System.Windows. Forms.Form
                            > >>>>>>>>>
                            > >>>>>>>>> '============== ========
                            > >>>>>>>>> ' Windows Form Designer generated code
                            > >>>>>>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                            > >>>>>>>>> '============== ========
                            > >>>>>>>>>
                            > >>>>>>>>> Public Class UserControl1
                            > >>>>>>>>> Inherits System.Windows. Forms.UserContr ol
                            > >>>>>>>>> Protected Overrides Sub OnPaint(ByVal p As
                            > >>>>>>>>> PaintEventArgs) MyBase.OnPaint( p)
                            > >>>>>>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                            > >>>>>>>>> clientRectangle .Width, _
                            > >>>>>>>>> ClientRectangle .Height, _
                            > >>>>>>>>> 0, 0)
                            > >>>>>>>>> End Sub
                            > >>>>>>>>>
                            > >>>>>>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                            > >>>>>>>>> System.Object, _ ByVal e As System.EventArg s) _
                            > >>>>>>>>> Handles MyBase.Load
                            > >>>>>>>>> Me.BackColor = Color.Yellow
                            > >>>>>>>>> End Sub
                            > >>>>>>>>> End Class
                            > >>>>>>>>>
                            > >>>>>>>>>
                            > >>>>>>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                            > >>>>>>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                            > >>>>>>>>> Dim uc As New UserControl1
                            > >>>>>>>>> uc.Location = New Point(0, 0)
                            > >>>>>>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                            > >>>>>>>>> uc.BackColor = Color.Yellow
                            > >>>>>>>>> uc.AutoScroll = True
                            > >>>>>>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                            > >>>>>>>>> uc.Visible = True
                            > >>>>>>>>> Me.Controls.Add (uc)
                            > >>>>>>>>> Size = New Size(New Point(300, 300))
                            > >>>>>>>>>
                            > >>>>>>>>> Dim lb As New Label
                            > >>>>>>>>> lb.Location = New Point(0, 150)
                            > >>>>>>>>> lb.Size = New Size(290, 80)
                            > >>>>>>>>> lb.Text = "1.Move the scrollbars,the diagonal line
                            > >>>>>>>>> isn't" + _ " drawn from(0,0) to
                            > >>>>>>>>> (width,height).
                            > >>>>>>>>> 2.Minimize" + _ " this form. 3. Restore the
                            > >>>>>>>>> form size,now the " + _ "line does go from
                            > >>>>>>>>> (0,0) to (width,height). " + _ "Why, why
                            > >>>>>>>>> isn't the diagonal line and " + _ "control
                            > >>>>>>>>> background cleared as you scroll?" Me.Controls.Add (lb)
                            > >>>>>>>>> End Sub
                            > >>>>>>>>> End Class[/color][/color]
                            >
                            >[/color]

                            Comment

                            • hexathioorthooxalate

                              #15
                              Re: Please help, more scrollbar questions. CODE INCLUDED.

                              We posted at the same time, just read what you had written.
                              Glad to be of help - Brian's solution is nicer though.
                              Hexathioorthoox alate.




                              "hexathioorthoo xalate" <ruler@REMOVESP AM.clara.co.uk> wrote in message
                              news:1065115737 .11339.0@doris. uk.clara.net...[color=blue]
                              > Are you sure? Not for me? You might be right but I can't see it. Why would
                              > continually refresh?
                              > The WndProc only causes a repaint when via WM_VSCROLL and WM_HSCROLL
                              > messages are detected, which isn't every time. I don't see how it can be
                              > continually firing.
                              >
                              >
                              > "One Handed Man" <Bombay@Duck.ne t> wrote in message
                              > news:blhm1n$742 $1@hercules.bti nternet.com...[color=green]
                              > > Nope sorry. The line flickes all the time because the paint events are
                              > > continually firing.
                              > >
                              > > OHM
                              > >
                              > > hexathioorthoox alate wrote:[color=darkred]
                              > > > Flickering: reverse the methods (modified below)
                              > > > Recursive: no.
                              > > >
                              > > >
                              > > > Protected Overrides Sub WndProc(ByRef m As _
                              > > > System.Windows. Forms.Message)
                              > > >
                              > > > '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                              > > > If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                              > > > MyBase.WndProc( m)
                              > > > End Sub
                              > > >
                              > > >
                              > > >
                              > > > "One Handed Man" <Bombay@Duck.ne t> wrote in message
                              > > > news:blhjeg$1ql $1@hercules.bti nternet.com...
                              > > >> This is not a workable solution. The reason being that once you
                              > > >> invalidate , it causes a paint event, which causes . . . . Flashing
                              > > >> forms, lines etc
                              > > >>
                              > > >> Recursive.
                              > > >>
                              > > >> OHM
                              > > >>
                              > > >>
                              > > >> hexathioorthoox alate wrote:
                              > > >>> Paste the following code into UserControl1
                              > > >>> Hexathioorthoox alate
                              > > >>>
                              > > >>>
                              > > >>> 'Putting a Debug.WriteLine (m.ToString) in the subroutine below
                              > > >>> 'shows that the order that messages are received/processed is
                              > > >>> 'WM_PAINT and then WM_XSCROLL. The usercontrol appears to be
                              > > >>> 'being painted first, and then scrolled, and this is why you
                              > > >>> 'are not seeing the diagonal. This code will ensure that
                              > > >>> 'after a scroll, a repaint (through Invalidate()) will
                              > > >>> 'occur - messy and probably overkill but I cannot currently
                              > > >>> 'see another way around your dilemma.
                              > > >>>
                              > > >>> Protected Overrides Sub WndProc(ByRef m As
                              > > >>> System.Windows. Forms.Message) MyBase.WndProc( m)
                              > > >>> '0x115=WM_VSCRO LL, 0x114=WM_HSCROL L
                              > > >>> If m.Msg = &H115 Or m.Msg = &H114 Then Invalidate()
                              > > >>> End Sub
                              > > >>>
                              > > >>>
                              > > >>>
                              > > >>>
                              > > >>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                              > > >>> news:blhd4a$hv6 $1@hercules.bti nternet.com...
                              > > >>>> Actually, I was wrong. It is not an event. However, logic tells us
                              > > >>>> that an event has taken place because otherwise it could not have
                              > > >>>> scrolled.
                              > > >>>>
                              > > >>>> I suggest you post this exact question as a new thread and this
                              > > >>>> will get you your answer. I dont know it at present.
                              > > >>>>
                              > > >>>>
                              > > >>>>
                              > > >>>>
                              > > >>>>
                              > > >>>> Colin McGuire wrote:
                              > > >>>>> OHM, I am sorry - I have seen this mentioned before and have never
                              > > >>>>> understood it. I know I'm close and the cigar eludes me. Any
                              > > >>>>> chance of coaching me on just a little further?
                              > > >>>>>
                              > > >>>>>
                              > > >>>>> Here is what I think what you mean from your latest post, and as I
                              > > >>>>> have implemented it is wrong because I get an a box showing up in
                              > > >>>>> my IDE saying "'VScroll' is not an event of
                              > > >>>>> WindowsApplicat ion15.Form1.Use rControl1'".
                              > > >>>>>
                              > > >>>>> What I did to my original code was
                              > > >>>>>
                              > > >>>>> Step 1: Added the following to UserControl1_Lo ad
                              > > >>>>>
                              > > >>>>> AddHandler VScroll, AddressOf capturedVScroll
                              > > >>>>>
                              > > >>>>> Step 2: Added the following to the code in UserControl1
                              > > >>>>>
                              > > >>>>> Private Sub capturedVScroll (ByVal sender As Object, _
                              > > >>>>> ByVal e As System.EventArg s)
                              > > >>>>> Debug.WriteLine ("capturedVScro ll")
                              > > >>>>> End Sub
                              > > >>>>>
                              > > >>>>>
                              > > >>>>> My final code therefore looks like this, but just one more tweak
                              > > >>>>> is necessary before I can get it to compile and work.
                              > > >>>>>
                              > > >>>>> Colin
                              > > >>>>>
                              > > >>>>> Public Class Form1
                              > > >>>>> Inherits System.Windows. Forms.Form
                              > > >>>>>
                              > > >>>>> '============== ========
                              > > >>>>> ' Windows Form Designer generated code
                              > > >>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                              > > >>>>> '============== ========
                              > > >>>>>
                              > > >>>>> Public Class UserControl1
                              > > >>>>> Inherits System.Windows. Forms.UserContr ol
                              > > >>>>> Protected Overrides Sub OnPaint(ByVal p As PaintEventArgs)
                              > > >>>>> MyBase.OnPaint( p)
                              > > >>>>> p.Graphics.Clea r(BackColor)
                              > > >>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                              > > >>>>> clientRectangle .Width, _
                              > > >>>>> ClientRectangle .Height, _
                              > > >>>>> 0, 0)
                              > > >>>>> End Sub
                              > > >>>>>
                              > > >>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                              > > >>>>> System.Object, _ ByVal e As System.EventArg s) _
                              > > >>>>> Handles MyBase.Load
                              > > >>>>> Me.BackColor = Color.Yellow
                              > > >>>>> AddHandler VScroll, AddressOf capturedVScroll 'ERROR
                              > > >>>>> HERE End Sub
                              > > >>>>>
                              > > >>>>> Private Sub capturedVScroll (ByVal sender As Object, _
                              > > >>>>> ByVal e As System.EventArg s)
                              > > >>>>> Debug.WriteLine ("capturedVScro ll")
                              > > >>>>> End Sub
                              > > >>>>>
                              > > >>>>> End Class
                              > > >>>>>
                              > > >>>>>
                              > > >>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                              > > >>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                              > > >>>>> Dim uc As New UserControl1
                              > > >>>>> uc.Location = New Point(0, 0)
                              > > >>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                              > > >>>>> uc.BackColor = Color.Yellow
                              > > >>>>> uc.AutoScroll = True
                              > > >>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                              > > >>>>> uc.Visible = True
                              > > >>>>> Me.Controls.Add (uc)
                              > > >>>>> Size = New Size(New Point(300, 300))
                              > > >>>>>
                              > > >>>>> Dim lb As New Label
                              > > >>>>> lb.Location = New Point(0, 150)
                              > > >>>>> lb.Size = New Size(290, 80)
                              > > >>>>> lb.Text = "1.Move the scrollbars,the diagonal line isn't"
                              > > >>>>> + _ " drawn from(0,0) to (width,height).
                              > > >>>>> 2.Minimize" + _ " this form. 3. Restore the form
                              > > >>>>> size,now the " + _ "line does go from (0,0) to
                              > > >>>>> (width,height). " + _ "Why, why isn't the
                              > > >>>>> diagonal line and " + _ "control background
                              > > >>>>> cleared as you scroll?" Me.Controls.Add (lb)
                              > > >>>>> End Sub
                              > > >>>>> End Class
                              > > >>>>>
                              > > >>>>>
                              > > >>>>>
                              > > >>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                              > > >>>>> news:blh8sf$k5k $1@titan.btinte rnet.com...
                              > > >>>>>> You need to repaint on VScroll. Your user control inherits from
                              > > >>>>>> Scrollable class and this event is protected so as you have
                              > > >>>>>> inherited this you should be able to add a handler and force the
                              > > >>>>>> control to repaint.
                              > > >>>>>>
                              > > >>>>>>
                              > > >>>>>>
                              > > >>>>>>
                              > > >>>>>>
                              > > >>>>>>
                              > > >>>>>> Colin McGuire wrote:
                              > > >>>>>>> You're not going to make me thank you again I hope :)
                              > > >>>>>>>
                              > > >>>>>>> Here is some more elaboration of my problem.
                              > > >>>>>>>
                              > > >>>>>>> What I see is:
                              > > >>>>>>>
                              > > >>>>>>> 1. When I move the vertical scrollbar by clicking "in"
                              > > >>>>>>> the scrollbar (ie between the up arrow and down arrow),
                              > > >>>>>>> the diagonal line is drawn properly (diagram below).
                              > > >>>>>>>
                              > > >>>>>>> +----------+
                              > > >>>>>>> |\ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \|
                              > > >>>>>>> +----------+
                              > > >>>>>>>
                              > > >>>>>>> 2. When I click the "down arrow" button on the vertical
                              > > >>>>>>> scrollbar, the diagonal scrolls, but I can see a tiny
                              > > >>>>>>> bit of the new diagonal showing up - sort of looks like
                              > > >>>>>>>
                              > > >>>>>>> +---\-------+
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \ |
                              > > >>>>>>> | \|
                              > > >>>>>>> | |
                              > > >>>>>>> | |
                              > > >>>>>>> | \|
                              > > >>>>>>> +-----------+
                              > > >>>>>>>
                              > > >>>>>>> 3. When I add a Debug.WriteLine ("OnPaint") inside
                              > > >>>>>>> the OnPaint method, both clicking "in" the scrollbar
                              > > >>>>>>> and clicking the up or down arrow of the scrollbar
                              > > >>>>>>> appear produce "OnPaint" in the IDE debug window.
                              > > >>>>>>>
                              > > >>>>>>> 4. When I minimise this (corrupted window, step 2), then
                              > > >>>>>>> maximize it again, then it redraws properly with
                              > > >>>>>>> the diagonal from (0,0) to (width,height) as shown
                              > > >>>>>>> in Step 1.
                              > > >>>>>>>
                              > > >>>>>>> BTW: I forgot to paste in the
                              > > >>>>>>>
                              > > >>>>>>> p.Graphics.Clea r(BackColor)
                              > > >>>>>>>
                              > > >>>>>>> in my original post before the
                              > > >>>>>>> p.Graphics.Draw Line .... but
                              > > >>>>>>> it doesn't make any difference if I do.
                              > > >>>>>>>
                              > > >>>>>>> Thank you
                              > > >>>>>>> Colin
                              > > >>>>>>>
                              > > >>>>>>>
                              > > >>>>>>>
                              > > >>>>>>>
                              > > >>>>>>>
                              > > >>>>>>>
                              > > >>>>>>> "One Handed Man" <Bombay@Duck.ne t> wrote in message
                              > > >>>>>>> news:blh02f$kg9 $1@hercules.bti nternet.com...
                              > > >>>>>>>> What happens then ?
                              > > >>>>>>>>
                              > > >>>>>>>>
                              > > >>>>>>>> Colin McGuire wrote:
                              > > >>>>>>>>> I apologize for posting yet another scrollbar question. Here
                              > > >>>>>>>>> is my code. All I want is for a diagonal line to appear from
                              > > >>>>>>>>> coordinates (0,0) to (width,height) in a usercontrol
                              > > >>>>>>>>> regardless of whether the user autoscrolls the usercontrol
                              > > >>>>>>>>> (other things that are on the usercontrol I want to scroll,
                              > > >>>>>>>>> but haven't included any here).
                              > > >>>>>>>>>
                              > > >>>>>>>>> Here are the steps to reproduce my problem.
                              > > >>>>>>>>>
                              > > >>>>>>>>> 1. Launch Visual Studio and create a new Windows
                              > > >>>>>>>>> application with "Form1".
                              > > >>>>>>>>> 2. Paste the following in (remember to include
                              > > >>>>>>>>> your "Windows Form Designer generated code).
                              > > >>>>>>>>> 3. Run - instructions are in the program that runs.
                              > > >>>>>>>>>
                              > > >>>>>>>>> I am using "Microsoft Development Environment 2003, Version
                              > > >>>>>>>>> 7.1.3088". I am using "Microsoft .NET Framework 1.1, Version
                              > > >>>>>>>>> 1.1.4322"
                              > > >>>>>>>>>
                              > > >>>>>>>>> Thank you for your patience with me.
                              > > >>>>>>>>> Colin
                              > > >>>>>>>>>
                              > > >>>>>>>>>
                              > > >>>>>>>>>
                              > > >>>>>>>>> Public Class Form1
                              > > >>>>>>>>> Inherits System.Windows. Forms.Form
                              > > >>>>>>>>>
                              > > >>>>>>>>> '============== ========
                              > > >>>>>>>>> ' Windows Form Designer generated code
                              > > >>>>>>>>> ' (INCLUDE HERE FOR FORM1 FROM YOUR IDE, NOT POSTED HERE)
                              > > >>>>>>>>> '============== ========
                              > > >>>>>>>>>
                              > > >>>>>>>>> Public Class UserControl1
                              > > >>>>>>>>> Inherits System.Windows. Forms.UserContr ol
                              > > >>>>>>>>> Protected Overrides Sub OnPaint(ByVal p As
                              > > >>>>>>>>> PaintEventArgs) MyBase.OnPaint( p)
                              > > >>>>>>>>> p.Graphics.Draw Line(New Pen(Color.Black ), _
                              > > >>>>>>>>> clientRectangle .Width, _
                              > > >>>>>>>>> ClientRectangle .Height, _
                              > > >>>>>>>>> 0, 0)
                              > > >>>>>>>>> End Sub
                              > > >>>>>>>>>
                              > > >>>>>>>>> Private Sub UserControl1_Lo ad(ByVal sender As
                              > > >>>>>>>>> System.Object, _ ByVal e As System.EventArg s) _
                              > > >>>>>>>>> Handles MyBase.Load
                              > > >>>>>>>>> Me.BackColor = Color.Yellow
                              > > >>>>>>>>> End Sub
                              > > >>>>>>>>> End Class
                              > > >>>>>>>>>
                              > > >>>>>>>>>
                              > > >>>>>>>>> Private Sub Form1_Load(ByVa l sender As System.Object, _
                              > > >>>>>>>>> ByVal e As System.EventArg s) Handles MyBase.Load
                              > > >>>>>>>>> Dim uc As New UserControl1
                              > > >>>>>>>>> uc.Location = New Point(0, 0)
                              > > >>>>>>>>> uc.Size = New System.Drawing. Size(New Point(100, 100))
                              > > >>>>>>>>> uc.BackColor = Color.Yellow
                              > > >>>>>>>>> uc.AutoScroll = True
                              > > >>>>>>>>> uc.AutoScrollMi nSize = New Size(New Point(200, 300))
                              > > >>>>>>>>> uc.Visible = True
                              > > >>>>>>>>> Me.Controls.Add (uc)
                              > > >>>>>>>>> Size = New Size(New Point(300, 300))
                              > > >>>>>>>>>
                              > > >>>>>>>>> Dim lb As New Label
                              > > >>>>>>>>> lb.Location = New Point(0, 150)
                              > > >>>>>>>>> lb.Size = New Size(290, 80)
                              > > >>>>>>>>> lb.Text = "1.Move the scrollbars,the diagonal line
                              > > >>>>>>>>> isn't" + _ " drawn from(0,0) to
                              > > >>>>>>>>> (width,height).
                              > > >>>>>>>>> 2.Minimize" + _ " this form. 3. Restore the
                              > > >>>>>>>>> form size,now the " + _ "line does go from
                              > > >>>>>>>>> (0,0) to (width,height). " + _ "Why, why
                              > > >>>>>>>>> isn't the diagonal line and " + _ "control
                              > > >>>>>>>>> background cleared as you scroll?" Me.Controls.Add (lb)
                              > > >>>>>>>>> End Sub
                              > > >>>>>>>>> End Class[/color]
                              > >
                              > >[/color]
                              >[/color]

                              Comment

                              Working...