Solved

Edit Box Size

Posted on 1998-08-04
4
213 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL Debugging - Temp Object Content 2 57
Problem to adjust sheet 1 96
WPF issue with Trigger 2 150
Authentication of Web Services 3 111
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

710 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