Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

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.
0
georgerr
Asked:
georgerr
  • 4
  • 3
  • 2
1 Solution
 
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mblatCommented:
Look at GetTextMetrics, GetTextExtent, GetTextExtentExPoint

Hope it helps...
0
 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now