|
-
March 30th, 1999, 08:22 PM
#1
How to Change the button caption of CFileDialog?
Hi,
I am using CFileDialog for my application, as a prompt to the user to select a
file to be overwritten. The problem is, the button has a caption "Open". how
do i change it to "Overwrite"? Also, how do i change the title of the dialog box?
Raphael
-
March 30th, 1999, 11:30 PM
#2
Re: How to Change the button caption of CFileDialog?
Click the properties for the button
In the caption window type the name you desire for the button
The same applies for your app
-
March 31st, 1999, 12:58 AM
#3
But where do I access the properties for the button?
Hi,
Well, I am not actually deriving a class from CFileDialog. I just use
an object of CFileDialog and then using it.
static char BASED_CODE szFilter[] = "Text Files (*.txt)|*.txt|Word Documents (*.doc)|*.doc|Image Files
(*.jpg;*.bmp;*.gif)|*.jpg; *.bmp;*.gif|All Files (*.*)|*.*||";
CFileDialog myDlg (TRUE, "*.txt", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
myDlg.m_ofn.lpstrTitle ="Overwrite a File";
This much I know how to do, that is to replace the title of the dialog box.
and then to display the dialog box, i just use
myDlg.DoModal();
But how do i change the caption of the OK button? the m_ofn structure does not
have any variable for defining the caption of the OK button
Raphael
-
March 31st, 1999, 01:11 AM
#4
Re: But where do I access the properties for the button?
override OnInitDialog and after CFileDialog has done its stuff,
get a handle to IDOK and change the text on the returned CWnd
Sally
-
March 31st, 1999, 02:16 AM
#5
Re: But where do I access the properties for the button?
Hi,
Before you call DoModal() of the file open dialog box set timer like this.
SetTimer(0,5,NULL);
Add a command handler for WM_TIMER message in your class.
In the handler do this
CWnd* pWndOfTitle = CWnd::FindWindow(NULL, "Overwrite" ;
if(pWndOfTitle ){
CWnd* pWndOfOpen = pWndOfTitle ->GetDlgItem(IDOK);
pWndOfOpen->SetWindowText("Overwrite" ;
}
The result was as expected. But there was a flicker in every 5 ms. Bcoz
windows send WM_TIMER message in every 5ms and the handler gets executed.
I couldn't remove that flicker. If you know the solution please let me know.
Hope this helps u,
Reshmi
-
March 31st, 1999, 03:26 AM
#6
Re: But where do I access the properties for the button?
Hi,
Sorry but how do we override OnInitDialog? Can we do that without deriving
a class from CFileDialog?
-
March 31st, 1999, 03:48 AM
#7
Re: But where do I access the properties for the button?
-
March 31st, 1999, 03:50 AM
#8
Re: But where do I access the properties for the button?
it is better to derive CMyFileDialog from CFileDialog, override OnInitDialog
and SET the text there
Sally
-
March 31st, 1999, 04:15 AM
#9
Re: How to Change the button caption of CFileDialog?
To change the OK button's text, derive a class from CFileDialog and use the undocumented function SetControlText().
To set an initial directory, set the OPENFILENAME structure member lpstrInitialDir to the directory.
CFileDialog dlg(...);
dlg.m_ofn.lpstrInitialDir = "x:\\folder";
dlg.DoModal();
If you look on my web site, at my MFC Example Projects for example 11, the CFileDialog class is set up to allow you to
change the button's text.
To use it:
CXDlg2 dlg(TRUE, _T("*" , NULL,
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
_T("(Your File Type) Files (*.*)|*.*|All Files (*.*)|*.*||" );
dlg.m_ofn.lpstrInitialDir = "x:\\folder";
dlg.SetOKButtonText("OverWrite" ;
dlg.DoModal();
Rail
Recording Engineer/Software Developer
Rail Jon Rogut Software
Rail Jon Rogut Software
-
March 31st, 1999, 04:23 AM
#10
Re: How to Change the button caption of CFileDialog?
Oops... sorry, I answered how to set the initial folder, when you were asking how to set the dialog box title, in the OPENFILENAME structure, set the lpstrTitle value:
CFileDialog dlg(...)
dlg.m_ofn.lpstrTitle = "Select a file";
dlg.DoModal();
Rail
Recording Engineer/Software Developer
Rail Jon Rogut Software
Rail Jon Rogut Software
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|