I can't seem to get the marquee style to work on a progress bar. I'm
using VS2005.
Could you guys help me out?
I've done the following:
[1] Added the following text to Properties->Linker->Manifest File-
>Additional Manifest Dependencies
"type='Win32' name='Microsoft.Windows.Common-Controls'
version='6.0.0.0' processorArchitecture='X86'
publicKeyToken='6595b64144ccf1df' language='*'"
[2] Added #define _WIN32_WINNT 0x0501 at the top of stdafx.h
[3]Added the following lines to start the marquee style:
dlgProgress.m_cProgressCtrl.ModifyStyle(0,PBS_MARQUEE,0);
dlgProgress.m_cProgressCtrl.SendMessage(PBM_SETMARQUEE,TRUE,50);
This is the class for the progress bar dialog:
class CProgressDlg : public CDialog
{
DECLARE_DYNCREATE(CProgressDlg)
public:
CProgressCtrl m_cProgressCtrl;
protected:
virtual void DoDataExchange(CDataExchange *pDX);
DECLARE_MESSAGE_MAP()
};
Is it a Unicode build?
Dave
Yup.. its a unicode build
It is an XP or later OS - and do your other controls show up themed?
I can't think what else to suggest. Code I've had for a long time just
does this:
HWND hProg = ::GetDlgItem( ghDlgCancel, IDC_PROGRESS );
DWORD dwStyle = ::GetWindowLong( hProg, GWL_STYLE );
dwStyle |= PBS_MARQUEE;
::SetWindowLong( hProg, GWL_STYLE, dwStyle );
::SendMessage( hProg, PBM_SETMARQUEE, TRUE, 200 );
Dave
What do you think? Is there anything else i could check?
Ah, so presumably it looks like it's the marquee style, but doesn't
actually change?
Is your application allowing Windows messages to be handled during
your operation?
Dave
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
To test the marquee style, I commented out the destroy command. The
marquee style was working but only when the result dialog was being
displayed.
Need your advice. How do you structure your program for the marquee
progress bar to work properly?
At the moment, my program flow is something like below:
[1]Create Start/Main Dialog
[2]OnOk->Create calculation thread and create progress bar dialog
-> Once calculation is complete, progress bar dialog is
destroyed.
-> Result dialog is created to display the calculation
result.
Please advise :)
Justin
>I'm still unable to make it work properly but Both of you pointed me
>to the right direction.
>Originally, after i had created the dialog containing the progress
>bar, i enter into a loop checking on the progress of the calculation
>that sits on another thread.
****
Absolutely wrong. NEVER do this, ever. Besides not working, it is inefficient and
guarantees you will peak CPU utilization at 100%, all of which is spent doing nothing.
Instead, make it the responsibility of the thread to send notifications of progress!
****
>After the calculation is done, the loop breaks and i destroy the
>progress bar dialog, then i create another dialog showing the result
>of the calculation.
>
>To test the marquee style, I commented out the destroy command. The
>marquee style was working but only when the result dialog was being
>displayed.
>
>Need your advice. How do you structure your program for the marquee
>progress bar to work properly?
****
See above. I use user-defined messages such as
UWM_SET_PROGRESS
where the WPARAM or LPARAM holds the value for the progress bar.
****
>At the moment, my program flow is something like below:
>[1]Create Start/Main Dialog
>[2]OnOk->Create calculation thread and create progress bar dialog
> -> Once calculation is complete, progress bar dialog is
>destroyed.
****
Here's a problem: if this is a dialog-based app, destroying the main dialog in OnOK will
make most other things no longer work. So it doesn't make sense to do this. You can have
a button that says "start computation" but coupling this to IDOK is probably a design
mistake.
joe
****
> -> Result dialog is created to display the calculation
>result.
>
>Please advise :)
>
>Justin
Thanks so much Joseph and David for your help.
I really appreciate it!!!!