CfileDialog Text Button Change

Posted on 2003-03-11
Medium Priority
Last Modified: 2013-11-20
Dear friends i have a great problem, I want to change the text of button Open and Cancel,
because i translate it in italian language.
I try with use the IDOK and IDCANCEL but in this way doesn't work.
I want to change the string  "File name" and "File of type" too.

Tonygnos From Italy
Question by:Tonygnos
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
  • 4
  • 3
  • 2
  • +1

Author Comment

ID: 8112286
help me
LVL 12

Expert Comment

ID: 8112629

  One way would be to look for the window

  CWnd* pFileNameWnd = myFileDlg.FindWindow ( "static", "File name:");

  pFileNameWnd->SetWindowText ( "Itialian File Name" );

 Another way

  Each of the controls in CFileDialog has an ID
  So experiment
  CWnd *pWnd = (CWnd*)GetDlgItem ( 1 );

  if ( pWnd )
      pWnd->SetWindowText ( "Test" );

  Until you find the right ID. The RC file for common dialogs exists somewhere I cant remember where though.


Author Comment

ID: 8118352
No, in this way doesn't work too
i'm sorry
Heeeeelp me please!
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.


Expert Comment

ID: 8118380
I think you should create new class that derive from CFileDialog.
On the OnInitDialog function, you call the following:

CWnd* pParent = GetParent();
if (pParent)
    pParent->SetDlgItemText(nID, (LPCSTR)string);

Where nID maybe IDOK, IDCANCEL, or whatever values that you can spy from the standard FileDialog, and string is what you want to set for that control
LVL 12

Expert Comment

ID: 8123528

 Have you tried changing to the Italian Locale?

 Maybe FileDialog already supports Italian!

Expert Comment

ID: 8124647
I've done something similar before. As hoabeo says, you should derive a class from CFileDialog but override OnInitDone() instead of OnInitDialog()

Then you can change the text of the buttons using:
SetControlText(IDOK, _T("Italian Open"));

Expert Comment

ID: 8124697
I just had another look and to find the identifiers for the items in the dialog, take a look at..


There is a table of identifier names near the bottom of the article, under the title "Explorer-Style Control Identifiers"

Author Comment

ID: 8127264
thanks to all but i resolve my problem jet.
i override OninitDialog and i use SetControlText routine.
but I have another question always on CFileDialog window : what are the ID of the text that compare when you go with the mouse on  the explorer icon(up on level,create new folder,list details) or wich kind of command i have to use to hide this function on CfileDialog?

thanks to all

Accepted Solution

jadams117 earned 200 total points
ID: 8129406
In your derived class override OnInitDone() function and put in something like..

void CMyFileDialog::OnInitDone()
     // set text in buttons
     GetParent()->SetDlgItemText(IDOK, "&Hello");
     GetParent()->SetDlgItemText(IDCANCEL, "&Goodbye");

     // get pointer to toolbar containing controls at top-left of dialog
     // look up CToolBarCtrl in MSDN to see members of this object
     CToolBarCtrl *pToolBar = (CToolBarCtrl*) CWnd::FromHandle(FindWindowEx(*GetParent(), NULL, "ToolbarWindow32", NULL));

     // the IDs of the toolbar buttons are
     // 0xA001 - up one level button
     // 0xA002 - create new folde button
     // 0xA003 - list button
     // 0xA004 - details button

     // e.g. set the state of the 'create new folder' button
     pToolBar->SetState(0xA002, TBSTATE_INDETERMINATE);

     // the indices of the toolbar buttons are
     // 0 - separator
     // 1 - up one level button
     // 2 - separator
     // 3 - create new folder button
     // 4 - separator
     // 5 - list button
     // 6 - details button

     // e.g. delete all buttons
     for (int i = pToolBar->GetButtonCount(); i; i--)

Author Comment

ID: 8135342
Thanks to all but jadams117 given to me a exhaustive answer.
Thakyou very mutch

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

752 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