Change default arrangement of Save and Cancel buttons in SaveFileDialog
Asked Answered
J

2

2

I m coding in c# and I want to change the default arrangement of 'Save' and 'Cancel' buttons in SaveFileDialog. The default arrangement is that the 'Save' button is above the 'Cancel' button.

What I want is to place 'Cancel' button on the right hand side of the 'Save' button.

I searched over the web and found that the text on these buttons can be changed(to which the answer was on stackoverflow itself) and nothing found on changing their arrangements (locations).

Please give me a solution if any of you have experienced this so far....

thank you

Jacobsohn answered 23/3, 2011 at 11:6 Comment(1)
Maybe this could solve your problem Extending the save file dialog classSupplejack
R
4

Please don't do this.

The user is used to where these buttons appear. If you try to change their layout then you will just make you app feel wrong.

If you have to do this then should make sure you use the legacy file dialogs (which will make your dialogs look even more odd on Vista/7). Use the lpfnHook field in the OPENFILENAME struct to obtain hooks in to the dialog procedure. Respond to the CDN_INITDONE notification and move the buttons around with MoveWindow or SetWindowPos. You'll have to hunt for the button window handles.

But really, please don't do this, you'll just make your app worse.

Regular answered 23/3, 2011 at 11:27 Comment(1)
Thank you loads!!! There was a requirement to do so and this solved the problem!!!Jacobsohn
A
3

That rings a bell. When you have the code to change the text of the button then you have the handle of the button window. Which you can then use when you pinvoke GetWindowRect and MoveWindow to move the button somewhere else. Visit pinvoke.net for the declarations.

Beware that the dialog changed in every Windows version. The next one might well break your program. Your customer is not going to be disappointed when you don't do this.

Abroms answered 23/3, 2011 at 12:32 Comment(1)
+1 "Your customer is not going to be disappointed when you don't do this" Made me chuckle anyway.Regular

© 2022 - 2024 — McMap. All rights reserved.