Please help me to display a loading bar

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<conio.h>
#include<windows.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include <stdio.h>




void loading();
void gotoxy(int x, int y);
int color(int x);
void gotoxy(int x, int y);
int main(){




void loading(){



int c;
for( int x = 0; x <= 100; x++)
{
gotoxy(c,10); printf("%c",219);
gotoxy(40,12); color(10); printf("%d %%",c);
color(15);
c += 3;
Sleep(100);
}
}
system("pause>0");
int main(){



system("cls");



{

HANDLE hConsoleOutput;
COORD dwCursorPosition;
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
};

}


int color(int ncolor){
int i=ncolor; // the value of ncolor is the color code
HANDLE ConsoleSettings;
ConsoleSettings=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(ConsoleSettings,i);
}

please help to produce a loading bar with percent progress[code]
[/code]
Last edited on
What are you loading?
its just a loading bar that i want to have
a loading screen
You can "draw" a loading bar by using symbols. Like:

 
|****      |


And you can use your gotoxy function to go back and draw progressively more * symbols.


But really... a loading bar doesn't make any sense at all unless you're actually loading something. And how you make a loading bar progress accurately depends on what you're loading. IE, it has to be a process you can interrupt periodically to get an update on its status.
ok let say I'm trying to load a program that will use a loading screen how can I project those ideas into reality?? could you help me thanks
You need to have a way to get notified at different points during the process. Just loading a single program would be difficult to have a loading bar for... because there isn't really any way to interrupt the loading of the program to have it tell you how far along it is.

Usually a loading screen accompanies processes of several parts. For example, if you are loading several image files into textures, you could calculate the total number of images you have to load, then load them one at a time, updating the progress bar between each one to keep the user up-to-date on how many have been loaded.
Topic archived. No new replies allowed.