?
Solved

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

Posted on 2003-03-17
9
Medium Priority
?
211 Views
Last Modified: 2013-11-20
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
Comment
Question by:georgerr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 8153233


 I suggest having a button that launches a small dialog with the text (edit) init.
0
 
LVL 4

Expert Comment

by:mblat
ID: 8154469
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
 
LVL 2

Author Comment

by:georgerr
ID: 8165385
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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 4

Accepted Solution

by:
mblat earned 200 total points
ID: 8168013
Look at GetTextMetrics, GetTextExtent, GetTextExtentExPoint

Hope it helps...
0
 
LVL 4

Expert Comment

by:mblat
ID: 8168021
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
 
LVL 2

Author Comment

by:georgerr
ID: 8172540
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
 
LVL 4

Expert Comment

by:mblat
ID: 8178616
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
 
LVL 12

Expert Comment

by:williamcampbell
ID: 8182058

 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
 
LVL 2

Author Comment

by:georgerr
ID: 8260560
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question