0

Hi all,

In my MFC application I've create two buttons, OPEN and CLOSE, used to open a text file and close it. I do it as follows.

void CSRFToolDlg::OnBnClickedOpen()
{
	char* ReadFileName = "G:\\Work On\\CPP\\SRFTool\\text_file.txt" ; 

	if(openFile.Open(ReadFileName, CFile::modeCreate | CFile::modeReadWrite))
	{
		AfxMessageBox("File creates successfully", MB_OK) ;
	}
	else
	{
		AfxMessageBox("Error in file opening", MB_OK) ;
	}
}


void CSRFToolDlg::OnBnClickedClose()
{
	openFile.Close() ;
}

What I want to do is, until user click the Open button the Close button should be disable. How should I do it. Those stuff really new for me.

Thanks

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by eranga262154
0

Yep, but I want to disable it before click the Open button. That mean I want to use inside an event like form load. After all experiment I found that if I declare

GetDlgItem(IDC_CLOSE)->EnableWindow(FALSE) ;

line inside the

OnInitDialog()

Actually it works. What's your comments on it.

Thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.