none
menuitem stop RRS feed

  • Question

  • hi

    The panal is designed like  a drop-down menu
    A set of buttons is placed with a drop-down menu
    Works well with me
    My problem now is that the panal time event is interrupted or irregular when there is another timer on the interface
    What do I need to add a stop properties to the timer or run the timer for the panel

    and add properties to hide or show panel

    Public Class menuitem
        Inherits System.Windows.Forms.Panel
    
        Public Sub New()
            MyBase.New()
        
        End Sub
    
        Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
            MyBase.OnPaint(e)
            Dim borderWidth As Integer = 2
            ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset)
            ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.LightGray, ButtonBorderStyle.Solid)
    
        End Sub
    
        Protected Overrides Sub OnResize(ByVal eventargs As EventArgs)
            MyBase.OnResize(eventargs)
            Me.Invalidate()
        End Sub
    
        Protected Overrides Sub OnLostFocus(e As System.EventArgs)
            MyBase.OnLostFocus(e)
           
            Me.Hide()
            Me.Dispose()
        End Sub
    
        Protected Overrides Sub OnLeave(ByVal e As EventArgs)
            MyBase.OnLeave(e)
            Dim t As New Timer With {.Interval = 12000, .Enabled = True}
            AddHandler t.Tick, Sub()
                                   t.Stop()
                                   Me.Hide()
                               End Sub
        End Sub
    
    
        Protected Overrides Sub OnMouseLeave(e As System.EventArgs)
            MyBase.OnMouseLeave(e)
            Dim t As New Timer With {.Interval = 12000, .Enabled = True}
            AddHandler t.Tick, Sub()
                                   t.Stop()
                                   Me.Hide()
                               End Sub
        End Sub
          
    End Class




    • Edited by ahmeddc Tuesday, May 21, 2019 7:38 AM
    Tuesday, May 21, 2019 7:34 AM

Answers


  • 1-I want to add a property to the appearance or hide tool

    2- Add a property and activate the time for the two events only on leave ,on mous leave

    yes

    Hi,

    1.Can't the Visible property of the control meet your requirements?

    2.This also does not require any attributes, just declare the timer as a global variable, so you can close or open the timer.

      Public Class menuitem
    
            Inherits System.Windows.Forms.Panel
            Public t1 As New Timer With {.Interval = 12000, .Enabled = True}
            Public t2 As New Timer With {.Interval = 12000, .Enabled = True}
    
    
    
            Public Sub New()
                MyBase.New()
    
            End Sub
    
            Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
                MyBase.OnPaint(e)
                Dim borderWidth As Integer = 2
                ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset)
                ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.LightGray, ButtonBorderStyle.Solid)
    
            End Sub
    
            Protected Overrides Sub OnResize(ByVal eventargs As EventArgs)
                MyBase.OnResize(eventargs)
                Me.Invalidate()
            End Sub
    
            Protected Overrides Sub OnLostFocus(e As System.EventArgs)
                MyBase.OnLostFocus(e)
    
                Me.Hide()
                Me.Dispose()
            End Sub
    
            Protected Overrides Sub OnLeave(ByVal e As EventArgs)
                MyBase.OnLeave(e)
    
                AddHandler t1.Tick, Sub()
                                        t1.Stop()
                                        Me.Hide()
                                    End Sub
            End Sub
    
    
            Protected Overrides Sub OnMouseLeave(e As System.EventArgs)
                MyBase.OnMouseLeave(e)
    
                AddHandler t2.Tick, Sub()
                                        t2.Stop()
                                        Me.Hide()
                                    End Sub
            End Sub
    
        End Class
      Dim p As New menuitem
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            p.t1.Enabled = False
            p.t2.Enabled = False
    
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ahmeddc Thursday, May 23, 2019 11:24 AM
    Wednesday, May 22, 2019 7:17 AM

