Creating custom progressbar in REALbasic line

This tutorial will show you how can you create a custom Progressbar Control for REAlbasic application using Canvas Control. Watch it, learn it, enjoy it!

Creating ProgressBar for REALbasic

We will start this tutorial with adding to Window1 Class a Canvas Control. Now in it Sub Paint () event enter the code below. This will draw a frame of our rectangle when the application will start.

1
2
g.ForeColor = RGB(135,136,162) //set the color
g.DrawRect (0,0,me.Width,me.Height) //draw the frame

Displaying the progress in our ProgressBar Control

This is the most important part of Creating custom progressbar in REALbasic tutorial. We will display visually the progress in our progress bar control. Copy and paste this code for example to the Canvas1 Sub Open ().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Dim i, v, progressvalue As Integer
Dim steep As Double
Dim g As Graphics
 
v = 2000 //the final value of progress
steep = Canvas1.Width / v //getting the size of one steep
 
for i = 0 to v //get the actual progress value
 
    App.DoEvents(2) //pause for 2 ms
 
    Canvas1.Graphics.ForeColor = RGB(237,237,237) // fixing a bug with wrong drawing string
    Canvas1.Graphics.FillRect (Canvas1.Width /2 - 10,1, 30, Canvas1.Height) //draw a fill rectangle for progress text
 
    Canvas1.Graphics.ForeColor = RGB(231,121,23) //set the color
    Canvas1.Graphics.FillRect (0,2, (steep * i), Canvas1.Height-4)  //draw the progress
 
    progressvalue = i * 100 / v //get the progress value for text display
    Canvas1.Graphics.ForeColor = RGB(50,50,50) //set the color
    Canvas1.Graphics.DrawString (Str(progressvalue) + " %", Canvas1.Width /2 - 10,16) // drawing the progress string in center of ProgressBra Control
 
    Canvas1.Graphics.ForeColor = RGB(135,136,162) //set the color
    Canvas1.Graphics.DrawRect (0,0,Canvas1.Width,Canvas1.Height) //draw the frame 
 
next

Download

If you see this message you probably want access special material for Premium Members (Source Files, Bonus Tutorials, free Classes and More). You can do this by subscribing REALbasic City site for 10 USD (access for 3 months). There is also a option to buy access only to this material. Login or register to get option to buy and support REALbasic City.

Log in

Author: Jakub Pawlak

I'm interested in all. Currently working on the development of TUTSPOLIS and I hope that in near feature the project will be successful.

6 Responses to “Creating custom progressbar in REALbasic”

  1. massimo says:

    Congratulations very nice effect !

  2. Andrew says:

    Hey thanks for the Tutorial, this is cool!

  3. Jakub Pawlak says:

    Hey, I will add more tutorials showing how to create this kind of custom controls for REALbasic :)

  4. Jp says:

    While I admit that I’m a total newb to this….I’m confused on how this actually works in an app. Basically my scenario is I have a progress bar that goes 0 to 100 in chunks of 15. Each time an applescript kicks off, the progress bar inches up little by little. Is this possible with your example? Any help is good help. Thanks!

  5. Jakub Pawlak says:

    Of course this is possible to do with my example. You should make a fake progress bar that draw 15 after the applescript kicks off.

Leave a Reply

Copyrights (c) TUTSPOLIS | Powered by Wordpress MU | Inspired at Elegant Themes designed by qbap (HTML5 & CSS3)