Solved

Edit Box Size

Posted on 1998-08-04
4
214 Views
Last Modified: 2013-12-03
I have a dialog box with a multi-line editbox control. The editbox is loaded with some data on WM_INITDIALOG. After the data is in the editbox I would like to resize the dialog and editbox so that the editbox is just big enough to view the longest line. ie: I dont want a horizontal scroll bar. Is there a function or message that can be used to get the witdth of the longest line in the editbox?
I am not using MFC.
0
Comment
Question by:marvinm
[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 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1412999
The closest to that are the EM_LINELENGTH and EM_GETLINECOUNT messages.
You have to iterate trough all lines, and check each line's lenght using EM_LINELENGTH. This way you can get the longest line
0
 

Expert Comment

by:PhilC
ID: 1413000
You could create the window with a horizontal scroll bar, then call GetScrollInfo(HWND,SB_HORZ,SCROLLINFO*);
You could then use the SCROLLINFO structure member .nMax to determine the width to make your window. Then remove the scroll bar from the window.

0
 
LVL 1

Author Comment

by:marvinm
ID: 1413001
Using the scroll info almost works. I am off by a few pixels. Could you give more detail as to how I should calulate the width of my editbox window from the scroll info?
0
 
LVL 6

Accepted Solution

by:
WxW earned 50 total points
ID: 1413002
Use the SetWindowPos() function to change the size of any Window.
To calculate the longest line , just get the text from the window using GetWindowText() . The control breaks the line using \r\n ( or \n , I don't remember ! ) . So you only have to extract each line from the text and do a strlen() .
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

623 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