Custom MessageBox

J

JonWayn

For quite a while now I have been struggling with a custom messagebox
function and I think its time I seek help on the matter. Hope someone here
has done something similar before.

I have a custom messagebox in a database which is made up of a form, a label
control, and 2 command buttons. The reason I am using this messagebox instead
of VB's MessageBox function is that depending on the urgency of the message,
I want the label to have 1 of 4 background color. The problem comes in when
the message doesnt fit the lable dimensions - when it requires the label to
be wider, taller or both - (there is never the need to make it smaller. It is
left as is if there is more than required room). The crux of the matter is
that if the string passed in is wider than the original label width will
take, I want line breaks inserted in the input string so that the message
will wrap lines until it fits. With the original size of the label, 5 or 6
line-wraps can be acommodated. If the whole string fits within those
parameters, then return the new line-wrapped string. If it doesnt, make
width/height adjustments upto, but not exceeding a predefined width. I am the
only caller of the function so I ensure that the message is constrained to
typical dimensions. Hope that isnt too confusing
 
M

Marshall Barton

JonWayn said:
For quite a while now I have been struggling with a custom messagebox
function and I think its time I seek help on the matter. Hope someone here
has done something similar before.

I have a custom messagebox in a database which is made up of a form, a label
control, and 2 command buttons. The reason I am using this messagebox instead
of VB's MessageBox function is that depending on the urgency of the message,
I want the label to have 1 of 4 background color. The problem comes in when
the message doesnt fit the lable dimensions - when it requires the label to
be wider, taller or both - (there is never the need to make it smaller. It is
left as is if there is more than required room). The crux of the matter is
that if the string passed in is wider than the original label width will
take, I want line breaks inserted in the input string so that the message
will wrap lines until it fits. With the original size of the label, 5 or 6
line-wraps can be acommodated. If the whole string fits within those
parameters, then return the new line-wrapped string. If it doesnt, make
width/height adjustments upto, but not exceeding a predefined width. I am the
only caller of the function so I ensure that the message is constrained to
typical dimensions.


This is a seriously nasty problem. The first thing to do is
change the label control to a text box. Set its Locked
peoperty to Yes and Enabled to No so users can not interact
with it.

Now download the TextHeightWidth sample database from
www.lebans.com and import the function into your database.
Look through the examples to see how to use the function in
your form to adjust the size of the text box to accomodate
the text you want to display.
 

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