Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » CExtCheckBox unchecked itself automatically Collapse All
Subject Author Date
Pixel Edena Jan 30, 2007 - 1:17 PM

Hello,
I have got a drawing-like MDI application with some tools buttons. Each tool has an associated CExtToolControlBar which is shown/hide when the tool is activated/deactivated. Each tool bar can contains some CExtComboBox, CExtFlatEdit or CExtCheckBox. Everything works well but CExtCheckBox controls.
The strange problem is that when the user click on the checkbox, the checkbox is correctly checked/unchecked but when the cursor leaves the checkbox, the checkbox is automatically unchecked ! However, it is possible to let the checkbox checked by jumping very quickly in the menu, then the checked stays checked until the cursor enter the checkbox ! (?!)
(of course I do not have any COMMAND_UI which could disable the checkbox)

Do you have an idea of what the problem could be or come from ?

Thanks a lot for your great library !

Pix

Pixel Edena Feb 1, 2007 - 10:00 AM

Thank you very much for your detailed answer. I made it work a little bit differently because my application is mostly dynamic (tools are added through plugins and a specific SDK) and I do not want to use the command updating mechanism. So I have derivated CExtBarCheckBoxButton::OnClick() and update the check using GetStyle()/SetStyle()... And it works just fine :)

Technical Support Feb 1, 2007 - 11:34 AM

The best way to code a pluggable application with Prof-UIS is to use the customizable toolbars and menus and ProfAuto. It is possible to provide the plugins with OLE automation interfaces and let them build and control their toolbars and menus.

Pixel Edena Jan 31, 2007 - 9:18 AM

Thanks a lot for your answer, I am gonna try to fix that as you explained.
However, I do not find any documentation about CExtBarCheckBoxButton. Actually, I looked in the source code for a function to programmaticaly set the check state of the button, but as far as I can see, the only way is to use SetStyle(TBBS_CHECKED); (and GetStyle() & TBBS_CHECKED to check its state). Why don’t you add member functions SetCheck() & GetCheck() as the MFC class or CExtCheckBox ?

Technical Support Feb 1, 2007 - 5:22 AM

The CExtBarButton and CExtBarCheckBoxButton objects have different visual appearance and exactly the same behavior. The CExtBarButton object works like a push button common control or button like check box control. The same is related to the CExtBarCheckBoxButton object but you have no reason to use it like push button control because it looks like check box. There are no new APIs defined in the CExtBarCheckBoxButton class. You simply should use the CExtBarCheckBoxButton type instead of the CExtBarButton type. The CExtToolControlBar::InsertSpecButton() method allows you to insert any kind of button object into toolbar.

In simple words, if you will use the CExtBarButton object, then you will see the same as Bold, Italic or Underline buttons in Word or WordPad applications. If you will use the CExtBarCheckBoxButton object, then you will get the same working buttons as Bold, Italic or Underline buttons in Word or WordPad applications, but they will have a look of the check box common control which you often see on dialogs.

To make the button object with the ID_SOME_BUTTON command identifier working like check box you should:

1) Add the following into the main frame class declaration:

bool m_bCheckedSomeButton;
afx_msg void OnSomeButton();
afx_msg void OnUpdateSomeButton( CCmdUI * pCmdUI )


2) Add the following into the main frame’s constructor:

m_bCheckedSomeButton = false;
3) Add the following into the main frame’s message map:
ON_COMMAND( ID_SOME_BUTTON, OnSomeButton )
ON_UPDATE_COMMAND_UI( ID_SOME_BUTTON, OnUpdateSomeButton )


4) Add the following into the main frame’s CPP file:

void CMainFrame::OnSomeButton()
{
    m_bCheckedSomeButton = ( ! m_bCheckedSomeButton );
    ::AfxMessageBox( _T("Checked state of some button was changed") );
}
 
void CMainFrame::OnUpdateSomeButton( CCmdUI * pCmdUI )
{
    pCmdUI->Enable(); 
    pCmdUI->SetCheck( m_bCheckedSomeButton ? 1 : 0 );
}



Technical Support Jan 31, 2007 - 4:52 AM

The toolbar button’s state is fully controlled by the MFC command updating mechanism. Besides, if a button common control (push button, check box or radio button) is attached to a toolbar button object, the button window’s checked state is also automatically updated according to the command updating mechanism. So please add the command updating handler for your check box button in the toolbar and control its checked state in it.

Additionally we would recommend you not to use windows attached to toolbar button objects if it is possible. For check boxes, you should insert the CExtBarCheckBoxButton button object into the toolbar instead of using a CExtBarButton object that has a check box-like button common control attached to it.