More PROGRESSBAR help!(SIMPLE!)

This is a discussion on More PROGRESSBAR help!(SIMPLE!) within the Windows Programming forums, part of the Platform Specific Boards category; Here's some code: LPCH pch; LPCH pchTemp; switch (message) /* handle the messages */ { case WM_CREATE: InitCommonControls(); hFile = ...

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question More PROGRESSBAR help!(SIMPLE!)

    Here's some code:

    LPCH pch;
    LPCH pchTemp;

    switch (message) /* handle the messages */
    {
    case WM_CREATE:
    InitCommonControls();

    hFile = CreateFile("C:/Starfield/NetStudio 1.5/NetStudio 1.5.exe", GENERIC_READ, FILE_SHARE_READ, NULL,
    OPEN_EXISTING, NULL, NULL);

    cb=GetFileSize(hFile, (LPDWORD) NULL);

    HWND pb;

    pb=CreateWindowEx(
    WS_EX_CLIENTEDGE,
    PROGRESS_CLASS,
    "",
    PBS_SMOOTH | WS_CHILD | WS_VISIBLE,
    0, 0,
    400, 20,
    hwnd,
    0,
    0,
    0
    );

    SendMessage(pb, PBM_SETBARCOLOR, 0, RGB(20,30,150));
    SendMessage(pb, PBM_SETRANGE, (WPARAM)0, (LPARAM)MAKELPARAM(0, 100));
    SendMessage(pb, PBM_SETSTEP, (WPARAM)1, (LPARAM)0);

    pch = (LPCH) LocalAlloc(LPTR, sizeof(char) * 2048);
    pchTmp = pch;

    do
    {
    ReadFile(hFile, pchTemp, sizeof(char) * 2048, &cb, (LPOVERLAPPED) NULL);

    SendMessage(pb, PBM_STEPIT, 0, 0);
    } while(cb);

    CloseHandle((HANDLE)hFile);
    break;


    When I run the program, it only progresses for about 1 block on the bar. How do I make 1 block for every 1 percent read and progress the bar?

    NOTE: Some code came from MSDN and NetStudio 1.5.exe is a program I made!
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Come on this should be easy for a published pro like you! (Or is it easier for you to get me to tell you how?)

    You have the file size, now find the ratio out of 100 (eg a percent ratio) for the read size (cb).
    Step the bar this amount of times.

    So if the file is 100Kb and you read 2Kb per read, how many TIMES to you have to send the step msg?

    //edit
    I also send this msg to ensure the progress is at the begining

    SendMessage( GetDlgItem(hhwnd,IDC_PROG), PBM_SETPOS, (WPARAM) 0,(LPARAM)0);
    Last edited by novacain; 12-13-2001 at 08:44 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Arrow Ok, now...

    Can you tell me how to get a percent ratio?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. progressBar
    By Coding in forum C# Programming
    Replies: 5
    Last Post: 02-23-2008, 07:52 AM
  2. progressbar
    By munna_dude in forum C Programming
    Replies: 8
    Last Post: 06-21-2007, 07:17 AM
  3. ProgressBar
    By Leite33 in forum Windows Programming
    Replies: 1
    Last Post: 01-15-2007, 08:21 AM
  4. Refresh ProgressBar
    By Dimeslime in forum C# Programming
    Replies: 2
    Last Post: 10-22-2003, 03:47 PM
  5. Progressbar as Part of Statusbar :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 04-26-2002, 09:59 AM

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