auto expanding edit box (to overcome limited screen space issue)

Due to *lack of screen space*, I need to implement an edit box that will expand (once it has focus) to show all its (read only) text and then return back to it's original size when the control loses focus.

Can anyone give me some help to achieve this? I have no idea how to calculate the required expanded size of the (multi line) edit box based on the string length and font size!

--Or is there any other method/control I can use to bypass the real estate problem?

Thanks.
LVL 2
georgerrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

williamcampbellCommented:


 I suggest having a button that launches a small dialog with the text (edit) init.
0
mblatCommented:
I have to agree with prev. response - I question usability if such UI control.

Never the less it may work in certain situations...

So to accomplish what you want you need to do the following:

1. Intercept WM_SETFOCUS message.
2. Use MoveWindow or SetWindowPos to change size of you control
3. Intercept WM_KILLFOCUS.
4. Same as #2.

It would be benificial to create your own version of Edit Control and override appropriate functionality.

look at this link

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfcnotes_TN062.asp

it will give you example on how to create custom edit control and paint it in different color.

You can expand on that.

Hope it helps..
0
georgerrAuthor Commented:
Thanks for your feedback.

First, I can't use a button to launch a message box due to lack of screen space.

mblat:  Yes, I was going to use the steps you listed but the question still is:

"I have no idea how to calculate the required expanded size of the (multi line) edit box based on the string length and font size"


0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

mblatCommented:
Look at GetTextMetrics, GetTextExtent, GetTextExtentExPoint

Hope it helps...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mblatCommented:
By the way, if you can't use button to lunch dialog, can't you use let's say double-click on edit control to launch it?

Or something simular, like Ctril-Shift-F8 :-)
0
georgerrAuthor Commented:
hi

I tried having a go with the double click idea.  The edit box doesn't capture double-click messages.  (In class wizard there are no messages for it)

So I tried handling *all* double-clicks on the dialog and checking if the mouse was over the edit box at the time, but this doesn't work either as there doesnt seem to be a double-click even over edit boxes.

any ideas?
0
mblatCommented:
Edit can handle double-clicks just fine.  There are many ways to implement this feature.  My prefered would be to create you own edit class CMyClass derived from CEdit.

Then you can use class wizard to add handling of double-clicks from inside of this class.


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfcnotes_TN062.asp

look at this link.  I already posted it here - it does show example of derived edit class ( not for dbl-clicks though )

hope it helps.
0
williamcampbellCommented:

 Wait a second you don't have room? A button is about the same size as an edit if not smaller ... replace the edit with a button make sure to put '...' at the end of the button description. Data...

 The button's tooltip should also display the edits text for quik viewing.

 Double clicking an edit in my view would be a little non-standard and may lead to many service calls :)
0
georgerrAuthor Commented:
mblat, williamcampbell

thanks both of you for help & comments.  To exlain further, the interface to this app isn't the usual "Windows" GUI and is specific to client requirements (large fonts & controls, touch screen interface, etc).

I've managed to get it working - but after a lot of headaches!

Thanks again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.