Log in

View Full Version : Yellow Progress Bar?


Melchior
02-26-2004, 11:57 AM
Hi,

I am not a developer but a client for a development so excuse me for not using correct 'tech-speak'.

On our application we requested that a yellow progress bar is shown but our developers tell me that it is only available in blue. Is that correct or is there a way to specify the colour of the bar.

Here is what they wrote to me:

"It is possible to change the default color of the progress bar on desktop but not on Pocket PC. The default color of the progress bar on Pocket PC is blue. "

Thanks for any advice.

Melchior

rhmorrison
02-26-2004, 01:38 PM
All messages from thread
Message 1 in thread
From: Martin ([email protected])
Subject: Progress bar color


View this article only
Newsgroups: microsoft.public.pocketpc.developer
Date: 2002-10-23 11:16:04 PST


PocketPC 2002 does not appear to support PBM_SETBARCOLOR
message. Any ideas on how to change the progress bar
color? Maybe subclassing it and hooking what message?
Thanks,
Martin
Message 2 in thread
From: Alexander Shargin ([email protected])
Subject: Re: Progress bar color


View this article only
Newsgroups: microsoft.public.pocketpc.developer
Date: 2002-10-24 05:32:02 PST


I can see no way to customize the color of the progress bar. But progress
bar is a pretty simple control and you can always reimplement it from
scratch.

--
Sincerely,
Alexander

mailto:[email protected]
http://www.RSDN.ru - Russian Software Developer Network

"Martin" <[email protected]> wrote in message
news:be0101c27abf$4fd693c0$3aef2ecf@TKMSFTNGXA09...
> PocketPC 2002 does not appear to support PBM_SETBARCOLOR
> message. Any ideas on how to change the progress bar
> color? Maybe subclassing it and hooking what message?
> Thanks,
> Martin

Based on this I ASSUME that the only way to get what you want would be to implement your own progress bar control which as stated should not be any big deal to implement.

rhmorrison
02-26-2004, 05:27 PM
From: Jeff Armstrong ([email protected])
Subject: Re: Progress Bar
View: Complete Thread (9 articles)
Original Format
Newsgroups: comp.os.ms-windows.programmer.tools.mfc, comp.os.ms-windows.programmer.win32, microsoft.public.win32.programmer.ui
Date: 2000/05/03


I wrote a progress bar class that displays the progress as a solid bar with
a percentage XOR'd with the bar color as the progress increases. (I didn't
like the CProgressBar provided by MFC) Following is the code that draws the
actual drawing. I can give you (or anyone else in this newsgroup) a copy of
the entire class if you would like to EMail me at [email protected]

void CProgressBar::DrawBar(CDC &cdcBar)
{
CBrush cbrBrush,
cbrBar;
CRect rctColor,
rctClient;
WORD wCx,
wRange;
CFont cfFont;
CDC cdcBase,
cdcMem;
CBitmap cbmpBase, // BMP for memory DC
cbmpText; // BMP for memory DC

ASSERT_VALID(this);

// Get dimensions of progress bar
GetClientRect(&rctClient);

// Create a bitmap compatible with the screen.
// This will be used to blit the completed progress bar and thus prevent any
flicker.
cdcBase.CreateCompatibleDC(&cdcBar);
cdcBase.SaveDC();

// Create a bitmap compatible with the screen
cbmpBase.CreateCompatibleBitmap(&cdcBar, rctClient.right,
rctClient.bottom);
cdcBase.SelectObject(cbmpBase);

// Create a white canvass to draw on
cdcBase.SelectObject(GetStockObject(WHITE_BRUSH));
cdcBase.SelectObject(GetStockObject(WHITE_PEN));
cdcBase.Rectangle(rctClient);

// Calculate how far to display color
wRange = m_wEnd - m_wStart;
rctColor = rctClient;
wCx = (WORD)(((float)(m_wPosition) * rctClient.right)/wRange + 0.5);

// Now draw the color portion
rctColor.right = rctColor.left + wCx;
cbrBar.CreateSolidBrush(m_rgbColor);
cdcBase.FillRect(&rctColor, &cbrBar);

// Display the percentage complete
CString cszPct;

cszPct.Format(_T("%d %%"), (m_wPosition*100)/wRange);

// Draw text to a bitmap in memory
cdcMem.CreateCompatibleDC(&cdcBase);
cdcMem.SaveDC();

// Create a bitmap compatible with the screen
cbmpText.CreateCompatibleBitmap(&cdcBase, rctClient.right,
rctClient.bottom);
cdcMem.SelectObject(cbmpText);

// Make our memory bitmap all white
cdcMem.SelectObject(GetStockObject(WHITE_BRUSH));
cdcMem.SelectObject(GetStockObject(WHITE_PEN));
cdcMem.Rectangle(rctClient);

// Select a 10-point Times New Roman font
cfFont.CreatePointFont(100, _T("Times New Roman"), &cdcBase);
cdcMem.SelectObject(&cfFont);

// Give our text a transparent background
cdcMem.SetBkMode(TRANSPARENT);
cdcMem.SetTextColor(m_rgbColor);

// Finally, draw our text
cdcMem.DrawText(
cszPct,
cszPct.GetLength(),
rctClient,
DT_CENTER | DT_SINGLELINE | DT_VCENTER);

// Now blit the text bitmap to the bar
// NOTE: We want colored text to change to white as the progress
// bar moves underneath it. The ternary raster code for
// this is DSxn, index 99 in the ternary raster code table.
cdcBase.BitBlt(
0, 0,
rctClient.right, rctClient.bottom,
&cdcMem,
0, 0,
0x00990066 // DSxn raster code
);

// Blit the completed progress bar to the destination DC
cdcBar.BitBlt(
0, 0,
rctClient.right, rctClient.bottom,
&cdcBase,
0, 0,
SRCCOPY // Blit source to dest. DC
);

// Restore our original device context
cdcMem.RestoreDC(-1);
cdcBase.RestoreDC(-1);
}

Jeff Armstrong
Sr. Programmer
ProModel Corporation

"Michael D. Ober" <[email protected]> wrote in message
news:[email protected]...
> How do I put a XOR'd percent complete on top of a progress bar control.
> Win98's setup program contains an example where the progress bar shows a
> graphic status and the actual percent complete is displayed right on top of
> the progress bar.
>
> Thanks,
> Mike Ober.
This might be a good start.
Better would be to contact Jeff Armstrong, [email protected], and ask him to send you the complete code.

Melchior
02-26-2004, 07:00 PM
Wow, what a great response! Thanks Bob :D