All replies

  • Hi,

    Do you mean that when a timer starts running, other timers must be turned off?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 22, 2019 1:59 AM
  • Hi,

    Do you mean that when a timer starts running, other timers must be turned off?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Do you mean that when a timer starts running, other timers must be turned off?

    1-I want to add a property to the appearance or hide tool

    2- Add a property and activate the time for the two events onlyon leave ,on mous leave

    yes

    Wednesday, May 22, 2019 2:32 AM

  • 1-I want to add a property to the appearance or hide tool

    2- Add a property and activate the time for the two events only on leave ,on mous leave

    yes

    Hi,

    1.Can't the Visible property of the control meet your requirements?

    2.This also does not require any attributes, just declare the timer as a global variable, so you can close or open the timer.

      Public Class menuitem
    
            Inherits System.Windows.Forms.Panel
            Public t1 As New Timer With {.Interval = 12000, .Enabled = True}
            Public t2 As New Timer With {.Interval = 12000, .Enabled = True}
    
    
    
            Public Sub New()
                MyBase.New()
    
            End Sub
    
            Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
                MyBase.OnPaint(e)
                Dim borderWidth As Integer = 2
                ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset)
                ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.LightGray, ButtonBorderStyle.Solid)
    
            End Sub
    
            Protected Overrides Sub OnResize(ByVal eventargs As EventArgs)
                MyBase.OnResize(eventargs)
                Me.Invalidate()
            End Sub
    
            Protected Overrides Sub OnLostFocus(e As System.EventArgs)
                MyBase.OnLostFocus(e)
    
                Me.Hide()
                Me.Dispose()
            End Sub
    
            Protected Overrides Sub OnLeave(ByVal e As EventArgs)
                MyBase.OnLeave(e)
    
                AddHandler t1.Tick, Sub()
                                        t1.Stop()
                                        Me.Hide()
                                    End Sub
            End Sub
    
    
            Protected Overrides Sub OnMouseLeave(e As System.EventArgs)
                MyBase.OnMouseLeave(e)
    
                AddHandler t2.Tick, Sub()
                                        t2.Stop()
                                        Me.Hide()
                                    End Sub
            End Sub
    
        End Class
      Dim p As New menuitem
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            p.t1.Enabled = False
            p.t2.Enabled = False
    
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ahmeddc Thursday, May 23, 2019 11:24 AM
    Wednesday, May 22, 2019 7:17 AM

  • 1-I want to add a property to the appearance or hide tool

    2- Add a property and activate the time for the two events only on leave ,on mous leave

    yes

    Hi,

    1.Can't the Visible property of the control meet your requirements?

    2.This also does not require any attributes, just declare the timer as a global variable, so you can close or open the timer.

      Public Class menuitem
    
            Inherits System.Windows.Forms.Panel
            Public t1 As New Timer With {.Interval = 12000, .Enabled = True}
            Public t2 As New Timer With {.Interval = 12000, .Enabled = True}
    
    
    
            Public Sub New()
                MyBase.New()
    
            End Sub
    
            Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
                MyBase.OnPaint(e)
                Dim borderWidth As Integer = 2
                ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset, Color.White, borderWidth, ButtonBorderStyle.Outset)
                ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.LightGray, ButtonBorderStyle.Solid)
    
            End Sub
    
            Protected Overrides Sub OnResize(ByVal eventargs As EventArgs)
                MyBase.OnResize(eventargs)
                Me.Invalidate()
            End Sub
    
            Protected Overrides Sub OnLostFocus(e As System.EventArgs)
                MyBase.OnLostFocus(e)
    
                Me.Hide()
                Me.Dispose()
            End Sub
    
            Protected Overrides Sub OnLeave(ByVal e As EventArgs)
                MyBase.OnLeave(e)
    
                AddHandler t1.Tick, Sub()
                                        t1.Stop()
                                        Me.Hide()
                                    End Sub
            End Sub
    
    
            Protected Overrides Sub OnMouseLeave(e As System.EventArgs)
                MyBase.OnMouseLeave(e)
    
                AddHandler t2.Tick, Sub()
                                        t2.Stop()
                                        Me.Hide()
                                    End Sub
            End Sub
    
        End Class
      Dim p As New menuitem
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            p.t1.Enabled = False
            p.t2.Enabled = False
    
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    what about

    1-I want to add a property to the appearance or hide tool

    Wednesday, May 22, 2019 7:55 AM
  • Hi,

    like this?p.visible

     Dim p As New menuitem
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            p.Visible = True
    
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            p.Visible = False
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 22, 2019 7:59 AM