|
Did you handle the WM_ERASEBKGND message?
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
Hi,
I'm using this source code to add a marquee progressbar which will only appear when my app is busy. However, when it is in hidden state, the progress bar will appear whenever I am resizing the window. As I implemented the ON_UPDATE_COMMAND_UI_RANGE for this control to force it to hide whenever it is not needed, it will disappear when I release the mouse to stop resizing the window. Does anyone have any idea not to make it appear at all?
I was thinking of removing the control entirely whenever it is not needed and replace it with a dummy blank control. However, I think this will make the app unstable because at the time when the control is being replaced, there will be a short moment of the control being removed. At that point of time, some other threads could be writing text on other status panes and this could crash the app is the update is on the highest index pane. This is unless, I add additional measures to protect this from happening by using mutex, etc. It will be a painful process just to hide the control.
Any advice would be appreciated.
Thanks
John
|
|
|
|
|
Why do not use RemovePane and AddPane methods?
The RemovePane method will not destroy your control if you will use the SetPaneControl method with bAutoDestroy parameter set to false.
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
Thank you Dmitriy.
It worked. Also, in addition, I will always use CommandToID to always get the correct index even if it is misaligned.
|
|
|
|
|
Yes, this is right approach.
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
Hi,
Has anyone tried setting a background image for a status bar?
I have tried various ways but not able to achieve that.
Any suggestions would be of great help.
Thanks in advance,
Narahari
|
|
|
|
|
Did you mean setting an icon for the status bar pane? If yes, then you can use the CStatusBarCtrl::SetIcon method.
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
Thanks for the quick response.
I actually want to set a bitmap as the background image for the whole status bar, not an icon.
|
|
|
|
|
In this case you have to manually paint all the status bar background and panes. The class in this article doesn't do this. You can use original class CExtStatusControlBar from the Prof-UIS Freeware[^] library which allows you to overide painting of the whole background or background of particular pane. This is done in the OnPaintEntireBackground and OnErasePaneBackground virtual methods.
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
Thanks for the suggestion.
Will try to use that class.
Regards,
narahari Upadhya
|
|
|
|
|
Hi Dimitri,
Can I use this class also in a DialogBox without inheritance and modification in the class?
Thank you.
We are an example of helping each other.
|
|
|
|
|
Using the status bar in the dialogs is extremely easy.
Please take a look at this project.
We just generated a simple dialog-based application, added CTestDlg::m_wndStatusBar property and created it in the CTestDlg::OnInitDialog() method. To stick the status bar to the bottom of the dialog window, we invoke the CWnd::RepositionBars() method in the OnInitDialog() and OnSize() methods. You can replace the the CStatusBar class with CExtStatusControlBar . The result will be the same. Of course, after creating the status bar in your dialog, you need to initialize its panes.
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
Well Dimitry,
You are a great guy for helping me with you quick response.
I'll work it out later, but again thank you very much!
We are an example of helping each other.
|
|
|
|
|
I want to pop a dialog, when click on progress bar.
how to do with it ?
|
|
|
|
|
Just create the CExtStatusControlBar -derived class and handle the mouse click event inside the derived class.
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
with valuable feedback and that is impressive.
good work too!
scott pelger
mammoth consulting
|
|
|
|
|
Thank you for your kind words. I'm always at your service!
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
I mean the icon on the left and the string on the right in the same pane.
Not a icon in a pane and a string in another pane
Thank you
|
|
|
|
|
Yes, this is possible. You need to use the
CStatusBarCtrl::SetIcon method which sets the icon for a pane in a status bar.
You can use the following code if you are using the Prof-UIS CExtStatusControlBar class:
<code>bool bRet = m_wndStatusBar.AddPane( IDS_PANE_TEXT, 1 );
if( !bRet )
return;
int nIndex = m_wndStatusBar.CommandToIndex( IDS_PANE_TEXT );
m_wndStatusBar.SetPaneWidth( nIndex, 100 );
HICON hPaneIcon = NULL;
HINSTANCE hInstResource =
AfxFindResourceHandle(
MAKEINTRESOURCE( IDR_PANE_ICON ),
RT_GROUP_ICON
);
ASSERT( hInstResource != NULL );
if( hInstResource != NULL )
{
hPaneIcon = (HICON)
::LoadImage(
hInstResource,
MAKEINTRESOURCE( IDR_PANE_ICON ),
IMAGE_ICON,
16,
16,
0
);
ASSERT( hPaneIcon != NULL );
}
m_wndStatusBar.GetStatusBarCtrl().SetIcon(
nIndex,
hPaneIcon
);
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
Any suggestions?
|
|
|
|
|
You can use the following code:
class CExtStatusBarComboBox : public CComboBox{
virtual void PostNcDestroy(){
delete this;
}
};
CExtStatusBarComboBox* m_pWndComboBox
m_pWndComboBox = new CExtStatusBarComboBox;
if (!m_pWndComboBox->Create(
WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWN,
CRect(0,0,0,200),
&m_pMainFrame->m_wndStatusBar,
IDC_STATUS_BAR_COMBO))
{
TRACE(_T("Failed to create combo box control.\n"));
return;
}
m_pWndComboBox->SetFont(
CFont::FromHandle(
(HFONT)::GetStockObject(DEFAULT_GUI_FONT)
)
);
m_pWndComboBox->AddString( _T("Item 1") );
m_pWndComboBox->AddString( _T("Item 2") );
m_pWndComboBox->AddString( _T("Item 3") );
m_pWndComboBox->AddString( _T("Item 4") );
bool bRet = m_pMainFrame->m_wndStatusBar.AddPane(IDS_PANE_COMBO,m_nPosition);
if(!bRet){
AfxMessageBox(_T("Pane index out of range\nor pane with same ID already exists in the status bar"), MB_ICONERROR);
return;
}
int nIndex = m_pMainFrame->m_wndStatusBar.CommandToIndex(IDS_PANE_COMBO);
if (nIndex == -1)
return;
m_pMainFrame->m_wndStatusBar.SetPaneWidth(nIndex, 100);
m_pMainFrame->m_wndStatusBar.SetPaneControl(m_pWndComboBox, IDS_PANE_COMBO, true);
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
Is it possible to add two buttons in one pane?
I tried, but the buttons always fill the whole pane. So when I add the second button it is drawn over the first one. Then, the first button is hidden...
I looked for style flags and in the RepositionControls() method but I could not find any solution.
|
|
|
|
|
Yes, it is possible.
Currently you can insert only one window into a pane. But there is a workaround. Just create a kind of proxy window, create two buttons in it dynamically, and insert the proxy where you want it.
Best regards,
Dmitriy Yakovlev
|
|
|
|
|
Thanks.
I encountered another problem: I'd like to disable a button control but it seems that disabling is only possible for edit controls. How can I disable (gray) a button using your DisableControl() method?
Stevy
|
|
|
|
|
Hi,
When you use the status bar in dialogs it is enough to call the DisableControl method. As for frame-based applications, the status bar uses the OnUpdateCmdUI handler in which it controlled state of all the panes.
Use the ON_UPDATE_COMMAND_UI macro for creating an update handler for the IDC_STATUS_BAR_BUTTON command. Each status bar pane needs to know whether it is enabled or disabled to display itself properly. If the framework does not find an ON_UPDATE_COMMAND_UI entry during command routing, it automatically enables the user-interface object if there is an ON_COMMAND entry somewhere with the same command ID. Otherwise, it disables it. Therefore, to ensure that a button is enabled/disabled, provide an update handler for the IDC_STATUS_BAR_BUTTON command.
…
afx_msg void OnUpdateStatusBarButton(CCmdUI* pCmdUI);
…
BEGIN_MESSAGE_MAP(CChildFormView, CFormView)
…
ON_UPDATE_COMMAND_UI(IDC_STATUS_BAR_BUTTON, OnUpdateStatusBarButton)
…
END_MESSAGE_MAP()
void CChildFormView::OnUpdateStatusBarButton (CCmdUI* pCmdUI)
{
if( m_pWndButton && ::IsWindow(m_pWndButton->m_hWnd))
pCmdUI->Enable( m_pWndButton->IsWindowEnabled() );
}
Best regards,
Dmitriy Yakovlev
|
|
|
|