Click here to Skip to main content
13,763,633 members
Click here to Skip to main content
Add your own
alternative version


17 bookmarked
Posted 10 Feb 2005

Heybo Message Box-Customizable Message Box

, 10 Feb 2005
Rate this:
Please Sign up or sign in to vote.
A customizable MessageBox with sound.

Sample Harness image


I work on projects with non-technical operators. The workstations have a touch screen, with no mouse. Sometimes it is necessary to have a MessageBox display some information. At times, it is hard to be precise clicking Okay with the touch screens because of angle and difference of height of the operators and the small size of the buttons. I was unable to find a simple component to allow a MessageBox with customizable button sizes. I decided to write my own, with a few other features, since I could reuse it for other projects.

Background (optional)

Some others use hooks for existing API message boxes. The hooks generally overwrite the text on the buttons, not the size. This is based on the System.Windows.Forms.Form object. Therefore, you can specify the button size.

Using the code

This code snippet shows how to specify button size, button font, and line size using the HeyboBox.

    // How to call the code with an icon and specified button size.
    HeyboBoxIcon hbi = HeyboBoxIcon.None;
    HeyboBoxButtons hbb = HeyboBoxButtons.OK;
    string text = "Sample Text";
    string caption = "My box caption";
    int buttonHeight = 100;
    int buttonWidth = 150;
    Form ownerForm = this;
    string lineLength = 100;
    Font font = new Font("Arial", 12f);
    DialogResult dr = Heybo.HeyboBox.Show( 
        ownerForm, text,
        caption, hbb, 
        null,//default button
        buttonWidth, lineLength,

Points of Interest

There may be another way of doing this without using the Windows API that is already established, but I could not find it. I made some enumerations for the button groups and for the images. Images are included as a resource in the library. Sounds have been implemented using P/Invoke, however, the code is a little messy.

The size of the box is dynamically determined by the largest of either buttons size, caption length, or text length. You may specify a new line character using the escape character for a new line. There is also a static property to change the font for both the buttons and the text.


Is being made...


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

Generala sick man Pin
youbest.cn7-Dec-06 18:11
memberyoubest.cn7-Dec-06 18:11 
QuestionSource code ?!? Pin
hoangtg29-Nov-05 15:53
memberhoangtg29-Nov-05 15:53 
AnswerRe: Source code ?!? Pin
Boyko Markov6-Feb-07 2:45
memberBoyko Markov6-Feb-07 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.181112.3 | Last Updated 10 Feb 2005
Article Copyright 2005 by hmlinder
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid