Solved

Need to change text in default buttons for CFileDialog

Posted on 1998-10-01
3
284 Views
Last Modified: 2013-11-20
Using CFileDialog, I need to change the text of the default
buttons for "Open" and "Cancel".  I believe I need to
override CFileDialog::OnInitDialog(), but I am not sure
how to do it or what needs to be done to do it.
0
Comment
Question by:Gedeon
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
psdavis earned 50 total points
ID: 1322826
CMyFileDialog::OnInitDialog( ... )
{
.
CWnd* pButton = GetDlgItem( IDOK );
pButton->SetWindowText( "My OK" );

pButton = GetDlgItem( IDC_CANCEL );
pButton->SetWindowText( "My Cancel" );
.
}

Phillip
0
 

Author Comment

by:Gedeon
ID: 1322827
How is the CMyFileDialog class set up?  I know it gets derrived
from the CFileDialog class and you have a virtual function to
override OnFileInit(), but I keep getting compile/link errors
when it comes to the constructor.  I tried having a constructor
of:

class CMyFileDialog : CFileDialog
{
public:
   CMyFileDialog( BOOL bOpenFileDialog );
protected:
   virtual BOOL OnInitDialog();
};

as well as:

class CMyFileDialog : CFileDialog
{
public:
CMyFileDialog(BOOL bOpenFileDialog,  
              LPCTSTR lpszDefExt = NULL,
              LPCTSTR lpszFileName = NULL,
              DWORD dwFlags = OFN_HIDEREADONLY |                               OFN_OVERWRITEPROMPT,
              LPCTSTR lpszFilter = NULL,
              CWnd* pParentWnd = NULL);
protected:
   virtual BOOL OnInitDialog();
};

but I get unresolved external errors when I try to create the
instance of CMyFileDialog by:

CMyFileDialog dlg( TRUE );

or

CMyFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY |                   OFN_OVERWRITEPROMPT, NULL, NULL );
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1322828
// I haven't done an override of the CFileDialog, but I have done a CPrintDialog override.  Since they're both common dialogs, there shouldn't be a problem.  Here's my header file

class CFingerPrintDialog : public CPrintDialog
{
 DECLARE_DYNAMIC(CFingerPrintDialog)

public:
 CFingerPrintDialog(BOOL bPrintSetupOnly,
 // TRUE for Print Setup, FALSE for Print Dialog
 DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS      | PD_HIDEPRINTTOFILE | PD_NOSELECTION,
  CWnd* pParentWnd = NULL);
  static const DWORD m_nHelpIDs[];

// Dialog Data
//{{AFX_DATA(CFingerPrintDialog)
  enum { IDD = IDD_FINGERPRINTDIALOG };
  BOOL      m_bDisplayMinutiaeLocation;
  BOOL      m_bDisplayImage;
//}}AFX_DATA

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFingerPrintDialog)
protected:
  virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
//}}AFX_VIRTUAL

protected:
//{{AFX_MSG(CFingerPrintDialog)
//}}AFX_MSG

DECLARE_MESSAGE_MAP()
};

// And the implementation

IMPLEMENT_DYNAMIC(CFingerPrintDialog, CPrintDialog)

CFingerPrintDialog::CFingerPrintDialog(BOOL bPrintSetupOnly, DWORD dwFlags, CWnd* pParentWnd) :
CPrintDialog(bPrintSetupOnly, dwFlags, pParentWnd)
{
//{{AFX_DATA_INIT(CFingerPrintDialog)
  m_bDisplayMinutiaeLocation = FALSE;
  m_bDisplayImage = TRUE;
//}}AFX_DATA_INIT
}

BEGIN_MESSAGE_MAP(CFingerPrintDialog, CPrintDialog)
//{{AFX_MSG_MAP(CFingerPrintDialog)
  ON_WM_CONTEXTMENU()
  ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CFingerPrintDialog::DoDataExchange(CDataExchange* pDX)
{
  CPrintDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFingerPrintDialog)
  DDX_Check(pDX, IDC_DISPLAY_MINUTIAE_LOCATIONS, m_bDisplayMinutiaeLocation);
  DDX_Check(pDX, IDC_DISPLAY_IMAGE, m_bDisplayImage);
//}}AFX_DATA_MAP
}

Good luck.

Phillip
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question