Solved

Need to change text in default buttons for CFileDialog

Posted on 1998-10-01
3
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
viewing source code from eclipse 13 111
pre4 challenge 19 116
JQuery serialize and unserialize 8 267
Increment column based of a FK 8 67
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 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