Anyone please provide me with sample code on how do i override the MessageBox class? or more specifically MessageBox.Show()?
Thanks a LOT
Reason: I have a desktop app to which im adding a command line interface. I need to override MessageBox.Show() to not have popups based on certain conditions
6 6946
I don't get what you're asking, what do you mean "Override"? Like make it whenever a messagebox is called not to show? This might be possible in your own form...If it's not what you're asking, please clarify, if you could...
joedeene
Edit: Could some mod delete this? i posted this before he added the reason, and i cant seem to delete this myself
Edit: Could some mod delete this? i posted this before he added the reason, and i cant seem to delete this myself
No reason to delete, it'll be fine.
As to the stopping of MessageBoxes, if its your code, just don't execute the code?
If you want to stop all MessageBox calls from everyprogram, well if it *can* be done, you willd need to check in with the c++/windows guys for some win32_API to stop them. Possibly a "kiosk" mode type of thing?
Sorry about the 'edit' confusion because of lack of reason. I should have added the "EDITED" caption....
Anyways, by 'override', I meant having the implementation of the override keyword. For example. ToString() is defined for every type, but you can still use the 'override' keyword and define a custom ToString() function.
I was hoping for something like that (of course, it wouldnt be using the override keyword) for MessageBox.Show()...
So I have this GUI application with three seperate classes and I am adding a command line interface to it. Everything works fine. The app can figure out when it got called by GUI and when it called throuh CLI.
I *COULD* have if statements everywhere where MessageBox.Show is used but that will get nasty in some places and seems like there has to be a better way to do it....any suggestions are appreciated
Not really sure by "kiosk' mode, but I was hoping I could provide my own implementation of MessageBox.Show to the system...
You could be abstracting out the messagebox.show.
Such as like: -
public static void DisplayMessage(string msg)
-
{
-
//some logic to determine if GUI or commandline
-
//if gui:
-
MessageBox.Show(msg);
-
//if commandline:
-
//whatever you want to do with the commandline.
-
}
-
then instead of calling MessageBox.Show(), you call DisplayMessage()
As to specifically overriding that method, you cant. You can't derive classes from static classes, so you wouldn't be able to create a child class that you could override the method in.
Yup, I was thinking about abstracting it out too. Except that I will have to go through the source and replace MessageBox.Show()....worse comes to worse, thats what I am gonna do...
I did realize that Show is a static method...so I guess abstraction is the best way to go.
Thanks people
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bhavna |
last post by:
I have a datetimepicker (dtp) on my windows form
the user initially selects a date and then selects the rooms they wish to book
The problem i have is that when the user goes back and tries to...
|
by: Rich Tasker |
last post by:
I have a strange situation. A simple call to MessageBox.Show("XXX", "YYY")
does not display the message in the messagebox with a visible font. Based on
the content of the messagebox, the box...
|
by: Dennis C. Drumm |
last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am
building a custom MessageBox dialog that has, among other things, a few new
button options (yes to all, no to all, etc.)...
|
by: Saso Zagoranski |
last post by:
Hi!
I'm trying to make my own MessageBox... What I would like to know is, how
the MessageBox class is implemented?
I could have something like:
new MyMessageBox().ShowDialog();
but I would...
|
by: songie D |
last post by:
Does c# support overriding by name and not signature
For instance I am building a custom collection class, that ca
only take a certain type of object
For this, I have added an override for add...
|
by: Sin |
last post by:
I'm currently evaluating VC.NET as the new platform for the company I work
for and things are looking grim... We're up against another IDE which took
me about 5 minutes to master and I've been...
|
by: alex_f_il |
last post by:
The class centers MessageBox inside the parent rectangle.
Enjoy!
using System;
using System.Windows.Forms;
using System.Text;
using System.Drawing;
using System.Runtime.InteropServices;
...
|
by: Peter E. Granger |
last post by:
I'm having a strange problem (or at least it seems strange to me) trying to
display a MessageBox in a VC++ .NET forms application.
If I put the call to MessageBox::Show in the form's .h file, it...
|
by: Dave Booker |
last post by:
It looks like the language is trying to prevent me from doing this sort of
thing. Nevertheless, the following compiles, and I'd like to know why it
doesn't work the way it should:
public class...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |