progress bar created in the status bar turns up uncover the pane

Hello Friends!!!

I create a progress bar in the status bar. But that's a still something wrong. The progress bar which should occupied the pane rectangle fail to cover all the rectangle but leave some part uncovered, I can see the progress on the surface and the end part of the IDS_PROGRESS string text uncovered. I don't know how to correct it. If your can offer some help, I will really appreciate it. thanks!

I post the code as follows:



[code]
// Create the status bar
BOOL CMainFrame::CreateStatusBar()
{
static UINT nIndicators[] = {
ID_SEPARATOR,
IDS_PROGRESS, //the pane for display the progress
IDS_TIMER, // show current time
IDS_INDICATOR_POS, // display the mouse position
ID_INDICATOR_LINE,// show the line number the cursor
//position in
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM
};

if (!m_wndStatusBar.Create (this))
return FALSE;

m_wndStatusBar.SetIndicators (nIndicators, 7);
return TRUE;
}


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

//
// Tell the frame window to permit docking.
//
EnableDocking (CBRS_ALIGN_ANY);

//
// Create the toolbar, style bar, and status bar.
//
if (!CreateToolBar () ||
!CreateStyleBar ()||!CreateStatusBar())
return -1;
//
// Load the saved bar state (if any).
//
LoadBarState (_T ("MainBarState"));


//get one pane space to create progress bar
CRect rect;
m_wndStatusBar.GetItemRect(1,&rect);
m_Progress.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH,rect,&m_wndStatusBar,IDS_PROGRESS);


SetTimer(ID_TIME,500,NULL); // For update the progress bar
return 0;
}


void CMainFrame::OnPaint()
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
if(m_Progress.GetSafeHwnd() != NULL)
{
CRect rect;
m_wndStatusBar.GetItemRect(1,&rect);
m_Progress.MoveWindow(rect);
}
// Do not call CFrameWnd::OnPaint() for painting messages
}


void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CTime time=CTime::GetCurrentTime();
int nHour=time.GetHour()%12;
int nMinu=time.GetMinute();
int nSecond=time.GetSecond();

CString str;
str.Format(_T("%0.2d:%0.2d:%0.2d"),nHour,nMinu,nSecond);
if(m_wndStatusBar.GetSafeHwnd() != NULL)
{
CClientDC dc(this);
CSize sz=dc.GetTextExtent("22:22:22");
m_wndStatusBar.SetPaneInfo(2,IDS_TIMER,SBPS_NORMAL,sz.cx);
m_wndStatusBar.SetPaneText(2,str);
}

if(m_Progress.GetSafeHwnd() == NULL)
{
CRect rect;
m_wndStatusBar.GetItemRect(1,&rect);
m_Progress.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH,rect,&m_wndStatusBar,IDS_PROGRESS);
m_Progress.SetRange(0,100);
m_Progress.SetPos(0);
}
m_Progress.StepIt();

CFrameWnd::OnTimer(nIDEvent);
}
[/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories