Click to See Complete Forum and Search --> : File Dialog - Why can I change caption on "Open" button but not "Save" button?


June 18th, 1999, 04:57 PM
I created a subclass of CFileDialog that takes a dialog caption and a caption for the "Open" or "Save" button in addition to the usual parameters to the constructor. This works fine for an open file dialog, but when I use it with a save file dialog, the caption on the "Save" button does not change. Why? The code is as follows:

CMyFileDialog::CMyFileDialog(BOOL bOpenFileDialog, LPCTSTR lpszDefExt,
LPCTSTR lpszFileName, DWORD dwFlags,
LPCTSTR lpszFilter, CWnd* pParentWnd,
const char* strTitle, const char* strBtnCaption
) :
CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter,
pParentWnd
)
{
m_csTitle = strTitle;
m_ofn.lpstrTitle = m_csTitle;
m_csBtnCaption = strBtnCaption;
}

BOOL CMyFileDialog::OnInitDialog()
{
CFileDialog::OnInitDialog();

GetParent()->SetDlgItemText(IDOK, m_csBtnCaption);

return TRUE;
}

Rail Jon Rogut
June 18th, 1999, 05:40 PM
Hmm... it should work the same for Save As and for Open, but you could also use the undocumented function SetControlText()... to see how it can be used, check out Example 11 on my web site at
http://home.earthlink.net/~railro/mfc_link.html

Recording Engineer/Software Developer
Rail Jon Rogut Software
railro@earthlink.net
http://home.earthlink.net/~railro/