Solved

Need to change text in default buttons for CFileDialog

Posted on 1998-10-01
3
259 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
Comment Utility
CMyFileDialog::OnInitDialog( ... )
{
.
CWnd* pButton = GetDlgItem( IDOK );
pButton->SetWindowText( "My OK" );

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

Phillip
0
 

Author Comment

by:Gedeon
Comment Utility
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
Comment Utility
// 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now