Thread: Status bar in Dialog Box

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    215

    Status bar in Dialog Box

    Does anyone have any idea how to add a status bar to a dialog box in an .rc file? If so, can you show me an example. thanks!

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    59
    Right click on the dialog and choose "Insert Active-X control". Choose "Microsoft Statusbar" from the list.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    If you're not using a dialog editor:
    Code:
    CONTROL "", IDD_STATUS_BAR,  STATUSCLASSNAME, WS_CHILD | WS_VISIBLE, 7, 63, 190, 8

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    215
    thanks, i just got it. Im trying to add a progress bar to the status bar, but I cant find any examples on how to do that. When I try to put the progress bar on it by the coordinates, the progress bar just seems to be overlapped by the status bar. I cant find any examples however on how to do what im trying to do. I put a search on cprogramming.com and a few came up but they werent for c/c++ win32 programming. And i searched the net, but i couldnt find anything.

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You'll will have to make the progress bar a child of the status bar. You will also have to size the progress bar appropriately.

    Code:
    // Sample: Make IDD_STATUS the parent of IDD_PROGRESS
    SetParent(GetDlgItem(IDD_PROGRESS), GetDlgItem(IDD_STATUS));
    Code:
    // Sample: Size IDD_PROGRESS to fit in the status bar
    GetClientRect(GetDlgItem(IDD_STATUS), &rect);
    MoveWindow(GetDlgItem(IDD_PROGRESS), rect.left, rect.top, rect.right, rect.bottom, TRUE);

  6. #6
    Registered User
    Join Date
    May 2004
    Posts
    215
    Hey, i tried doing that, but my progress bar disappeared. it doenst seem to work.

  7. #7
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    It should. Have you used MoveWindow as described by 'tmouse to reposition the control?

    [edit]>>but my progress bar disappeared<<

    It's more likely your statusbar has just been obscured by the progressbar. Try:
    Code:
    MoveWindow(GetDlgItem(IDD_PROGRESS),0,0,30,8,1);
    when repositioning the progress bar - it should show up as a thin strip on the left of the status bar.[/edit]
    Last edited by Ken Fitlike; 07-25-2004 at 05:51 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  8. #8
    Registered User
    Join Date
    May 2004
    Posts
    215
    still didnt work, heres the code ive done.

    Code:
    in rc file
     CONTROL "", ID_PROGRESS, PROGRESS_CLASS,WS_VISIBLE , 55, 150, 100, 30
    
    
    CONTROL  " ",ID_STATUS_SEARCH,STATUSCLASSNAME, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0,0, 0
    
    in c file
    
    SetParent(GetDlgItem(hwnd,ID_PROGRESS), GetDlgItem(hwnd,ID_STATUS_SEARCH));
    GetClientRect(GetDlgItem(hwnd,ID_STATUS_SEARCH), &rect);
    MoveWindow(GetDlgItem(hwnd,ID_PROGRESS), 0,0,30,8, TRUE);

  9. #9
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The progress bar needs the WS_CHILD style.

  10. #10
    Registered User
    Join Date
    May 2004
    Posts
    215
    did that, still doesnt show up

  11. #11
    Registered User
    Join Date
    May 2004
    Posts
    215
    i thihnk it has something to do with this:

    Code:
    	 SetParent(GetDlgItem(hwnd,ID_PROGRESS), GetDlgItem(hwnd,ID_STATUS_SEARCH));
    because when i take it out i can see the bar, but its not on the status bar, but when i put that in i dont see it anymore

  12. #12
    Registered User
    Join Date
    May 2004
    Posts
    215
    I checked the MSDN website, and it said i needed to use these two macros if im using windows xp,
    WM_CHANGEUISTATE and WM_UPDATEUISTATE.

    however, I tried compiling it and it said those were undeclared identifiers

  13. #13
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I never would have figured out this one without a few minutes of debugging.

    Code:
    SetParent(GetDlgItem(hwnd,ID_PROGRESS), GetDlgItem(hwnd,ID_STATUS_SEARCH));
    MoveWindow(GetDlgItem(hwnd,ID_PROGRESS), 0,0,30,8, TRUE);
    See the problem here? Hint: why would the call to GetDlgItem be failing in MoveWindow? Have a think about it, especially the arguments that GetDlgItem takes, before reading on. Try to figure it out.


    The rest of this message, if needed, will be posted tomorrow!

    [edit]I don't think WM_CHANGEUISTATE and WM_UPDATEUISTATE are needed here, although good work in looking them up. It's all about the arguments to GetDlgItem().[/edit]
    Last edited by anonytmouse; 07-25-2004 at 11:15 AM.

  14. #14
    Registered User
    Join Date
    May 2004
    Posts
    215
    hehe thanks, im suppose to turn this in tomorrow though. hehe ill try to figure it out though, thanks!

  15. #15
    Registered User
    Join Date
    May 2004
    Posts
    215
    Well MoveWindow moves a window but GetDlgItem takes in a window and a dialog item, so i dont know where to go from there other than the progress bar in the dialog box is just an item and not a window? i dont know if what im saying makes sense since im new to this stuff.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. beach bar (sims type game)
    By DrKillPatient in forum Game Programming
    Replies: 1
    Last Post: 03-06-2006, 01:32 PM
  3. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  4. Adding progress bar to a dialog box.
    By Brian in forum Windows Programming
    Replies: 1
    Last Post: 11-15-2002, 06:27 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM