Creating a loading bar in C

This is a discussion on Creating a loading bar in C within the Windows Programming forums, part of the Platform Specific Boards category; Hey, how do i create a loading bar in Dev C Bloodshed. I am using windows 7 and my compiler ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    45

    Creating a loading bar in C

    Hey, how do i create a loading bar in Dev C Bloodshed.
    I am using windows 7 and my compiler is Bloodshed Dev C++

    I need to create this for my program

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    1,220
    If your needs are simple and a text based program, you can print a line with the line-feed character to simulate this. Here is an example

    Code:
    #define DOTS_10 ".........."
    #define SPAC_10 "          "
    int main(void)
    {
        for (int i=1; i <= 10; i++) {
            do_something();
            printf("%1.*s", i, DOTS_10);
            printf("%1.*s\r", 10-i, SPAC_10);        
        }
        printf("\nDone!\n");
        return EXIT_SUCCESS;
    }
    Each time you print \r the cursor goes to the beginning of the line and overwrites what was there before. So the result gradually completes to show the entire line of dots

    A more sophisticated approach is to use a GUI library which has classes and methods for drawing graphical progress bars to the screen. There are also text-based libraries which have these as well. Ncurses + CDK is one example for text mode.

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    45
    How would i create the graphical progress bars

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    1,220
    To create graphical progress bars, use a GUI library. Examples are Qt, GTK and on Windows you can use the WINAPI if you want. Try searching for winapi progress bar example for examples

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    > I am using windows 7 and my compiler is Bloodshed Dev C++
    The last supported OS for bloodshed dev-c++ was windows 2000.

    Perhaps you should upgrade.
    Visual Studio Express 2012 Products | Microsoft Visual Studio
    smorgasbordet - Pelles C
    Code::Blocks
    Orwell Dev-C++ | Free Development software downloads at SourceForge.net

    Oh, and moved to the windows board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Mar 2013
    Posts
    7
    Project Progress Bar in Codeblocks - XP Visual Style:
    Win API - Capítulo 50 Barra de progreso

    Regards

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. loading bar
    By brack in forum C Programming
    Replies: 42
    Last Post: 03-16-2011, 07:08 AM
  2. loading .h, .dll, and .lib
    By sigh in forum Windows Programming
    Replies: 4
    Last Post: 02-08-2008, 01:32 AM
  3. Loading an exe
    By Supar in forum C++ Programming
    Replies: 3
    Last Post: 05-28-2003, 11:32 PM
  4. Creating a loading symbol
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-30-2001, 03:10 PM
  5. Loading.......................
    By Stealth in forum C++ Programming
    Replies: 5
    Last Post: 10-31-2001, 05:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21