简体   繁体   中英

Override WinForms MessageBox Control

All, I understand that for extensively customised dialogs I would need to create my own form and ShowDialog() . However, in my current case I would just like to extend the MessageBox class to facilitate a CustomMessageBox that is capable of showing different icons insted of those determined by the system.

I have not overridden such a control before and I am not even sure where to start. Could someone point me in the right direction?

Thanks for your time.

MessageBox is not a control actually (doesn't inherit from Control ), it's just a class.

Actually, it's even almost a static class, as there is no public/protected constructor defined, and only static methods. It's more like a factory.

You probably should write your own, as it's not extendable.

You can't customize MessageBox like that, unfortunately. You will have to roll-your-own.

MessageBox does not support customization beyond changing the message, caption, and the standard buttons that are available. If you want a custom message box, you have to create one yourself. See How to create a custom MessageBox? for an example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM