Make MFC Program with Multiple Tabs - mfc

I want to make a MFC program with multiple tab, which each tab is assigned a dialog as this picture:
Which MFC project should I create? How can I make these tabs and when I click that tab, a corresponding dialog will be opened.
For example, I have 2 dialog: IDC_VIEWER and IDC_UART. In MainFrm.cpp:
CMultiDocTemplate* pNewDocTemplate = new CMultiDocTemplate(
IDR_VIEWER_TMPL,
RUNTIME_CLASS(CBaseDocument),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CViewer));
AddDocTemplate(pNewDocTemplate);
CMultiDocTemplate* pNewDocTemplate = new CMultiDocTemplate(
IDR_VIEWER_TMPL,
RUNTIME_CLASS(CBaseDocument),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CViewer));
AddDocTemplate(pNewDocTemplate);
But these tap not link to to corresponding dialog.

Related

How does the MFC PropertyGrid control work in the dialog editor in visual studio?

In the visual studio dialog editor i can add a MFC Property Grid control to the dailog. How can i customize its content, and set options like allowing the user to edit the contents of it when the program using it is running, or how i can change the contents of it using c++?
When i add something like a button or and edit control it displays on the dailog box when the program is running, while when i add a MFC Property Grid the dailog isnt even being displayed.
Here is a picture of the visual studio dialog editor and a MFC property control grid in the middle of the dailog with contents i dont know how to change.
Simple tutorial of CMFCPropertyGridCtrl:
1.Create a dialog-based MFC project, drag a CMFCPropertyGridCtrl into it, and adjust the size. Then change the ID for the control to IDC_MFCPROPERTYGRID_TEST, and use Add Varible to add a variable m_propertyGrid to the control. Change the setting of Notify to True.
Description Rows Count refers to the number of rows in the description section below.
Enable Description Area indicates whether to enable the following description function.
Enable Header indicates whether to start the header.
Mark Modified Properties indicates whether to highlight the changes.
2.Set interface
Add the following code in OnInitDialog()
HDITEM item;
item.cxy=120;
item.mask=HDI_WIDTH;
m_propertyGrid.GetHeaderCtrl().SetItem(0, new HDITEM(item));
Add content
Add the following code in OnInitDialog()
CMFCPropertyGridProperty* pProp2 = new CMFCPropertyGridProperty(
_T("choose"),
_T("select"),
_T(""));
pProp2->AddOption(_T("1"));
pProp2->AddOption(_T("2"));
pProp2->AddOption(_T("3"));
pProp2->AllowEdit(FALSE); //Editing of options is not allowed
m_propertyGrid.AddProperty(pProp2);
The three parameters passed in when calling the constructor are item name, default options and description text.
Also, you could add drop-down menu:
CMFCPropertyGridProperty* pProp2 = new CMFCPropertyGridProperty(
_T("choose"),
_T("select"),
_T(""));
pProp2->AddOption(_T("1"));
pProp2->AddOption(_T("2"));
pProp2->AddOption(_T("3"));
pProp2->AllowEdit(FALSE); //Editing of options is not allowed
m_propertyGrid.AddProperty(pProp2);
In addition, there are three similar projects:
CMFCPropertyGridColorProperty * pProp3 = new CMFCPropertyGridColorProperty(
_T("colour"), RGB(0, 111, 200));
m_propertyGrid.AddProperty(pProp3);
CMFCPropertyGridFileProperty * pProp4 = new CMFCPropertyGridFileProperty(
_T("open file"), TRUE, _T("D:\\test.txt"));
m_propertyGrid.AddProperty(pProp4);
LOGFONT font = { NULL };
CMFCPropertyGridFontProperty * pProp5 = new CMFCPropertyGridFontProperty(
_T("select font"), font);
m_propertyGrid.AddProperty(pProp5);
Finally, This is the final program running interface:

C++ - MFC - Change text of a CMenu

Good morning everybody,
I created an application that manages multi-language. When I dynamically change the default language of the application, all the text of the different graphic components change very well excepted one component. I don't know why ?
I tried those lines for modifying the text of the menu title but it changes only if I put my mouse on this menu.
MENUITEMINFO info;
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_ID;
VERIFY(AfxGetMainWnd()->GetMenu()->GetMenuItemInfoA(0, &info, TRUE));
AfxGetMainWnd()->GetMenu()->ModifyMenuA(0, MF_STRING | MF_BYPOSITION, info.wID, theApp.vattingTranslation.GetDescription(256).c_str());
Why does it not refresh automatically my menu item "Système" ?
Thanks in advance
You need to call a DrawMenuBar function afterwards as specified in the ModifyMenu documentation:
The application must call the DrawMenuBar function whenever a menu
changes, whether the menu is in a displayed window.

