Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Problem with MFCApp

Hi,
Further to this

https://www.experts-exchange.com/questions/28641185/Problem-with-form-project.html

I still do not see resource view, after I've selected CFormView to the project.
Avatar of sarabande
sarabande
Flag of Luxembourg image

did you open 'resource files' in solution explorer? then look for mfcapplication2.rc if found double-click. if there is another .rc file you also may double-click.

Sara
Avatar of Peter Chan

ASKER

Many many thanks Sara.

what to do against .rc file?
double-click will open the resource view. it is a tree where you could define new resources. below 'dialog' you already will find two entries. one for about dialog and one for the dialog form generated by wizard as a starter for your dialog-based mfc application.

if you click on the IDD_DIALOG1 (or similar) you get a form resource with ok and cancel button and a static control stating 'define your controls here'. first, you would click on that static text control and remove it by 'DEL' key. if you don't see a tool box with controls in the docking area on the right, you should get the toolbox via the 'view' menu. if done so far, you can select controls from toolbox and move them by drag'n'drop to the form. selecting a control in the form and ALT+ENTER allows to define the properties of the control. you should first change the default ID of the control to some meaningful name, for example IDC_ST_KEY for a static text control "Key" and IDC_ED_KEY for the corresponding edit control. you may use your own syntax, but do not take the defaults since that would make it difficult to discuss about them. you can test a defined form by choosing the 'test' button which is available by mini buttons of the resource editor. you also will find buttons which help to size and align the controls in the form. for example you could select multiple controls in the form by holding the CTRL key while selecting controls and then make them all same size or have them aligned left or have them same distance within one line or column.

Sara
User generated imageMany thanks Sara.
Here is what I can see, to the .rc file

and I do not see buttons to each dialog in above.
double-click on IDD_MFCAPPLICATION7_DIALOG and the resource editor will open the form associated with that resource id.

Sara
Many thanks Sara.

you can select controls from toolbox and move them by drag'n'drop to the form. selecting a control in the form and ALT+ENTER allows to define the properties of the control.

what objects should be added to the current DIAGLOG form you're talking about?
you may need
- some static text controls for example with text "File Path".
- some edit controls which correspond to the static text control.
- a group of radio buttons to make  achoice between different record types
- a push button to invoke a query
- a listbox or list control or static multiline box to display results

see above where i made a detailed description of the first steps you could do.

Sara
Thanks a lot.
1. Does it mean we need to validate the given File Path?
2. What are the available record types?
1. Does it mean we need to validate the given File Path?
no. not necessarily. if your program "knows" that the files are below c:\dp4 and that the names are flname*.idx, flnumber*.idx or flout.dat, you would ask like

index name        File Number: [___]
index number    File Number: [___]
data record    

File Path : [c:\dp4\_______________________________]

in your dialog where you have 3 radio buttons to let the User decide which structure to choose, where you have a pair of static text + edit field for the number extension of the two index structures and finally a static text with "File Path" and a static output text control where you display the path which you would get by createFileName function. for example if the User selects 'index number' and entered '17' for file number, the path would evaluate to "c:\dp4\flnumber_17.idx".

you would fill the path either after the User clicked to a Button 'Check File Exists' or whenever there is a change on either the radio buttons or the edit controls asking for file number.

Sara
Many thanks Sara.
Should I create the form with the details, within BinaryFile.cpp?
Sorry, I think we should create the form with the details, within .rc project, right? But I do not have the details to create one form within that.
Should I create the form with the details, within BinaryFile.cpp?

no. binaryfile.cpp is your interface to the files and records. it is part of the application layer while the form is part of the visualization layer. since we removed stdafx.h from binaryfile.cpp the functions and classes implemented in binaryfile.cpp cannot call into the mfc framework but only the other way round.

I think we should create the form with the details, within .rc project, right?
what do you mean by .rc project? there is a .rc file which stores all the resources you define with resource editor in the .rc file. if you right-click on controls in the resource editor you will find wizard functionality whci allow you to bind member variables of your dialog class to controls. it also makes it possible to create event handlers as a response to user input in your form. you may play with these features in order to get more experienced.

Sara
Thanks. How to raise resource editor?
the resource editor opens if you click on a resource id of the resource view.

https://www.experts-exchange.com/questions/28674259/Problem-with-MFCApp.html?anchorAnswerId=40782523#a40782523

Sara
Thanks Sara.
I do not see Textbox on Toolbox to define for File number.
I do not see Textbox
??? you don't see 'Static Text' control?

you have to "explore" all the controls in the toolbox yourself. select one, drag it to the dialog, check its properties, resize it, look for events, and so on, and find out what it could be used for. by CTRL+T (or mini button >[-]) you can test the dialog (ESC ends the test). the help and info you got for any detail is very good. i also could give you an answer to your questions, but it will last years compared to days if we would continue like we do now.

Sara
User generated image
Thanks a lot.
Yes, I did think Static text can fit to the needs. But I do not see the way to input to "File Number" and "File Path" in above, after I've selected Static Text.
I do not see the way to input to "File Number" and "File Path"
for input you have to choose edit control from toolbox. check my comments where i already elaborated which controls you need for the first approach.

the "file path" only is output. therefore you may use two static text controls (but change ID from IDC_STATIC to individual name).
or also choose edit control and make it read-only by properties.

Sara
BTW, what should be done, within Save and Cancel buttons?
Remove 'Save' since there is nothing to 'save'. or change it to 'Show Structure'. if you do so, also change name of the ID.

'cancel' should/would exit the dialog.

Sara
Thanks Sara.
What kind of Edit control I should choose for File Number?
just the 'Edit Control' from toolbox. size it that it can take 4 digits. rename the id like IDC_ED_NAMIDX_FILNUM. if created right-click at the control, choose 'Add Variable...', the 'Add Member Variable Wizard' opens, use category 'Value', what allows to define a member for the contents rather than for the control, choose CString as 'Variable type' and name it like 'm_namidxFilnum' according to the ID name. choose again 'Add Variable' for the edit control and let category 'Control' and name the control variable m_edNameIdxFilnum'. repeat all for the second edit control which would take the file number for number index files. you would choose CString and not 'int' since you want to be able to let the file number empty if you want to evaluate the merged index file. then right-click again at the control and choose 'Add Eventhandler...'. Use EN_CHANGE event and click 'Add and Edit' button. it would go to the dialog cpp file where the wizard has created an empty handler function for you which was called automatically for any change on the edit field. add statement UpdateData(TRUE); into the function what will read the input from screen into the CString member variable. then use

std::wistringstream wos((LPCTSTR)m_nameIdxFilnum);
int filnum = 0;
if (!wos >> filnum) 
{
       AfxMessageBox(_T("Number input required"));
       m_edNamIdxFilnum.SetFocus();
}

Open in new window


i assume you have unicode character set for your project (if not choose istringstream instead of wistringstream).

the wistringstream (or istringstream) is available via #include <sstream> which must be added to the cpp file below all other include statements.

Sara
Sorry, I get the attached below
User generated image
when I choose "Add variable" to File Number in above.
you need to read my posts more thoroughly.

you need two controls, a static text control and an edit control for to get an input for file number.


File Number:        _____________


the text with "File Number:" is a static text control which you can choose from toolbox and drag to the dialog. then you change the properties at least for the text. i also gave you the advice to change the ID from IDC_STATIC to an individual ID like IDC_ST_NAMIDX_FILNUM. the advantage of doing so is, that IDC_STATIC resolves to -1 what actually is not an ID(entification) but  only a default. IDC_STATIC allows to show fixed text at the screen. it does not allow to change the text dynamically or to show/hide the control (what probably we need when the radio boxes were changed by the user).

IDC_STATIC also doesn't allow to add a variable for the control, since the mapping of a variable to a control needs a unique ID for the control, differently to -1.

that was the first flaw.

the second is, that you didn't define an edit control in your form and now try to do the actions i explained with a static text control. that is more than one step back and ignores all I have told you in the last 5 comments how to do that and which steps to do.

i will no longer answer questions until you have achieved to compile and build your test application and have a dialog with 3 radio buttons, at least 1 static control "file number" and 1 edit control where the user can input the file number, and 1 cancel button where you could exit from dialog.

Sara
Sara, thanks a lot.

I did follow all your current responses. But how to correct these
Error	2	error C2440: 'type cast' : cannot convert from 'HRESULT (__thiscall CMFCApplication7Dlg::* )(IHTMLElement *)' to 'DHEVTFUNC'	c:\mfcapplication7\mfcapplication7\mfcapplication7dlg.cpp	50	1	MFCApplication7
Error	3	error C1903: unable to recover from previous error(s); stopping compilation	c:\mfcapplication7\mfcapplication7\mfcapplication7dlg.cpp	50	1	MFCApplication7
	4	IntelliSense: "CDHtmlDialog" is not a nonstatic data member or base class of class "CMFCApplication7Dlg"	c:\MFCApplication7\MFCApplication7\MFCApplication7Dlg.cpp	56	4	MFCApplication7
	5	IntelliSense: expected a ')'	c:\MFCApplication7\MFCApplication7\MFCApplication7Dlg.cpp	56	41	MFCApplication7
	6	IntelliSense: function "std::basic_istringstream<_Elem, _Traits, _Alloc>::basic_istringstream(const std::basic_istringstream<_Elem, _Traits, _Alloc>::_Myt &) [with _Elem=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>]" (declared at line 439 of "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream") cannot be referenced -- it is a deleted function	c:\MFCApplication7\MFCApplication7\MFCApplication7Dlg.cpp	185	26	MFCApplication7
	7	IntelliSense: identifier "m_nameIdxFilnum" is undefined	c:\MFCApplication7\MFCApplication7\MFCApplication7Dlg.cpp	185	35	MFCApplication7
	8	IntelliSense: identifier "m_edNamIdxFilnum" is undefined	c:\MFCApplication7\MFCApplication7\MFCApplication7Dlg.cpp	190	3	MFCApplication7

Open in new window

while here are the codes of the dialog.

//
//

#include <sstream>
#include "stdafx.h"
#include "MFCApplication7.h"
#include "MFCApplication7Dlg.h"
#include "afxdialogex.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialogEx
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()


// CMFCApplication7Dlg dialog

BEGIN_DHTML_EVENT_MAP(CMFCApplication7Dlg)
	DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK)
	DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
END_DHTML_EVENT_MAP()


CMFCApplication7Dlg::CMFCApplication7Dlg(CWnd* pParent /*=NULL*/)
	: CDHtmlDialog(CMFCApplication7Dlg::IDD, CMFCApplication7Dlg::IDH, pParent)
	, m_namidxFilnum(_T(""))
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMFCApplication7Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_ED_NAMIDX_FILNUM, m_namidxFilnum);
	DDX_Control(pDX, IDC_ED_NAMIDX_FILNUM, m_edNameIdxFilnum);
}

BEGIN_MESSAGE_MAP(CMFCApplication7Dlg, CDialogEx)
	ON_WM_SYSCOMMAND()
	ON_BN_CLICKED(IDC_RADIO1, &CMFCApplication7Dlg::OnBnClickedRadio1)
	ON_EN_CHANGE(IDC_ED_NAMIDX_FILNUM, &CMFCApplication7Dlg::OnEnChangeEdNamidxFilnum)
	ON_BN_CLICKED(IDC_BUTTON2, &CMFCApplication7Dlg::OnBnClickedButton2)
END_MESSAGE_MAP()


// CMFCApplication7Dlg message handlers

BOOL CMFCApplication7Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		BOOL bNameValid;
		CString strAboutMenu;
		bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
		ASSERT(bNameValid);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMFCApplication7Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialogEx::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMFCApplication7Dlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialogEx::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMFCApplication7Dlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

HRESULT CMFCApplication7Dlg::OnButtonOK(IHTMLElement* /*pElement*/)
{
	OnOK();
	return S_OK;
}

HRESULT CMFCApplication7Dlg::OnButtonCancel(IHTMLElement* /*pElement*/)
{
	OnCancel();
	return S_OK;
}


void CMFCApplication7Dlg::OnBnClickedRadio1()
{
	// TODO: Add your control notification handler code here
}


void CMFCApplication7Dlg::OnEnChangeEdNamidxFilnum()
{
	UpdateData(TRUE);

	std::wistringstream wos((LPCTSTR)m_nameIdxFilnum);
	int filnum = 0;
	if (!wos >> filnum)
	{
		AfxMessageBox(_T("Number input required"));
		m_edNamIdxFilnum.SetFocus();
	}

	// TODO:  If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialogEx::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
}


void CMFCApplication7Dlg::OnBnClickedButton2()
{
	// TODO: Add your control notification handler code here
	ASSERT(AfxGetMainWnd() != NULL);
	AfxGetMainWnd()->SendMessage(WM_CLOSE);
}

Open in new window

Sara,
I really really appreciate you a lot!

Have a great weekend.
: CDHtmlDialog(CMFCApplication7Dlg::IDD, CMFCApplication7Dlg::IDH, pParent)
you derived the dialog from CDHtmlDialog what is a kind of web dialog. i assume you checked some checkbox when creating the dialog project.

actually i haven't any idea what a web dialog should help for your requirements. currently it requires some additionally code where i don't have any idea how to solve them. i think your dialog class should be derived from CDialog or from CDialogEx. you could change that and remove any generated code which refers to 'html' somehow. it might be easier to create a new project where you simply use the defaults and don't check any buttons where you don't know which consequences they may have. or you create a new default project and look to the differences to mfcapplication7 and
correct them in code.

function "std::basic_istringstream<_Elem, _Traits, _Alloc>::basic_istringstream(const std::basic_istringstream<_Elem, _Traits, _Alloc>::_Myt &) [with _Elem=wchar_t, _Traits
seems you forgot to include <sstream>

identifier "m_nameIdxFilnum" is undefined      
isn't it m_namIdxFilnum? or did you forget to add the member with 'add member wizard'?

identifier "m_edNamIdxFilnum" is undefined
did you forget to add the member with 'add member wizard' as described above?

note, intellisense is not a compiler. so the warnings are not compiler errors. you always should build the project in order to get compiler errors. then by f4 it jumps to the line where the error is. or double-click on the error message.

Sara
Many thanks Sara.

repeat all for the second edit control which would take the file number for number index files. you would choose CString and not 'int' since you want to be able to let the file number empty if you want to evaluate the merged index file. then right-click again at the control and choose 'Add Eventhandler...'. Use EN_CHANGE event and click 'Add and Edit' button. it would go to the dialog cpp file where the wizard has created an empty handler function for you which was called automatically for any change on the edit field.

are you talking about the control highlighted below?
User generated image
if yes, why can't I choose CString in above?
Please forgive me if I do anything contradicting to your guidance. Thanks
the control you hilited should be located right from static control with text "Filenumber:". That is normal dialog design. you have a static text as prompt and an edit control for user input. the pair of controls belongs to the radiobutton 'Index Name'. That's why it is located in same line. if the user chooses 'index Number' we would need another pair of prompt and edit, since the user would be confused otherwise.

