Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello, I am try to change some text in the saveFileDialog. Like "Save in", "File name".
Use the way HOOK, SetDlgItemText and SetWindowText.

I have change all the text in the openFileDialog succesful use that way. But I don't know why I can't change the text of saveFileDialog, I think the id of item should be the same as openFileDialog.

For now, I can only change the text of "Cancel" Button and the "File name".

Anybody have some idea? Thx
Posted
Updated 6-Oct-10 22:04pm
v2
Comments
TheyCallMeMrJames 6-Oct-10 10:56am    
Just a head's up more than anything (and this might not be too important to you) but a consideration to make when doing this is that you instantly lose globalization support for the dialogs, unless you're handling that in your re-labeling yourself.
Toli Cuturicu 6-Oct-10 15:01pm    
Bad user name. Change it!
Dalek Dave 7-Oct-10 4:04am    
Minor Edit for Grammar.

OK, I found the problem. It seems that the some components in the SaveFileDialog not reflash. But I don't find the solution. Also need your help.
PS: the refalsh() doesn't work.
 
Share this answer
 
Comments
chaikun 27-Feb-12 23:35pm    
Hi, recenly I happen to this problem, did you have already solve the problem? Can you share some advice for me? Thanks~
It would be helpful if you would post some of the code that you have tried. In the meantime take a look at this article[^] on how things were done to customize the OpenFile dialog, it may give you some ideas.
 
Share this answer
 
Comments
Nemesis_Satan 7-Oct-10 4:01am    
Thank you CIDev
I have read the article over times.

I write the code here:

HookProc dlgHookProc = new HookProc(DialogHookProc);
int hHook = setWindowHookEx((int)WH_CBT, dlgHookProc, (IntPtr)0,
(int)GetCurrentThreadId());

SaveFileDialog controlex = new SaveFileDialog();
controlex.showDialog(this);

UnhookwindowsHookEx(hHook);

private static int DialogHookProc(int ncode, IntPtr wParam, IntPtr lParam)
{
if(ncode < 0)
{
return CallNextHookEx(hHook, ncode, wParam, lParam);
}
else if(ncode == 5)
{
SetDlgItemText(wParam, 1, "Oui");
SetDlgItemText(wParam, 2, "Non");
SetDlgItemText(wParam, 1091, "File dans");
SetDlgItemText(wParam, 1090, "Nom du file");
SetDlgItemText(wParam, 1089, "Type");
SetWindowText(wParam, "Enregistrer");
}

return CallNextHookEx(hHook, ncode, wParam, lParam);
}

Here is the most important code, in the function DialogHookProc, the SetDlgItemText and SetWindowText are used for change the text of the button, label and the title of window. The number is the ID of the component.

I don't think it's the code problem, because when I change it to openFileDialog, it works good. By the way, I have tested all the ID in the saveFileDialog.

Confused

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900