Solved

Customizing CFileDialog

Posted on 1997-04-30
6
249 Views
Last Modified: 2013-11-20
I would like to rename the "Open" button, but I don't know its control ID. How to get its control ID?
0
Comment
Question by:gulmi
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:mbhakta
ID: 1301246
There is a way of doing it.

Make a tool like spy++ which will automatically monitor the active window . If the active window title/class matches that of the CFileDialog (using FindWindow /EnumWindows). Now, iterate thru all the child windows of your file open dialog and catch the handle of your Ok button ( using EnumChildWindows). Using SetWindowText() you can set the title text.

But beware this isn't as easy as it looks. Mainly because , if your dialog box is modal you will have to execute this process either from another thread or another application.

0
 
LVL 2

Accepted Solution

by:
rajesh032097 earned 100 total points
ID: 1301247
Hi,
Use IDOK as it's control ID. It should work.
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1301248
Hang on, can you please give me one good reason why my answer was rejected. Yes, you can do it by using IDOK as the control ID. But you still need to go thru the technique I have explained to get there. How will you change the button text just by knowing the control ID ? If you have a better technique PLEASE tell me...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Expert Comment

by:rajesh032097
ID: 1301249
Hi Mbhakta,
I used following code to change text in my application in the OnInitDialog() function of my CFileDialog derived class.
CWnd* pParent = GetParent();
CWnd* pWnd = pParent->GetDlgItem(IDOK);
pWnd->SetWindowText("NewName");
It's working fine here.
Please advise me if there are any potential errors in it.

0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1301250
That looks fine to me. But our man Gulmi never mentioned this is what he wanted. His question is one line. I hope in future people come up with more self explainatory questions. Experts are not psychics.

Well done mate. If I were Gulmi I would give you 500 points.
0
 

Author Comment

by:gulmi
ID: 1301251

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 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

21 Experts available now in Live!

Get 1:1 Help Now