March 8, 2021

glimworm

Advances in world technology

progressbar – vb.Internet Development Bar With Text



Reverend Jim

3,430



Hello, I’m Jim, a person of DaniWeb’s moderators.



Moderator



Showcased Poster


The next a person (unused b) was leftover code from earlier attempts whilst figuring the current variation out. I just neglected to take away it. Thanks for noting what could be improved.




Edited

by Reverend Jim

Member Avatar

Hi RJ –

I would like to use your CustomProgress handle with a StatusStrip manage throughout style-time (by using the IDE). Can you demonstrate me how to add the CustomProgress command to the StatusStrip control’s fall-down list of controls?

This would enable me to use your CustomProgress control alternatively of the typical ProgressBar management with the StatusStrip control on my sort. Thanks.


Edited

by [email protected]

Member Avatar

Hi RJ –

This is what I was able to create as a solution to my inquery..

2020-04-05_20-31-36.png

Here is what I have place collectively (it may perhaps not be the “most effective” technique, so I would recognize it if you have any tips)…

'   https://stackoverflow.com/issues/7608556/how-to-make-tailor made-toolstripprogressbar-in-c-sharp-home windows-kinds

Imports Program.Home windows.Kinds.Design '...demanded for ToolStripItemDesignerAvailability


Community Class ToolStripProgressBarC
    Inherits MyCustomToolStripControlHost

    '...phone the foundation constructor passing in a myCustomProgressBar occasion
    General public Sub New()
        MyBase.New(New myCustomProgressBar)
        CType(Manage, myCustomProgressBar).Style = ProgressBarStyle.Ongoing
    Finish Sub

    General public ReadOnly House ProgressBarControl As myCustomProgressBar
        Get
            Return CType(Handle, myCustomProgressBar)
        Conclude Get
    Conclusion Property

    '...expose the myCustomProgressBar.Benefit as a residence
    Public Home Price As Integer
        Get
            Return Me.ProgressBarControl.Value
        Conclusion Get
        Set
            Me.ProgressBarControl.Benefit = Benefit
        End Established
    Conclude Assets
Conclusion Course

General public Course MyCustomToolStripControlHost
    Inherits ToolStripControlHost

    Community Sub New()
        MyBase.New(New Management())
    Stop Sub

    Public Sub New(ByVal c As Regulate)
        MyBase.New(c)
    Close Sub
Stop Course

Public Course myCustomProgressBar

    '   https://www.daniweb.com/programming/application-growth/code/519610/vb-web-progress-bar-with-text

    Inherits ProgressBar

    General public Overrides Property Textual content As String
    '...http://www.pinvoke.net/default.aspx/Constants/WM.html
    '   WM_PAINT = &HF  decimal value = 15...CDec("&H0F") = 15
    Private Const WmPaint = 15

    '...WndProc receives all messages directed to the existing window. In purchase to
    '   prevent overwriting your text, make sure the default code executes initial,
    '   then get in touch with the custom made regime to exhibit the overlaid textual content

    Guarded Overrides Sub WndProc(ByRef m As Process.Windows.Sorts.Information)
        MyBase.WndProc(m)
        If m.Msg = WmPaint Then
            PaintText()
        Conclusion If
    Conclude Sub

    Personal Sub PaintText()

        Dim s As String = Text

        '...exhibit both a proportion or custom made textual content

        If s = "" Then
            Dim percent = CInt(100 * (Worth - Least) / (Maximum - Least))
            s = per cent.ToString & "%"
        Conclude If

        '...get the graphics object and compute drawing parameters based mostly on the latest Font specs

        Making use of g As Graphics = Me.CreateGraphics()
            Dim textSize As SizeF = g.MeasureString(s, Me.Font)
            Working with b = New SolidBrush(ForeColor)
                g.DrawString(s, Me.Font, Brushes.Black, CSng(Me.Width / 2 - textSize.Width / 2), CSng(Me.Height / 2 - textSize.Height / 2))
            Stop Using
        Finish Making use of

    Finish Sub

Conclude Course

Thank you all over again for your assistance!


Edited

by [email protected]