Thread: PROGRESS_CLASS and Win XP

  1. #1
    george7378
    Guest

    PROGRESS_CLASS and Win XP

    Hi, I'm having a bit of trouble with progress bars.

    I've made an app in visual C++ 2008 express which uses progress bars, and it compiles and runs fine on Windows 7, but when I try and run it on windows XP, the program exits as soon as I open it. I tried re-compiling the code on the Win XP computer, and the debugger gives me this:

    Code:
    The thread 'Win32 Thread' (0x250) has exited with code -1 (0xffffffff).
    The program '[2892] Clock.exe: Native' has exited with code -1 (0xffffffff).
    When I take the progress bars out of the resource file, it compiles and runs fine.

    I have defined the progress bars in the resource file like this:

    Code:
        CONTROL         "", IDC_PROGRESS1, PROGRESS_CLASS, PBS_SMOOTH | PBS_VERTICAL, 25, 31, 25, 85
        CONTROL         "", IDC_PROGRESS2, PROGRESS_CLASS, PBS_SMOOTH, 142, 94, 88, 21
    What could be wrong? How do I properly define progress bars?

    Thanks!

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Not entirely sure, but are you calling InitCommonControlsEx before creating the dialog box?

    It is likely that in Windows 7 that gets called by one of MS's DLLs when your program initializes, for supporting some whizzy graphics, negating the need for you to do it.

  3. #3
    george7378
    Guest
    Hi - no, I haven't done that. Would I just need to put InitCommonControlsEx(); in my WinMain()?

    Thanks for the help!

  4. #4
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Yes, WinMain's a good place to do it. One of your first calls.

    Personally I always thought that dialog creation handling was pretty good, and fell back to not creating a particular control in the event of its class not being found.
    You might also want to check around what you're looking at, just in case you cause stack corruption earlier on and this is only felt when heavy lifting occurs inside the dialog creation function. Windows 7 may mitigate that in a way that XP does not.

  5. #5
    george7378
    Guest
    Ah, that seems to have done it! I've added this in WinMain:

    Code:
    	INITCOMMONCONTROLSEX initex;
    	initex.dwSize = sizeof(INITCOMMONCONTROLSEX);
    	initex.dwICC  = ICC_PROGRESS_CLASS;
    	InitCommonControlsEx(&initex);
    and also added 'comctrl32.lib' into the 'additional dependencies' in the linker settings - it works well now

    Thanks for your extra info too, you've been a great help.

Popular pages Recent additions subscribe to a feed