Which event to open a wxToolBar drop-down menu?

I'm using a wxToolBar with an drop-down item:
g_toolBar1->AddTool(TOOLBAR_CMD_CONTROL_DROPDOWN,_("Control elements"),MainWin::getBitmap(gearsXPM,"gears"),wxNullBitmap,wxITEM_DROPDOWN);
custParent->Connect(TOOLBAR_CMD_CONTROL_DROPDOWN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(DrawCanvasSwitcher::OnToolbar),NULL,g_drawCanvas);
.... // add items to controlMenu here
g_toolBar1->SetDropdownMenu(TOOLBAR_CMD_CONTROL_DROPDOWN,controlMenu);
The drop-down menu opens automatically when somebody left-clicks the arrow right beside the tool. But what event do I have to send to open the drop-down menu programmatically?
Thanks!
You can open any menu, also a drop down menu by calling PopupMenu:
bool wxWindow::PopupMenu (wxMenu* menu,
const wxPoint& pos = wxDefaultPosition);
So in your case it should be:
yourWxWindow->PopupMenu(controlMenu);
or when you are already in a class that inherits from wxWindow:
PopupMenu(controlMenu);

In MFC, How can I have a button to create several dialog instances successively without closing them?

I've already implemented a dialog with a button on it.
When the user clicks the button, a new dialog is shown. But the problem is the user can't click the button unless I close the new dialog.
How can I let the user click the button without closing the new dialog instances?
Here is the code for the button clicking part:
void CMyprojDlg::OnClicked()
{
dialognewone mydia;
mydia.DoModal();
}
You should create a modeless dialog dynamically:
void CMyprojDlg::OnClicked()
{
// Note that: you should free memory by yourself when you close the dialog
dialognewone *mydia = new dialognewone();
mydia->Create(IDD_DIALOG1); // create a modeless dialog
mydia->ShowWindow(SW_SHOWNORMAL); // show a modeless dialog
}
According to the keyword by Michael Walz' Comment .
I've changed my code into
void CMyprojDlg::OnClicked()
{
DialogClassName *dia = new DialogClassName;
dia->Create(IDNumberOfTemplate,this);
dia->ShowWindow(SW_SHOW);
}
And It works.

How can I add a context sensitive help button for a specific dialog control

I have an MFC app (10 year old app), which has context sensitive help for each dialog. I want to add help on a specific combobox, as well as a little question mark button next to this control. Users can either select the combobox and hit F1, or they can click on the button next to the combobox, and it will jump to a help page that is specifically about this combobox, rather than general help for the whole dialog.
In the dialog resource properties, I have set "Context Help" to True.
In the combobox properties, I've set "Help ID" to True.
In myapp.hpp, I have added "HIDC_MYCOMBOBOX = mycombobox_help.htm" to the [ALIAS] section, and included the resource.hm file in the [MAP] section.
Again in app.hpp file, the dialog uses "HIDD_MYDIALOG =
mydialog_help.htm"
Yet selecting the combobox and pressing F1 still brings up mydialog_help.htm, instead of mycombobox.htm.
What am I missing to use a separate help page for the control?
Is it possible to redirect the control to an anchor in the main page? Something, along the lines of...
HIDC_MYCOMBOBOX = mydialog_help.htm#mycombobox
I have added a "?" button to run the following code, but this also doesn't give the context for the control, and just opens the mydialog_help.htm.
HELPINFO lhelpinfo;
lhelpinfo.cbSize = sizeof(lhelpinfo);
lhelpinfo.iContextType = HELPINFO_WINDOW;
lhelpinfo.iCtrlId = IDC_BALANCING_METHOD;
lhelpinfo.hItemHandle = GetDlgItem(IDC_BALANCING_METHOD)->m_hWnd;
lhelpinfo.dwContextId = HIDC_BALANCING_METHOD;
lhelpinfo.MousePos = POINT();
CDialog::OnHelpInfo(&lhelpinfo);