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

This will disable the button CButton->EnableWindow(FALSE) .

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.