Need advice on making a MessageBox replacement

  • Thread starter Jeff Johnson [MVP: VB]
  • Start date
J

Jeff Johnson [MVP: VB]

I'm looking to make an enhanced MessageBox. I want to make it work very much
like the regular MessageBox as far as developers are concerned, so I'd like
to use the Show() method to display it. However, I want it displayed
modally, which we normally achieve with ShowDialog(). Is there a way that
the called form can force itself to display modally, or can you think of
another way I can do this?

Another question I have is about icons. I want to pass a standard
MessageBoxIcon enum to the Show() method and then display the OS-specific
icon that was requested. In other words, it'll look different on XP than on
2000. To this end I can't simply stick a graphic in my assembly. I can
probably figure out how to DRAW the icon myself, it's RETRIEVING it from the
system that's beyond me right now. Suggestions?
 
J

Jeff Johnson [MVP: VB]

Another question I have is about icons. I want to pass a standard
MessageBoxIcon enum to the Show() method and then display the OS-specific
icon that was requested. In other words, it'll look different on XP than on
2000. To this end I can't simply stick a graphic in my assembly. I can
probably figure out how to DRAW the icon myself, it's RETRIEVING it from the
system that's beyond me right now. Suggestions?

Geez, ignore that part. I just discovered the SystemIcons class....
 
H

Herfried K. Wagner [MVP]

* "Jeff Johnson said:
Another question I have is about icons. I want to pass a standard
MessageBoxIcon enum to the Show() method and then display the OS-specific
icon that was requested.

Some tips:

My FAQ:

For the system icons:

Have a look at the 'SystemIcons' class.

For the system sounds:

\\\
Private Declare Auto Function MessageBeep Lib "user32.dll" ( _
ByVal wType As Int32 _
) As Boolean

Private Const MB_ICONASTERISK As Int32 = &H40 ' Information.
Private Const MB_ICONEXCLAMATION As Int32 = &H30 ' Ausrufezeichen.
Private Const MB_ICONHAND As Int32 = &H10 ' Stopschild.
Private Const MB_ICONQUESTION As Int32 = &H20 ' Fragezeichen.
Private Const MB_OK As Int32 = &H0 ' Standard-OK.
///

Usage:

\\\
MessageBeep(MB_ICONHAND)
///

Notice that Windows' messagebox supports copying its contents to the
clipboard by pressing Ctrl+C.
 
J

Jeff Johnson [MVP: VB]

Is there a way that
the called form can force itself to display modally, or can you think of
another way I can do this?

Okay, I'm a twit and should have just tried it first. You can call
ShowDialog() from within the called form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top