Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to change text in default buttons for CFileDialog

Posted on 1998-10-01
3
Medium Priority
?
314 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 150 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 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