o Index Name        Filenumber: [___________]
o Index Number    Filenumber: [___________]
o Data Record

File Path: [____________________________________________________________________]

if the user selects Index Name, the static Filenumber and edit control right of Index Number were disabled (or hidden). The static Filenumber + edit control right of 'Index Name' were enabled and made visible (if not already).

if the user selects Index Number, the static Filenumber and edit control right of Index Name were disabled (or hidden).The static Filenumber + edit control right of 'Index Number' were enabled and made visible (if not already).

if the user selects Data Record all controls right of 'Index Name' and 'Index Number' were disabled (or hidden), since we have only one Datafile without any filenumber.

both edit controls should get a CString member variable and a CEdit member variable. the first allows to let the input field blank (what is not possible if you use an int member). the second makes it easier to disable or hide the control. i also recommend to add a CStatic member for all static text controls. this only will succeed if the ID is different from IDC_STATIC.

all static and edit controls need a unique ID specifier which is different from IDC_STATIC and should have a proper naming. the resource editor automatically adds a new #define statement to resource.h header file if you add a new control with an ID different from IDC_STATIC.

if yes, why can't I choose CString in above?
you need to change 'Category' value from 'Control' to 'Value'.

member variables either can be chosen for the control or for the value(contents). for example, if choosing 'Control' you define a CEdit member named 'm_edFilNumNameIndex'. such a member allows you to have a statement 'm_edFilNumNameIndex.EnableWindow(FALSE);' in order to disable the control for editing. if you define a 'value' member, the wizard would add a CString or int or double member variable, for example m_strFilNumNameIndex to your dialog class. this CString member variable would be filled with the input the user had entered to the edit control when you call UpdateData(TRUE); in your dialog cpp file. for initialization you could fill the member variable like 'm_strFilNumNameIndex = "123";' and then call 'UpdateData(FALSE);'. this statement would put the '123' to screen. such initializing would be done in the OnInitDialog member function or in a handler function hwn you want to write to screen rather than to read from screen.

Sara
Good day Sara,
I should have a group to the three Radio buttons, right?

Have a great weekend! Appreciations to your continual help!
yes. best you would first define a groupbox and name it like 'Choose Type of Binary File', then define the radio box buttons one after the other. it is important, that the IDC numbers of the radio buttons are consecutive (what would be automatically the case if you define them together), since you only would bind an int member variable only to the first radiobutton. the wizard then would automatically make that the member variable actually is 0 if the first radio button was selected, 1 if the second, and 2 if the third radio button was chosen. you may look into the resource.h to see whether the IDC numbers are fine (if not you can change them in resource.h though with care).

Sara
Good day Sara,
Should I directly run the generated .exe file to further test against the Dialog project ? Many thanks
you may start the executable by f5 in the visual studio. if your configuration is 'Debug' you would be able to set breakpoints to statements where the execution stopped and where you can evaluate variables and more ...

Sara
Sorry Sara.

Using these codes

void CMFCApplication8Dlg::OnBnClickedRadioname()
{
	// TODO: Add your control notification handler code here
	CButton* pButton = (CButton*)GetDlgItem(IDC_RADIO_name);
	CWnd* pEdit = GetDlgItem(IDC_EDIT_name);
	int nCheck = pButton->GetCheck();

	CButton* pButton2 = (CButton*)GetDlgItem(IDC_RADIO_number);
	CWnd* pEdit2 = GetDlgItem(IDC_EDIT_number);
	int nCheck2 = pButton2->GetCheck();

	CButton* pButton3 = (CButton*)GetDlgItem(IDC_RADIO_data_rec);
	int nCheck3 = pButton3->GetCheck();

	if (nCheck == 1)
	{
		pEdit->EnableWindow(TRUE);
		pEdit2->EnableWindow(FALSE);
	}

	if (nCheck2 == 1)
	{
		pEdit->EnableWindow(FALSE);
		pEdit2->EnableWindow(TRUE);
	}

	if (nCheck3 == 1)
	{
		pEdit->EnableWindow(FALSE);
		pEdit2->EnableWindow(FALSE);
	}
}


void CMFCApplication8Dlg::OnBnClickedRadionumber()
{
	// TODO: Add your control notification handler code here
	CButton* pButton = (CButton*)GetDlgItem(IDC_RADIO_name);
	CWnd* pEdit = GetDlgItem(IDC_EDIT_name);
	int nCheck = pButton->GetCheck();

	CButton* pButton2 = (CButton*)GetDlgItem(IDC_RADIO_number);
	CWnd* pEdit2 = GetDlgItem(IDC_EDIT_number);
	int nCheck2 = pButton2->GetCheck();

	CButton* pButton3 = (CButton*)GetDlgItem(IDC_RADIO_data_rec);
	int nCheck3 = pButton3->GetCheck();

	if (nCheck == 1)
	{
		pEdit->EnableWindow(TRUE);
		pEdit2->EnableWindow(FALSE);
	}

	if (nCheck2 == 1)
	{
		pEdit->EnableWindow(FALSE);
		pEdit2->EnableWindow(TRUE);
	}

	if (nCheck3 == 1)
	{
		pEdit->EnableWindow(FALSE);
		pEdit2->EnableWindow(FALSE);
	}
}

Open in new window


The radio buttons are not displayed properly. why?

Many thanks.
The problem is that the radio buttons could be on at the same time.

Have a great weekend!
there is a trick with radio-Buttons. they were not handled singly but as a group. for that you have to right-click on the first radio button, choose properties and change Group property to True. this makes that only one button can be checked at a time.

see https://msdn.microsoft.com/en-us/library/hab12t9w.aspx
for detecting selection change you either could have a OnBnClickedRadioxxxx for each button and handle it like

// this enumeration could be defined somewhere in your dialog header.
enum 
{
    Name_selected = 0,
    Number_selected = 1,
    Record_selected = 2
};

void CDlg::OnRadioBtnNameClicked()
{
   // check old value of Radio button selection
   if (m_radSelection != Name_selected)
   {
      m_radSelection = Name_selected;
      // now add code to handle the Event

   }
}

Open in new window


or you add an event handler for the Group manually:


 add this line to the message map of the dialog class (between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP)

 ON_CONTROL_RANGE( BN_CLICKED, ID1, ID2, OnRadioBtnClicked )

Open in new window

ID1 is the ID of the first Radio button and ID2 the last one.

 declare the function OnRadioBtnClicked in the dialog header file:

 afx_msg void OnRadioBtnClicked(UINT radioID);

Open in new window


implement it in the Dialog source file:

 void CMyDialog::OnRadioBtnClicked(UINT radioID)
 {
      switch(radioID)
      {
      case IDC_RADIO_NAME:
      {
             // add here the code
             break;
      }
      case IDC_RADIO_NUMBER:
      {
             // add here the code
             break;
      }
      case IDC_RADIO_RECORD:
      {
             // add here the code
             break;
      }
     }
}

Open in new window


The ID represents the resource id of the control clicked and you can use it.

generally you should use an int member for the Radio Group as described previously. for initializing the Group you should add the following to OnInitDialog function:

BOOL CMyDlg::OnInitDialog()
{
    // current implementation
    ....
    // initialize member for Radio group
    m_radSelected = Name_selected;
    // send initial data to Screen
    UpdataData(FALSE);
    returm FALSE;
}

Open in new window


Sara
// this enumeration could be defined somewhere in your dialog header.
enum
{
    Name_selected = 0,
    Number_selected = 1,
    Record_selected = 2
};

void CDlg::OnRadioBtnNameClicked()
{
   // check old value of Radio button selection
   if (m_radSelection != Name_selected)
   {
      m_radSelection = Name_selected;
      // now add code to handle the Event

   }
}

Many thanks Sara.

How to resolve these

Error	1	error C2106: '=' : left operand must be l-value	
	2	IntelliSense: expression must be a modifiable lvalue	

Open in new window

using these codes

void CMFCApplication8Dlg::OnBnClickedRadioname()
{
	// TODO: Add your control notification handler code here
	CButton* pButton = (CButton*)GetDlgItem(IDC_RADIO_name);
	CWnd* pEdit = GetDlgItem(IDC_EDIT_name);
	int nCheck = pButton->GetCheck();

	CButton* pButton2 = (CButton*)GetDlgItem(IDC_RADIO_number);
	CWnd* pEdit2 = GetDlgItem(IDC_EDIT_number);
	int nCheck2 = pButton2->GetCheck();

	CButton* pButton3 = (CButton*)GetDlgItem(IDC_RADIO_data_rec);
	int nCheck3 = pButton3->GetCheck();

	if (nCheck == 1)
	{
		pEdit->EnableWindow(TRUE);
		pEdit2->EnableWindow(FALSE);
	}

	if (nCheck2 == 1)
	{
		pEdit->EnableWindow(FALSE);
		pEdit2->EnableWindow(TRUE);
	}

	if (nCheck3 == 1)
	{
		pEdit->EnableWindow(FALSE);
		pEdit2->EnableWindow(FALSE);
	}

	if (IDC_RADIO_name != Name_selected)
	{
		IDC_RADIO_name = Name_selected;
		// now add code to handle the Event

	}
}

Open in new window

the 'm_radSelection' must be replaced by the int member variable which you added by wizard for the first radio button (and which is supposed to take the selection of the whole group of radio buttons).

the statement 'IDC_RADIO_name = Name_selected;' is wrong. it should be

m_radSelected = Name_selected;

Open in new window


note, instead of using GetDlgItem to get a pointer of the control, you also could create a member for the control by wizard in resource editor.

// if first radio button checked
if (m_radName.GetCheck() == TRUE)
{
     m_editNameFileNum.EnableWindow(TRUE);
     m_editNumberFileNum.EnableWindow(FALSE);
}
else if (m_radNumber.GetCheck() == TRUE)
{
     m_editNameFileNum.EnableWindow(FALSE);
     m_editNumberFileNum.EnableWindow(TRUE);
}
else if (m_radRecord.GetCheck() == TRUE)
{
     m_editNameFileNum.EnableWindow(FALSE);
     m_editNumberFileNum.EnableWindow(FALSE);
}

Open in new window


if you add member variables for each input control or radio group, you even don't need the button controls:

then your code could look much better and more readable like

// get data from screen
UpdateData(TRUE);
// the radio button selection is now in m_radSelection;
m_editNameFileNum.EnableWindow(m_radSelection == Name_selected);
m_editNumberFileNum.EnableWindow(m_radSelection == Number_selected);

Open in new window


Sara
the 'm_radSelection' must be replaced by the int member variable which you added by wizard for the first radio button (and which is supposed to take the selection of the whole group of radio buttons).

Many thanks Sara.

Is it fine that I directly create the variables like

void CMFCApplication8Dlg::OnBnClickedRadioname()
{
	// TODO: Add your control notification handler code here
	CButton* pButton = (CButton*)GetDlgItem(IDC_RADIO_name);
	CWnd* pEdit = GetDlgItem(IDC_EDIT_name);
	int nCheck = pButton->GetCheck();

	CButton* pButton2 = (CButton*)GetDlgItem(IDC_RADIO_number);
	CWnd* pEdit2 = GetDlgItem(IDC_EDIT_number);
	int nCheck2 = pButton2->GetCheck();

	CButton* pButton3 = (CButton*)GetDlgItem(IDC_RADIO_data_rec);
	int nCheck3 = pButton3->GetCheck();
	...

Open in new window


instead of using the wizard to create the variables?
it is ok, but the wizard thing is much easier code and much more effective.

in resource editor right-click on first radio button, choose add member, choose category 'Value', choose int type, and name the control m_radSelection.

the rest will do the wizard.

in OnInitDialog you would set m_radSelection=0; and call UpdateData(FALSE); what would make that the first radio button was checked. if you do UpdateData(TRUE); the current selection will be put to m_radSelection.

Sara
if you want to define a member variable for the value in the wizard dialog 'add member variable', you have to choose 'value' from category combobox while the default is 'control'.

Sara
Good day Sara,

BTW, do you have any ideas which good C / C++ compiler does also work on Linux platform?

Have a good weekend!
you have to take gcc and perhaps qt for gui library and ide.

it has major differences to visual studio and mfc. so if you intend to port the gui project to linux, you may expect a long-time learning process. the savebinaryfile and readbinaryfile though easily can be ported if you simply replace the little parts where windows api was accessed.

Sara
Many thanks Sara.
Very sorry Sara.

I think I am having the similar codes like yours, below

void CMFCApplication8Dlg::OnBnClickedRadioname()
{
	// TODO: Add your control notification handler code here
	CButton* pButton = (CButton*)GetDlgItem(IDC_RADIO_name);
	CWnd* pEdit = GetDlgItem(IDC_EDIT_name);
	int nCheck = pButton->GetCheck();

	CButton* pButton2 = (CButton*)GetDlgItem(IDC_RADIO_number);
	CWnd* pEdit2 = GetDlgItem(IDC_EDIT_number);
	int nCheck2 = pButton2->GetCheck();

	CButton* pButton3 = (CButton*)GetDlgItem(IDC_RADIO_data_rec);
	int nCheck3 = pButton3->GetCheck();

	if (nCheck == 1)
	{
		pEdit->EnableWindow(TRUE);
		pEdit2->EnableWindow(FALSE);
	}

	if (nCheck2 == 1)
	{
		pEdit->EnableWindow(FALSE);
		pEdit2->EnableWindow(TRUE);
	}

	if (nCheck3 == 1)
	{
		pEdit->EnableWindow(FALSE);
		pEdit2->EnableWindow(FALSE);
	}
	...

Open in new window

can you please point it out, where I should adjust it, in above, to ensure only one radio button can be selected, each time?
i tried your rc file. i can read it but not change since my vs version is 2012 and not vs 2013.

i will make an own project with vs2012 where i will do the significant changes to your approach.

we can talk tomorrow how to overtake my changes to your project.

Sara
i made a new project mfcapplication8 in vs 2008 (as vs2012 has some issues at my pc).

you may replace resource.h, mfcapplication8.h and mfcapplication8.cpp. then open rc file using "Open with" and choose source code text editor. search for the dialog resource IDD_MFCAPPLICATION8_DIALOG and replace it.

resource.h

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by MfcApplication8.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_MFCAPPLICATION8_DIALOG      102
#define IDR_MAINFRAME                   128
#define IDC_GRP_RAD                     1000
#define IDC_RAD_NAME                    1001
#define IDC_RAD_NUMBER                  1002
#define IDC_RAD_DATARECORD              1003
#define IDC_EDIT_NAME_FILENUM           1004
#define IDC_STAT_NAME_FILENUM           1005
#define IDC_STAT_NUMBER_FILENUM         1006
#define IDC_EDIT_NUMBER_FILENUM         1007
#define IDC_STAT_FILE_PATH              1008
#define IDC_EDIT_FILE_PATH              1009

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        129
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1010
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

Open in new window


dialog resource in mfcapplication8.rc

IDD_MFCAPPLICATION8_DIALOG DIALOGEX 0, 0, 320, 200
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "MfcApplication8"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,209,179,50,14
    PUSHBUTTON      "Cancel",IDCANCEL,263,179,50,14
    GROUPBOX        "Binary File Selection",IDC_GRP_RAD,20,18,261,97
    CONTROL         "Name Index",IDC_RAD_NAME,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,33,35,61,10
    CONTROL         "Number Index",IDC_RAD_NUMBER,"Button",BS_AUTORADIOBUTTON,33,55,61,10
    CONTROL         "Data Record",IDC_RAD_DATARECORD,"Button",BS_AUTORADIOBUTTON,33,75,61,10
    LTEXT           "File Number",IDC_STAT_NAME_FILENUM,122,37,39,8
    EDITTEXT        IDC_EDIT_NAME_FILENUM,165,34,29,14,ES_AUTOHSCROLL
    LTEXT           "File Number",IDC_STAT_NUMBER_FILENUM,121,56,39,8
    EDITTEXT        IDC_EDIT_NUMBER_FILENUM,165,52,29,14,ES_AUTOHSCROLL
    LTEXT           "File Path",IDC_STAT_FILE_PATH,32,96,28,8
    EDITTEXT        IDC_EDIT_FILE_PATH,72,94,199,14,ES_AUTOHSCROLL
END

Open in new window


// MfcApplication8Dlg.h : header file
//

#pragma once
#include "afxwin.h"

enum
{
    nameSelected,
    numberSelected,
    recordSelected
};


// CMfcApplication8Dlg dialog
class CMfcApplication8Dlg : public CDialog
{
public:

    int m_radSelection;
    CStatic m_statNameFileNum;
    CStatic m_statNumberFileNum;
    CEdit m_editNameFileNum;
    CEdit m_editNumberFileNum;
    CString m_strNameFileNum;
    CString m_strNumberFileNum;
    CString m_strFilePath;
// Construction
public:
	CMfcApplication8Dlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_MFCAPPLICATION8_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedRadName();
    afx_msg void OnBnClickedRadNumber();
    afx_msg void OnBnClickedRadDatarecord();
    afx_msg void OnEnKillfocusEditNameFilenum();
    afx_msg void OnEnKillfocusEditNumberFilenum();

    void EnableDisableFileNum();
    void BuildFileName(const CString & strFileName);
};

dialog cpp

[code]// MfcApplication8Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "MfcApplication8.h"
#include "MfcApplication8Dlg.h"

#include "BinaryHeader.h"

#include <string>
#include <sstream>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()

Open in new window


// CMfcApplication8Dlg dialog



CMfcApplication8Dlg::CMfcApplication8Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMfcApplication8Dlg::IDD, pParent)
    , m_radSelection(0)
    , m_strNameFileNum(_T(""))
    , m_strNumberFileNum(_T(""))
    , m_strFilePath(_T(""))
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMfcApplication8Dlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_STAT_NAME_FILENUM, m_statNameFileNum);
    DDX_Control(pDX, IDC_STAT_NUMBER_FILENUM, m_statNumberFileNum);
    DDX_Control(pDX, IDC_EDIT_NAME_FILENUM, m_editNameFileNum);
    DDX_Control(pDX, IDC_EDIT_NUMBER_FILENUM, m_editNumberFileNum);
    DDX_Text(pDX, IDC_EDIT_NAME_FILENUM, m_strNameFileNum);
    DDX_Text(pDX, IDC_EDIT_NUMBER_FILENUM, m_strNumberFileNum);
    DDX_Text(pDX, IDC_EDIT_FILE_PATH, m_strFilePath);
    DDX_Radio(pDX, IDC_RAD_NAME, m_radSelection);
}

BEGIN_MESSAGE_MAP(CMfcApplication8Dlg, CDialog)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
    ON_BN_CLICKED(IDC_RAD_NAME, &CMfcApplication8Dlg::OnBnClickedRadName)
    ON_BN_CLICKED(IDC_RAD_NUMBER, &CMfcApplication8Dlg::OnBnClickedRadNumber)
    ON_BN_CLICKED(IDC_RAD_DATARECORD, &CMfcApplication8Dlg::OnBnClickedRadDatarecord)
    ON_EN_KILLFOCUS(IDC_EDIT_NAME_FILENUM, &CMfcApplication8Dlg::OnEnKillfocusEditNameFilenum)
    ON_EN_KILLFOCUS(IDC_EDIT_NUMBER_FILENUM, &CMfcApplication8Dlg::OnEnKillfocusEditNumberFilenum)
END_MESSAGE_MAP()


// CMfcApplication8Dlg message handlers

BOOL CMfcApplication8Dlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
    m_radSelection = nameSelected;
    m_strFilePath  = _T("C:\\dp4\\");
    UpdateData(FALSE);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMfcApplication8Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMfcApplication8Dlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMfcApplication8Dlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void CMfcApplication8Dlg::EnableDisableFileNum()
{
    m_statNameFileNum.EnableWindow(m_radSelection == nameSelected);
    m_editNameFileNum.EnableWindow(m_radSelection == nameSelected);
    m_statNumberFileNum.EnableWindow(m_radSelection == numberSelected);
    m_editNumberFileNum.EnableWindow(m_radSelection == numberSelected);
}

void CMfcApplication8Dlg::OnBnClickedRadName()
{
    // TODO: Add your control notification handler code here
    m_radSelection = nameSelected;     
    EnableDisableFileNum();
    BuildFileName(_T("flname"));
    
}

void CMfcApplication8Dlg::OnBnClickedRadNumber()
{
    // TODO: Add your control notification handler code here
    m_radSelection = numberSelected;     
    EnableDisableFileNum();
    BuildFileName(_T("flnumber"));
}

void CMfcApplication8Dlg::OnBnClickedRadDatarecord()
{
    // TODO: Add your control notification handler code here
    m_radSelection = recordSelected;     
    EnableDisableFileNum();
    BuildFileName(_T("flout"));
}

void CMfcApplication8Dlg::OnEnKillfocusEditNameFilenum()
{
    // TODO: Add your control notification handler code here  
    BuildFileName(_T("flname"));
}

void CMfcApplication8Dlg::OnEnKillfocusEditNumberFilenum()
{
    // TODO: Add your control notification handler code here
    BuildFileName(_T("flnumber"));
}

void CMfcApplication8Dlg::BuildFileName(const CString & strFileName)      
{
    UpdateData(TRUE);
    CString strFileExt = _T(".idx");

    CString strFileNum;
    if (m_radSelection == nameSelected)
    {
        if (m_strNameFileNum.IsEmpty() == false)
        {
            strFileNum = _T("_");
            strFileNum += m_strNameFileNum;
        }
    }
    else if (m_radSelection == numberSelected)
    {
        if (m_strNumberFileNum.IsEmpty() == false)
        {
            strFileNum = _T("_");
            strFileNum += m_strNumberFileNum;
        }
    }
    else
    {   
        strFileExt = _T(".dat");
    }
    CString strFilePath = m_strFilePath;
    int pos = strFilePath.Find(_T("\\fl"));
    if (pos > 0)
    {
        strFilePath = strFilePath.Left(pos+1);
    }
    strFilePath += strFileName;
    strFilePath += strFileNum;
    strFilePath += strFileExt;
    m_strFilePath = strFilePath;

    UpdateData(FALSE);
}

Open in new window


Sara
Sorry Sara. I get these
Error	1	error C2065: 'IDC_ST_NAMIDX_FILNUM' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	81	1	MFCApplication8
Error	2	error C2065: 'IDC_EDIT1' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	82	1	MFCApplication8
Error	3	error C2065: 'IDC_RADIO_name' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	89	1	MFCApplication8
Error	4	error C2065: 'IDC_RADIO_number' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	90	1	MFCApplication8
Error	5	error C2065: 'IDC_RADIO_name' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	183	1	MFCApplication8
Error	6	error C2065: 'IDC_EDIT_name' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	184	1	MFCApplication8
Error	7	error C2065: 'IDC_RADIO_number' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	187	1	MFCApplication8
Error	8	error C2065: 'IDC_EDIT_number' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	188	1	MFCApplication8
Error	9	error C2065: 'IDC_RADIO_data_rec' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	191	1	MFCApplication8
Error	10	error C2065: 'IDC_RADIO_name' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	212	1	MFCApplication8
Error	11	error C2065: 'IDC_RADIO_name' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	214	1	MFCApplication8
Error	12	error C2065: 'IDC_RADIO_name' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	224	1	MFCApplication8
Error	13	error C2065: 'IDC_EDIT_name' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	225	1	MFCApplication8
Error	14	error C2065: 'IDC_RADIO_number' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	228	1	MFCApplication8
Error	15	error C2065: 'IDC_EDIT_number' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	229	1	MFCApplication8
Error	16	error C2065: 'IDC_RADIO_data_rec' : undeclared identifier	c:\mfcapplication8 150615\mfcapplication8\mfcapplication8dlg.cpp	232	1	MFCApplication8

Open in new window

to Resource.h file below

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by MfcApplication8.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_MFCAPPLICATION8_DIALOG      102
#define IDR_MAINFRAME                   128
#define IDC_GRP_RAD                     1000
#define IDC_RAD_NAME                    1001
#define IDC_RAD_NUMBER                  1002
#define IDC_RAD_DATARECORD              1003
#define IDC_EDIT_NAME_FILENUM           1004
#define IDC_STAT_NAME_FILENUM           1005
#define IDC_STAT_NUMBER_FILENUM         1006
#define IDC_EDIT_NUMBER_FILENUM         1007
#define IDC_STAT_FILE_PATH              1008
#define IDC_EDIT_FILE_PATH              1009

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        129
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1010
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

Open in new window

Sorry to my late replies these days as there was environment changes recently and now it is OK.
you have to open the rc file in text mode and replace the snippet of the IDD_MFCAPPLICATION8_DIALOG resource by the one i posted recently. you see that the error messages show small letters in resource ids where the resource.h has caapital letters. you also see that you have ids IDC_EDIT1 which are not part of the snippet i posted.

note, i can't give you my rc file since it was created with vs2008 what probably gives some conversion issues if you include it in vs2013.

Sara
Hi Sara,
when adjusting mfcapplication8.rc, which file to adjust below?
User generated image
Many thanks
SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many thanks Sara.

which is the file I should put these codes?

// MfcApplication8Dlg.h : header file
//

#pragma once
#include "afxwin.h"

enum
{
    nameSelected,
    numberSelected,
    recordSelected
};


// CMfcApplication8Dlg dialog
class CMfcApplication8Dlg : public CDialog
{
public:

    int m_radSelection;
    CStatic m_statNameFileNum;
    CStatic m_statNumberFileNum;
    CEdit m_editNameFileNum;
    CEdit m_editNumberFileNum;
    CString m_strNameFileNum;
    CString m_strNumberFileNum;
    CString m_strFilePath;
// Construction
public:
	CMfcApplication8Dlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_MFCAPPLICATION8_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedRadName();
    afx_msg void OnBnClickedRadNumber();
    afx_msg void OnBnClickedRadDatarecord();
    afx_msg void OnEnKillfocusEditNameFilenum();
    afx_msg void OnEnKillfocusEditNumberFilenum();

    void EnableDisableFileNum();
    void BuildFileName(const CString & strFileName);
};

dialog cpp

[code]// MfcApplication8Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "MfcApplication8.h"
#include "MfcApplication8Dlg.h"

#include "BinaryHeader.h"

#include <string>
#include <sstream>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)

Open in new window

{
      CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
sorry the files i posted were mixed. the following should be the correct  MfcApplication8Dlg.h and MfcApplication8Dlg.cpp

Sara

// MfcApplication8Dlg.h : header file
//

#pragma once
#include "afxwin.h"

enum
{
    nameSelected,
    numberSelected,
    recordSelected
};


// CMfcApplication8Dlg dialog
class CMfcApplication8Dlg : public CDialog
{
public:

    int m_radSelection;
    CStatic m_statNameFileNum;
    CStatic m_statNumberFileNum;
    CEdit m_editNameFileNum;
    CEdit m_editNumberFileNum;
    CString m_strNameFileNum;
    CString m_strNumberFileNum;
    CString m_strFilePath;
// Construction
public:
	CMfcApplication8Dlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_MFCAPPLICATION8_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedRadName();
    afx_msg void OnBnClickedRadNumber();
    afx_msg void OnBnClickedRadDatarecord();
    afx_msg void OnEnKillfocusEditNameFilenum();
    afx_msg void OnEnKillfocusEditNumberFilenum();

    void EnableDisableFileNum();
    void BuildFileName(const CString & strFileName);
};

Open in new window


// MfcApplication8Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "MfcApplication8.h"
#include "MfcApplication8Dlg.h"

#include "BinaryHeader.h"

#include <string>
#include <sstream>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()

// CMfcApplication8Dlg dialog

CMfcApplication8Dlg::CMfcApplication8Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMfcApplication8Dlg::IDD, pParent)
    , m_radSelection(0)
    , m_strNameFileNum(_T(""))
    , m_strNumberFileNum(_T(""))
    , m_strFilePath(_T(""))
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMfcApplication8Dlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_STAT_NAME_FILENUM, m_statNameFileNum);
    DDX_Control(pDX, IDC_STAT_NUMBER_FILENUM, m_statNumberFileNum);
    DDX_Control(pDX, IDC_EDIT_NAME_FILENUM, m_editNameFileNum);
    DDX_Control(pDX, IDC_EDIT_NUMBER_FILENUM, m_editNumberFileNum);
    DDX_Text(pDX, IDC_EDIT_NAME_FILENUM, m_strNameFileNum);
    DDX_Text(pDX, IDC_EDIT_NUMBER_FILENUM, m_strNumberFileNum);
    DDX_Text(pDX, IDC_EDIT_FILE_PATH, m_strFilePath);
    DDX_Radio(pDX, IDC_RAD_NAME, m_radSelection);
}

BEGIN_MESSAGE_MAP(CMfcApplication8Dlg, CDialog)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
    ON_BN_CLICKED(IDC_RAD_NAME, &CMfcApplication8Dlg::OnBnClickedRadName)
    ON_BN_CLICKED(IDC_RAD_NUMBER, &CMfcApplication8Dlg::OnBnClickedRadNumber)
    ON_BN_CLICKED(IDC_RAD_DATARECORD, &CMfcApplication8Dlg::OnBnClickedRadDatarecord)
    ON_EN_KILLFOCUS(IDC_EDIT_NAME_FILENUM, &CMfcApplication8Dlg::OnEnKillfocusEditNameFilenum)
    ON_EN_KILLFOCUS(IDC_EDIT_NUMBER_FILENUM, &CMfcApplication8Dlg::OnEnKillfocusEditNumberFilenum)
END_MESSAGE_MAP()


// CMfcApplication8Dlg message handlers

BOOL CMfcApplication8Dlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
    m_radSelection = nameSelected;
    m_strFilePath  = _T("C:\\dp4\\");
    UpdateData(FALSE);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMfcApplication8Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMfcApplication8Dlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMfcApplication8Dlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void CMfcApplication8Dlg::EnableDisableFileNum()
{
    m_statNameFileNum.EnableWindow(m_radSelection == nameSelected);
    m_editNameFileNum.EnableWindow(m_radSelection == nameSelected);
    m_statNumberFileNum.EnableWindow(m_radSelection == numberSelected);
    m_editNumberFileNum.EnableWindow(m_radSelection == numberSelected);
}

void CMfcApplication8Dlg::OnBnClickedRadName()
{
    // TODO: Add your control notification handler code here
    m_radSelection = nameSelected;     
    EnableDisableFileNum();
    BuildFileName(_T("flname"));
    
}

void CMfcApplication8Dlg::OnBnClickedRadNumber()
{
    // TODO: Add your control notification handler code here
    m_radSelection = numberSelected;     
    EnableDisableFileNum();
    BuildFileName(_T("flnumber"));
}

void CMfcApplication8Dlg::OnBnClickedRadDatarecord()
{
    // TODO: Add your control notification handler code here
    m_radSelection = recordSelected;     
    EnableDisableFileNum();
    BuildFileName(_T("flout"));
}

void CMfcApplication8Dlg::OnEnKillfocusEditNameFilenum()
{
    // TODO: Add your control notification handler code here  
    BuildFileName(_T("flname"));
}

void CMfcApplication8Dlg::OnEnKillfocusEditNumberFilenum()
{
    // TODO: Add your control notification handler code here
    BuildFileName(_T("flnumber"));
}

void CMfcApplication8Dlg::BuildFileName(const CString & strFileName)      
{
    UpdateData(TRUE);
    CString strFileExt = _T(".idx");

    CString strFileNum;
    if (m_radSelection == nameSelected)
    {
        if (m_strNameFileNum.IsEmpty() == false)
        {
            strFileNum = _T("_");
            strFileNum += m_strNameFileNum;
        }
    }
    else if (m_radSelection == numberSelected)
    {
        if (m_strNumberFileNum.IsEmpty() == false)
        {
            strFileNum = _T("_");
            strFileNum += m_strNumberFileNum;
        }
    }
    else
    {   
        strFileExt = _T(".dat");
    }
    CString strFilePath = m_strFilePath;
    int pos = strFilePath.Find(_T("\\fl"));
    if (pos > 0)
    {
        strFilePath = strFilePath.Left(pos+1);
    }
    strFilePath += strFileName;
    strFilePath += strFileNum;
    strFilePath += strFileExt;
    m_strFilePath = strFilePath;

    UpdateData(FALSE);
}

Open in new window

Sorry, I get these

Error	1	error C2653: 'CMFCApplication8Dlg' : is not a class or namespace name	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	71	1	MFCApplication8
Error	2	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	72	1	MFCApplication8
Error	3	error C2653: 'CMFCApplication8Dlg' : is not a class or namespace name	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	72	1	MFCApplication8
Error	4	error C2065: 'IDD' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	72	1	MFCApplication8
Error	5	error C2550: 'CMFCApplication8Dlg' : constructor initializer lists are only allowed on constructor definitions	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	74	1	MFCApplication8
Error	6	error C2065: 'm_hIcon' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	75	1	MFCApplication8
Warning	7	warning C4508: 'CMFCApplication8Dlg' : function should return a value; 'void' return type assumed	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	76	1	MFCApplication8
Error	8	error C2653: 'CMFCApplication8Dlg' : is not a class or namespace name	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	78	1	MFCApplication8
Error	9	error C2248: 'CWnd::DoDataExchange' : cannot access protected member declared in class 'CWnd'	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	80	1	MFCApplication8
Error	10	error C2352: 'CWnd::DoDataExchange' : illegal call of non-static member function	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	80	1	MFCApplication8
Error	11	error C2065: 'm_namidxFilnum' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	81	1	MFCApplication8
Error	12	error C2065: 'm_edNameIdxFilnum' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	82	1	MFCApplication8
Error	13	error C2653: 'CMFCApplication8Dlg' : is not a class or namespace name	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	85	1	MFCApplication8
Error	14	error C2270: 'GetMessageMap' : modifiers not allowed on nonmember functions	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	85	1	MFCApplication8
Error	15	error C3861: 'GetThisMessageMap': identifier not found	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	85	1	MFCApplication8
Error	16	error C2146: syntax error : missing ';' before identifier 'ThisClass'	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	85	1	MFCApplication8

Open in new window

if I have changed this

// MfcApplication8Dlg.h : header file
//

// MFCApplication8Dlg.h : header file
//

#pragma once
#include "afxwin.h"


// CMFCApplication8Dlg dialog
class CMFCApplication8Dlg : public CDialogEx
{
	// Construction
public:
	CMFCApplication8Dlg(CWnd* pParent = NULL);	// standard constructor

	// Dialog Data
	enum { IDD = IDD_MFCAPPLICATION8_DIALOG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


	// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	CString m_namidxFilnum;
	CEdit m_edNameIdxFilnum;
	afx_msg void OnBnClickedRadioname();
	afx_msg void OnBnClickedRadionumber();
};

Open in new window

to

// MFCApplication8Dlg.h : header file
//

#pragma once
#include "afxwin.h"

enum
{
    nameSelected,
    numberSelected,
    recordSelected
};


// CMfcApplication8Dlg dialog
class CMfcApplication8Dlg : public CDialog
{
public:

    int m_radSelection;
    CStatic m_statNameFileNum;
    CStatic m_statNumberFileNum;
    CEdit m_editNameFileNum;
    CEdit m_editNumberFileNum;
    CString m_strNameFileNum;
    CString m_strNumberFileNum;
    CString m_strFilePath;
// Construction
public:
	CMfcApplication8Dlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_MFCAPPLICATION8_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedRadName();
    afx_msg void OnBnClickedRadNumber();
    afx_msg void OnBnClickedRadDatarecord();
    afx_msg void OnEnKillfocusEditNameFilenum();
    afx_msg void OnEnKillfocusEditNumberFilenum();

