There is a class in which the method is described:

public static extern int MessageBox(IntPtr handle, string text, string title, uint type); 

I call it with the specified parameters in the handler:

 IntPtr handle = this.Handle; string text = "text"; string title = "title"; uint type = 4; WinAPIClass.MessageBox(handle, text, title, type); 

MB_ICONQUESTION you please MB_ICONQUESTION me how to add an MB_ICONQUESTION icon?

1 answer 1

The correct answer is with the help of MessageBox api.

You can try two options.

1. hacker :)


  1. get HWND MessageBox windows,
  2. get the HWND sub-windows where the native icon is located (no matter what),
  3. load your bitmap (from a resource or file),
  4. using SendMessage, load your bitmap there (to the window from point 2).

2. Write yourself MessageBox from scratch


This is not as difficult as it seems, for example, based on the Dialog element.

There are third-party developments, here are some links:

TaskDialogIndirect creates, displays and manages the task dialog box. The task dialog contains the application-defined icons, messages, title, check box, links to commands, buttons and switches.

Using Windows Hooks to Improve MessageBox in .NET

CustomMessageBox - works just like a regular message class. By Brian Graham

It makes sense to look towards the Metro .NET framework, there are many elements with advanced functionality, including MessageBox (Dialog)