Solved

Need to change text in default buttons for CFileDialog

Posted on 1998-10-01
3
302 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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