    void EnableDisableFileNum();
    void BuildFileName(const CString & strFileName);
};

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the CMfcApplication8Dlg was in the sources i posted. ther errors you posted are from mfcapplication8dlg.cpp and it seems that it was your cpp file since the compiler complains that CMFCApplication8Dlg was not defined.

you definitively have to use both header and cpp from my sources and rename your sources such they were not used anymore in the solution. however, it would make sense to rename the class name to CMFCApplication8Dlg cause this name was used also in some other sources of the solution.

open (my) mfcapplication8dlg.h and do ctrl+h. then replace CMfcApplication8Dlg by CMFCApplication8Dlg for all occurrences.

then do the same for (my) MfcApplication8Dlg.cpp.

note, altenatively to renaming your source files and copy my files to the project folder, you could copy the contents of my file to your files. then, change class name to capital 'MFC' and then do a rebuild all to get the stdafx.cpp newly built.

Sara
Many thanks Sara.

I still get these
Error	1	error C2065: 'IDC_STAT_NAME_FILENUM' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	63	1	MFCApplication8
Error	2	error C2065: 'IDC_STAT_NUMBER_FILENUM' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	64	1	MFCApplication8
Error	3	error C2065: 'IDC_EDIT_NAME_FILENUM' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	65	1	MFCApplication8
Error	4	error C2065: 'IDC_EDIT_NUMBER_FILENUM' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	66	1	MFCApplication8
Error	5	error C2065: 'IDC_EDIT_NAME_FILENUM' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	67	1	MFCApplication8
Error	6	error C2065: 'IDC_EDIT_NUMBER_FILENUM' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	68	1	MFCApplication8
Error	7	error C2065: 'IDC_EDIT_FILE_PATH' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	69	1	MFCApplication8
Error	8	error C2065: 'IDC_RAD_NAME' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	70	1	MFCApplication8
Error	9	error C2065: 'IDC_RAD_NAME' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	78	1	MFCApplication8
Error	10	error C2065: 'IDC_RAD_NUMBER' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	79	1	MFCApplication8
Error	11	error C2065: 'IDC_RAD_DATARECORD' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	80	1	MFCApplication8
Error	12	error C2065: 'IDC_EDIT_NAME_FILENUM' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	81	1	MFCApplication8
Error	13	error C2065: 'IDC_EDIT_NUMBER_FILENUM' : undeclared identifier	c:\mfcapplication8\mfcapplication8\mfcapplication8dlg.cpp	82	1	MFCApplication8

Open in new window

after I've adjusted the codes per your given advices. Can you please take a look to this
https://app.box.com/s/8ru6i6sn56j68vnrbgehs9xg8imga1s8

if available? Have a great weekend!
you need to replace your resource.h with mine.

Sara
Yes, I did put that and here are the codes

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by MFCApplication8.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_MFCAPPLICATION8_DIALOG      102
#define IDR_MAINFRAME                   128
#define IDC_RADIO1                      1000
#define IDC_RADIO_name                  1000
#define IDC_RADIO2                      1001
#define IDC_RADIO_number                1001
#define IDC_RADIO3                      1002
#define IDC_RADIO_data_rec              1002
#define IDC_EDIT1                       1003
#define IDC_EDIT_number                 1003
#define IDC_ST_NAMIDX_FILNUM            1004
#define IDC_EDIT_name                   1005
#define IDC_ST_NAMIDX_FILNUM2           1006
#define IDC_EDIT3                       1007

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        129
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1008
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

Open in new window

the resource.h is not mine.

you already had the right one (see
https://www.experts-exchange.com/questions/28674259/Problem-with-MFCApp.html?anchorAnswerId=40836326#a40836326)

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by MfcApplication8.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_MFCAPPLICATION8_DIALOG      102
#define IDR_MAINFRAME                   128
#define IDC_GRP_RAD                     1000
#define IDC_RAD_NAME                    1001
#define IDC_RAD_NUMBER                  1002
#define IDC_RAD_DATARECORD              1003
#define IDC_EDIT_NAME_FILENUM           1004
#define IDC_STAT_NAME_FILENUM           1005
#define IDC_STAT_NUMBER_FILENUM         1006
#define IDC_EDIT_NUMBER_FILENUM         1007
#define IDC_STAT_FILE_PATH              1008
#define IDC_EDIT_FILE_PATH              1009

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        129
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1010
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many thanks Sara I attach objects from previous project in the following

User generated image
I know I can copy the codes fro m previous project. But can I have the details to re-create the objects highlighted?
you would get the structures index_name, index_number, item, rec_struc from binaryfile.h. so the only thing you have to do is to copy the binaryfile.h and binaryfile.cpp either to the new project folder, or, to a folder which is parallel to the new project folder. then add the files (add ... existing item ...) to your new project as described in step 15 to step 19.

Sara
if you are not sure whether the binaryfile.h and binaryfile.cpp are good, post them here in a code block window.

Sara
Many thanks Sara.
should I choose add "Class" or "Resource" to add the file, if I right-click the project?
you have to choose the Solution Explorer and select the 'Project' MfcApplication8. the project is below 'MfcApplication8 Solution'.

then right-click and 'Add' -> 'Existing Item...' and an explorer-like window opens.
then navigate to the folder where binaryfile.h and binaryfile.cpp are located. it should be the MfcApplication8 folder or a folder on same level as MfcApplication8. if you do the latter, you would need to add the folder as relative path for all configurations into the Configuration Properties - VC++ Directories - Include Directories like "..\BinaryFileFolder". the .. is the parent folder.

Sara
Sorry, is it to add the files by choosing the following

User generated image
or not? thanks Sara
you still are in the class view. you have to go to solution explorer which normally is availble via a tab parallel to class view and resource view, but also can be selected by 'View' menu.

the class view shows classes, structures and global variables while the solution explorer shows files.

Sara
Good day Sara,

I've finished all the steps given by you on Jun24 and is able to compile the project fine, excluding these 2 steps

11. select mfcapplication8dlg.h from below and put contents into clipboard:
12. select mfcapplication8dlg.cpp from below and put contents into clipboard:

Open in new window

can I know if I should replace the relevant codes of the project per what you've provided, by the above 2 steps?

Have a great weekend!
yes, you would exchange the full contents of both files. and if you have taken care that the class name was MfcApplication8Dlg  (with Mfc beginning with a capital M followed by small letters fc) it indeed should compile and build just fine.

Sara
Many thanks Sara.
Do you mean I should put the codes of both MfcApplication8Dlg.h and MfcApplication8Dlg.cpp, per what you've provided through the above 2 steps?
Hi Sara,
I've already put the codes of both MfcApplication8Dlg.h and MfcApplication8Dlg.cpp into the project, while I've replaced any occurrence of MfcApplication8 to MfcApplication9. when building the whole solution, I encounter this
Error	1	error C1083: Cannot open include file: 'BinaryFile.h': No such file or directory	c:\mfcapplication9\mfcapplication9\mfcapplication9dlg.cpp	8	1	MfcApplication9
	2	IntelliSense: cannot open source file "BinaryFile.h"	c:\MfcApplication9\MfcApplication9\MfcApplication9Dlg.cpp	8	1	MfcApplication9

Open in new window

while I've added BinaryFile.h into the project as one existed item, on solution explorer.
for including the binaryfile.h it is not enough to add it to the project but you also have to add the folder where the files reside to the include directory settings below vc directories. i already told you that a few comments before.

add it as a relative path for both release and debug configuration.

alternatively you may delete the binaryfile.h and binaryfile.cpp from project tree, then move the files to the project folder, and add them again to the project.

Sara
while I've replaced any occurrence of MfcApplication8 to MfcApplication9.
why not name the project 'ShowBinaryFile' or 'ViewBinaryFile'? do you really think that you ever will go back to mfxcapplicationx again or can draw any benefit from it?

Sara
for including the binaryfile.h it is not enough to add it to the project but you also have to add the folder where the files reside to the include directory settings below vc directories. i already told you that a few comments before.

add it as a relative path for both release and debug configuration.
Sorry Sara. Is there anything got misunderstood, as within the project, I have these 2 files

BinaryFile.cpp
BinaryHeader.h

and should the relevant header file name be "BinaryHeader.h" instead?
and should the relevant header file name be "BinaryHeader.h" instead?
actually you may name it as you like, though normally a header and its cpp have the same name.

binaryfile.h is a good name  and binaryheader.h is a pleonasm.

Sara