Add a button to MFC CDockingPane titlebar - c++

Anyone knows how to add a button to the titlebar of a CDockablePane ? I tried the usual way with CDialog but it does not work for CDockablePane...
Thanks

You need to create an instance of CMFCCaptionButton, then use the protected but undocumented m_arrButtons member of the CDockablePane class:
yourDockablePane.m_arrButtons.Add(new CMFCCaptionButton(YOURCOMMANDID));

Related

CDialogEx constructor and inherited Create() method

When i programatically create a non-modal dialog from a dialog resource ID i use the following code:
CDialogEx myDialog(IDD_DIALOG1, this);
...
myDialog.Create(IDD_DIALOG1, this);
One can see that this isn't very practical as one needs to pass the dialog ID twice.
Did i understand something wrong about the creation of a dialog?
Is there a way to avoid that repetition?
What is the reason that the MFC class CDialogEx provides a constructor
CDialogEx(UINT nIDTemplate, CWnd* pParent=NULL);
but also an inherited method
virtual BOOL CDialog::Create(UINT nIDTemplate, CWnd* pParentWnd = NULL);
which forces me to repeat the dialog ID?
The reason behind is that i want to derive an own class myDialogClass from CDialogEx but do not want to assign an ID at this point. Would it be possibly ok to pass a dummy ID to the CDialogEx constructor?
I want to assign the ID when i create the dialog window, not before.
class MyDialogClass: public CDialogEx{
...
public:
MyDialogClass(CWnd* pParent=NULL):CDialogEx(DUMMY_ID, pParent){}
}
Furthermore i want to extract my dialog class into an own library (MFC extension library) and use it in some other code.
My dialog class provides an additional memory DC to the normal DC, but this could just be any other functionality.
I want to use this additional functionality in several contexts.
“Did i understand something wrong about the creation of a dialog?” There are two scenarios a dialog box may be used: modal & modeless. You mixed them:
CDialog & CDialogEx provides a parameterless constructor which may be used with the modeless scenario. Your code becomes:
CDialogEx myDialog();
// ...
myDialog.Create(IDD_DIALOG1, this);
For more information on how to correctly implement a modeless dialog, see this.

MFC - Change font in a CMFCToolTipCtrl used in CDialogEx control

I'm trying to display a ToolTip for a CStatic derived control in my dialog.
What I've already done:
Added a CMFCToolTipCtrl item to my CDialogEx member.
In the init dialog member I've specified CMFCToolTipInfo structure and passed it as argument in CMFCToolTipCtrl item constructor.
Call the EnableToolTips(); member for my CStaticExts and for my CDialogEx.
Overrided the PreTranslateMessage of my CDialogEx adding the "RelayEvent".
Set "Notify: TRUE" in the resource editor.
Doing so I managed to display the tooltip in a partially customized way (baloon and background color) but now I would like to enlarge the font, make it bold and, eventually, display an icon, similarly to the tool tips I can see on my toolbar.
I already tried calling "SetFont" and "SetIcon" methods for the CMFCToolTipCtrl item but it didn't work.
Is that possible?
The normal Font that is used in CMFCToolTipCtrl ist retrieved from a global data store inside the MFC (see GetGlobalData()->fontTooltip). This data structure AFX_GLOBAL_DATA is filled when the MFC is started. SetFont has no effect here.
If you want to change the behaviour you have to create your own CMFCToolTipCtrl class and overwrite OnDrawLabel. You have the source of the MFC so it is easy to provide your own implementation.

Making a propertysheet as MDI child

I have a class derived from CPropertySheet in my MDI application. It is a model-less property sheet shown when a button is pressed in one of the views of application. I need to make the sheet as a child view of the application
How to do it?
You just need to change the parent of property sheet using SetParent, or when you instantiate the CPropertySheet-derived class object, you can pass the parent CWnd* reference to constructor of CPropertySheet.
Is this not working?

Relationship between CDocument and CPropertySheet

I have a CPropertySheet instance which is initialized using DoModal() in one of the methods of my CDocument class, in an MDI MFC application
My problem is I would like to refresh the view associated with the document from the sheet without ending the DoModal().
How do I get an handle back to the CDocument from my CPropertySheet so I can manipulated the CView easily ?
I have tried different things from this MSDN article but I am not able to retrieve what I want http://msdn.microsoft.com/en-us/library/bs315d2c.aspx
Thanks a lot.
You can use the SendMessage or PostMessage to the target window. Do this when the apply button is clicked.
Refer: http://cppandmfc.blogspot.com/2012/08/mfc-creating-and-using-property-page.html
You will get a Nice idea from that writeup

CMFCRebar on a dialog box

Can we create a CMFCRebar on a dialog box? If yes, then how? I need to have a CMFCReBar drawn on a dialog box with a toolbar and and menubar.
There are a lot of examples of how to add a toolbar to a CDialog. Have you tried to take one of those samples and modify CDialog with the new CDialogEx and CRebar with CMFCReBar? I haven't tried it but maybe it works.
By the way, there is a tag specific for MFC feature pack questions (mfc-feature-pack). Maybe you should add this tag.
Regards,
Javier