Skip to content

MessageBoxIcon as PictureBox Image #316

Closed

Description

@itg-assistant

Cris asked 2016-10-12 19:25:15 UTC

Hi,

I have a customized exception handler that opens a form with a detailed error information and an option to email the error report. I want to use Wisej MessageBoxIcon instead of an old 3-d gif file I used before. I tried to use:

pictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap(). It works but id doesn't give me the one used by Wisej. I also tried

pictureBox1.Image = Wisej.Web.MessageBoxIcon.Error.????? but I am stuck on how to convert it into an image.

Thanks.

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-10-13 12:38:33 UTC

    Use pictureBox1.ImageSource="messagebox-error". Check in the theme file for the different icon names under "images".

    The name after "messagebox-" corresponds to the MessageBoxIcon enum. But you can use any theme image name in ImageSource.

    Best,

    Luca

  2. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Cris answered 2016-10-17 11:56:03 UTC

    Hi Luca,

    Yes! It works. But...the image fill-color is black. I saw the right color in Appearances.MessageBox.Image..properties.textColor. Is there a way I can use them and how?

    Actually, I've already changed the fill-color of those images, replaced messagebox-* in the file and it's working. But I would prefer to use whatever is the value in the theme file, if possible. And I really do not know how it would affect other parts of Wisej that use those images after replacing them.

    Thanks.

  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-10-17 14:16:23 UTC

    Hi Cris,

    You can set the ForeColor property of the picture box. If you want to use the colors from the theme you can set the color to a named theme color, or simply use any other color. To use a theme color do this:

    this.pictureBox1.ForeColor = Color.FromName("invalid");

    If there is a name mismatch, you can ensure that it uses the theme color like this:

    this.pictureBox1.ForeColor = Color.FromName("@invalid");

    This is how Wisej handles SVG icons and images vs. font icons:

    • SVG icons are typically black since they use the fill color property to fill the icon.

    • SVG colored icons can use any color in addition to the "dynamic" fill color.

    • Font icons (which are inherently a hack devised years ago when browsers didn't fully support svg images) are always mono color. You can't have colored font icons.

    • Wisej preloads the svg icons and caches them as xml documents. When the svg image is used on a widget, wisej changes the fill color to use the widget's text color. If the icon is monochrome it will adapt to the text color, otherwise it's unchanged.

    • Additionally, if the icon is used as a background image, Wisej can set the css fill color value using the style value from the theme.

    HTH

    Best,

    Luca

  4. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Cris answered 2016-10-18 05:53:43 UTC

    Hi Luca,

    Got it working using the ForeColor property and the built-in theme. There is no such property in WinForm and I was surprised.

    Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions