CToolBar with checkbox only - not showing properly - mfc

I have an MFC CToolBar (dockable to a CFrameWnd) containing a checkbox and a button.
This works fine now, but I need to remove the button, and then the CToolBar does not show properly any more. As it seems because it gets "zero" height. The checkbox style is "turned into" a TBBS_SEPARATOR using a call to CToolBar::SetButtonInfo before it is "created".
How can I make the toolbar visible also without that dummy button?

I solved this by overriding the CToolBar::CalcDynamicLayout method and provided the size of the toolbar there. Then the button was not needed any more. This assumes the toolbar is created with CBRS_SIZE_DYNAMIC.

Related

C++ CListControl - check if selected

I've got a ListControl box and I want to enable a textbox if the user clicks on a button there.
I've allready tried to update the dialog via an "OnLeftButtonUp" function which works quite well if I click outside the ListControl but when I click INSIDE the box nothing happens...
Any ideas why?
Cheers

How do I get a Maximise button and a What's This button on a Qt Dialog?

I currently have a Qt::Dialog with a What's This help button, and a close button in the title bar.
I tried modifying the window hint flags to include the maximise and minimise buttons as well.
This worked but removed the What's This button, even if I explicitly included the flag for the what's this button as well.
Is there any way that I can have a dialog with maximise and minimise buttons but keep the What's this functionality?
If you don't mind where the What's this button appears, you can create a new button anywhere (probably called "What's This" or just "?").
This new button must be connected to a slot that includes the function:
`QWhatsThis::enterWhatsThisMode();`
which will perform the same function as the now missing What's This button in the title bar.
It probably is the only function the slot needs to call.
This action can even be called from a menu, and if required from a key combination.

Programmatically and completely delete button from MFC toolbar

I have a document within MFC C++ application. I need to delete one the buttons from the particular CMFCToolbar within a code (not resources) completely, even preventing a user to restore the button via toolbar customization dialog. At this moment I use RemoveButton method of CMFCToolbar but it only makes the button invisible and it can be restored via toolbar customization dialog that is not an option for me at this time. I will be very glad if you suggest something that can help me there.
There are two internal lists in CMFCToolBar that are used to reset the Buttons upon customization.
They are named m_OrigButtons and m_OrigResetButtons.
You may need to derive your own class and delete the buttons with the specific IDs from there.
But better: Never to include such a button on the first time when the toolbar is created!

How to hide a custom toolbar from IE

I have developed a toolbar with one button for IE.
My toolbar displays with a default close button in the IE window.
When I click on the close button the toolbar prompts for the disable option.
This completely disables the toolbar.
But what I need is I just want to hide the toolbar. So still it can perform some actions even though the toolbar is not visible.
How can I make the toolbar just to hide instead of disable?
have you tried any IE statements? There are a few for JS aConditional comments

How do I add a Checkbox to a tool bar in MFC with a custom bitmap?

I have a C++ MFC MDI application. I have a tool bar with some buttons on it. I need to add some check boxes to this toolbar and i need them to have custom bitmaps just as my buttons do. Thanks
EDIT:
By bitmpas i refer to the pixel images that can be created using the tool bar editor in visual stuidos 2008. I would like a picture (of my creation) instead of the usual tick box.
You don't use checkboxes on toolbars.
You should rather use regular buttons in Check mode. That means that the button stays pressed when user releases it. Clicking it a second time releases the button. This is the same behaviour as a checkbox.
You can either set a toolbar button as checkable by code:
m_ToolBar.SetButtonStyle(nButtonId, TBBS_CHECKBOX);
Or by enabling the corresponding property in the resource editor.
If you want to modify the image displayed when the button is pressed, in your ON_UPDATE_COMMAND_UI handler, use m_ToolBar.GetButtonInfo() to check if the image matches the state. If not, change it using m_ToolBar.SetButtonInfo() and specify the index of an extra image added to the image list of the toolbar.
The following is a link which might help you
http://www.ucancode.net/Visual_C_Control/Place-Combo-Edit-Box-Progress-Control-On-ToolBar-CToolBar-VC-Example.htm