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.
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.
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(
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...