Thread: Status bar in Dialog Box

  1. #16
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    OK, I'm only posting this because you have to finish by tomorrow and I'm going. I suggest you think about it a bit more before reading on. MoveWindow is irrelevant. The important fact is that GetDlgItem(hwnd, ID_PROGRESS) is failing after the call to SetParent(). Why?


























    After you call SetParent(), hwnd is no longer the parent of ID_PROGRESS. Therefore:
    Code:
    GetDlgItem(hwnd,ID_PROGRESS)
    will fail. The new parent is the status bar so we have to use that in the call to GetDlgItem with the equivalent of:
    Code:
    GetDlgItem(GetDlgItem(hwnd, ID_STATUS), ID_PROGRESS)
    Here is the code that I used:
    Code:
    		case WM_INITDIALOG:
    		{
    			RECT rc;
    			HWND hwndStatus = GetDlgItem(hwndDlg, ID_STATUS);
    			HWND hwndProgress = GetDlgItem(hwndDlg, ID_PROGRESS);
    
    			SetParent(hwndProgress, hwndStatus);
    			SendMessage(hwndProgress, PBM_SETPOS, 50, 0);
    			GetClientRect(hwndStatus, &rc);
    			MoveWindow(hwndProgress, rc.left + 1, rc.top + 1, rc.right - 2, rc.bottom - 2, TRUE);
    			return TRUE;
    		}
    
    		case WM_SIZE:
    		{
    			RECT rc;
    			HWND hwndStatus = GetDlgItem(hwndDlg, ID_STATUS);
    			HWND hwndProgress = GetDlgItem(hwndStatus, ID_PROGRESS);
    
    			SendMessage(hwndStatus, WM_SIZE, wParam, lParam);
    			GetClientRect(hwndStatus, &rc);
    			MoveWindow(hwndProgress, rc.left + 1, rc.top + 1, rc.right - 2, rc.bottom - 2, TRUE);
    			break;
    		}
    and the RC contents:
    Code:
        CONTROL         "", ID_STATUS, STATUSCLASSNAME, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0
        CONTROL         "", ID_PROGRESS, PROGRESS_CLASS, WS_CHILD | WS_VISIBLE, 0, 0, 100, 10

  2. #17
    Registered User
    Join Date
    May 2004
    Posts
    215
    Code:
    MoveWindow(GetDlgItem((GetDlgItem(hwnd,ID_STATUS_SEARCH)),ID_PROGRESS), rect.left, rect.top, rect.right, rect.bottom, TRUE);
    is that it?
    Last edited by osal; 07-25-2004 at 11:32 AM.

  3. #18
    Registered User
    Join Date
    May 2004
    Posts
    215
    yep thanks, that looks like thats it!, ive got a question, i just want the progress bar in one part of the status bar, i mean i have it in all of it, but i want to keep my status bar in three pieces and in one piece will be some text, the next the progress bar, and the other more text, is there a function like SB_SET or something to put it in the second part?

  4. #19
    Registered User
    Join Date
    May 2004
    Posts
    215
    nevermind i think i might have gotten it, sorry! and thanks!

  5. #20
    Registered User
    Join Date
    May 2004
    Posts
    215
    im trying to get the progress bar to move, but it wont, heres what i got

    Code:
     SendMessage(GetDlgItem((GetDlgItem(hwnd,ID_STATUS_SEARCH)),ID_PROGRESS),PBM_SETSTEP,(WPARAM)10,0);
    
    		  SendMessage(GetDlgItem((GetDlgItem(hwnd,ID_STATUS_SEARCH)),ID_PROGRESS),PBM_STEPIT,0,0);

  6. #21
    Registered User
    Join Date
    May 2004
    Posts
    215
    Ok, im working with the progress bar, is there a way to make the timer start a specific time, lets say when the user clicks a button, and then make it stop when when the function is done instead of making it work for a certain amount of time? like instead of putting a 5 second lapse at 5000 make it go until a function is done?

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