Change default arrangement of Save and Cancel butt

2020-03-30 02:12发布

问题:

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

回答1:

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.



回答2:

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.



回答3:

Maybe this could solve your problem Extending the save file dialog class