how to get size of text in a Dialog?

MessageBoxes usually size themself according to the text displayed,
depending on fontsize and number of chars.

can anyone please explain (or point me to an URL where it is explained)
how they do it? To keep it simple, lets say we have just a CStatic and
a Text in it.

How do i get the "optimal" values for the region for MoveWindow() ?

0
clqrq (258)
9/14/2006 4:45:30 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
320 Views

Similar Articles

[PageSpeed] 0


".rhavin grobert" <clqrq@yahoo.de> wrote in message
news:1158252329.933561.100380@d34g2000cwd.googlegroups.com...
> MessageBoxes usually size themself according to the text displayed,
> depending on fontsize and number of chars.
>
> can anyone please explain (or point me to an URL where it is explained)
> how they do it? To keep it simple, lets say we have just a CStatic and
> a Text in it.
>
> How do i get the "optimal" values for the region for MoveWindow() ?
>

I am not sure what you mean by Optimal values. To change the size of text,
you can specify the font of whatever size  you want. Make a CFont member
object in the dailog's constructor (so that it lives as long as the control
does) and specify it on to the control (using SetFont) whenever you want to
change its font.

--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com




0
ajaykalra (6842)
9/14/2006 4:49:14 PM
Check this out:

http://msdn2.microsoft.com/en-us/library/z7e878zz.aspx

Tom

".rhavin grobert" <clqrq@yahoo.de> wrote in message 
news:1158252329.933561.100380@d34g2000cwd.googlegroups.com...
> MessageBoxes usually size themself according to the text displayed,
> depending on fontsize and number of chars.
>
> can anyone please explain (or point me to an URL where it is explained)
> how they do it? To keep it simple, lets say we have just a CStatic and
> a Text in it.
>
> How do i get the "optimal" values for the region for MoveWindow() ?
> 


0
tserface (3861)
9/14/2006 4:49:48 PM
Tom Serface spoke wisely:
> Check this out:
> http://msdn2.microsoft.com/en-us/library/z7e878zz.aspx

exactly what i was looking for, thx a lot;-)

0
clqrq (258)
9/14/2006 5:11:37 PM
"Tom Serface" <tserface@msn.com> wrote in message 
news:%2380RL3B2GHA.2196@TK2MSFTNGP06.phx.gbl...
> Check this out:
>
> http://msdn2.microsoft.com/en-us/library/z7e878zz.aspx
>

In addition, if you have multi line text and know the desired width, use 
DrawText (DT_CALCRECT),  (I think it is DT_CALCRECT) to compute the required 
height.

-- David
http://www.dcsoft.com


0
dc2983 (3206)
9/14/2006 5:51:02 PM
> "Tom Serface" <tserface@msn.com> wrote in message
> news:%2380RL3B2GHA.2196@TK2MSFTNGP06.phx.gbl...
> > Check this out:
> >
> > http://msdn2.microsoft.com/en-us/library/z7e878zz.aspx
> >
>
> In addition, if you have multi line text and know the desired width, use
> DrawText (DT_CALCRECT),  (I think it is DT_CALCRECT) to compute the required
> height.

I have actually always used DrawText.

---
Ajay

0
ajaykalra (6842)
9/14/2006 6:05:18 PM
Reply:

Similar Artilces:

New page set to wrong percentage size
Hi, I usually view my pages at 100%. I wanted to show a separate, additional window at 75% which worked fine. However, every time I open a new window, it resorts to 75%. Is there a way to set the default back to 100% for new windows? Many thanks, Dave On 15 Nov, 07:30, Dave <enquir...@photographybyward.co.uk> wrote: > Hi, > > I usually view my pages at 100%. I wanted to show a separate, > additional window at 75% which worked fine. However, every time I open > a new window, it resorts to 75%. Is there a way to set the default > back to 100% for new win...

I've never used a RichEdit control before and I am getting an assertion...
My application's ::InitInstance calls AfxInitRichEdit2() (which returns TRUE) The dialog I have placed the control on is created dynamically and in the wizard generated code: void CFileScanViewer::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_RICHEDIT_RESULTS, m_oRichEditResults); } DDX_Control fails with an ASSERTION because all the way down in CDataExchange::PrepareCtrl the call to GetOleControlSite( control ID ) returns NULL. IDC_RICHEDIT_RESULTS is the ID of a RichEdit 2.0 control. m_oRichEditResults was created by using the dialog...

Text #3
In Cell A1,2 ,3 ect i have the following info 12345BO 1234BO 123456BO How do i convert these in Cells B1, 2, 3 etc to : 012345 001234 123456 To create a 6 figure number with the BO dropped off? in column b put this formula find(a1,"BO",1) in column c put this formula mid(a1,1,b1-1) format the c column to numbers "Dava Sutts" wrote: > In Cell A1,2 ,3 ect i have the following info > > 12345BO > 1234BO > 123456BO > > How do i convert these in Cells B1, 2, 3 etc to : > 012345 > 001234 > 123456 > > To create a 6 figure number with th...

Scrolling Text Field
I am not sure if this is the correct forum or not. I use FrontPage to manage my personal website and I am one step above a novice. On several of my pages I post rather lengthy clips of VBA code. I would like to display this code in some sort of fixed sized text field where visitors could scroll to read or select and copy the text. I have found on the Insert menu a Form>Insert Text Area control that almost suit the bill if I could only figure out how "lock" it so that the content cannot be altered by visitors. Can this be done or is there a more appropriate type...

Line Break in unbound text box with hyperlink
Hi. I have a text box that displays a generated hyperlink on a report. The problem is that sometimes the hyperlink is longer than the text box and it grows vertically and inserts a line break after the end of the first line. When the user clicks the link on the electronic PDF created from the report, it only picks up the first line of link. Is there a way to tell it to "wrap" to pick up the all the lines? Thanks, Cathy ...

Text Box Invisible
I have Word 2007 and have been using it for over a year. Recently, text boxes and drawings are invisible in all but Print Preview and Full Screen Reading mode. They used to be visible in other modes until the following sequence of events occurred: 1) I sent a Word 2007 document out for review. 2) The reviewer returned the document in compatibility mode with Track Changes on. 3) I accepted all changes. It appears my preferences and styles were changed. I looked for a way to show/hide text boxes and drawings, but couldn't find anything. On Tue, 17 Nov 2009 12:14:09 -08...

On Send/Receive: Dialog box "The operation failed. Object not fo
Outlook 2007. When I click on send/receive, I get a dialog box that reads "The operation failed. An object could not be found". Initial set-up was successful because Outlook bounced a confirmation message to my ISP and it came back properly. I can use e-mail through Explorer and my ISP, but not through Outlook. This is a problem with a new Gateway GM5420 computer, new Microsoft Vista, and a new installation of Microsoft Office Professional 2007. See if this helps: http://support.microsoft.com/kb/312354/en-us You receive the "The operation failed. An object could no...

Excel 2003 Gets Slow
Hello, I have been using Excel 2003 for about 6 months now, i have been experiencing a problem that is getting worst as days go by, my problem is that when ever i open excel and work continiously i'm ok but as soon as i walk away for about ten minutes or so and i leave excel open with what ever i was working on it just sits there for abou five minutes or so to close and i have to reboot my machine to get back to normal. Any suggestions. Henry ...

Application Window Size
I have a database which has the facilty to open another mdb and then open a specific form. I have used the 'CreateObject("Access.Application")' method. It runs fine, but the application window opens in reduced size. The only code examples I can find to maximize the application window is by using the Shell command. Is there another way of maximising the application window? Many thanks Ian King Using the ShowWindow API function is one way. Paste the following into a standard module in the app to be opened: Private Declare Function ShowWindow Lib "user32"...

Most Frequently used Text value in a column
I have an Excel 2000 spreadsheet used for daily entries for any given month. Some of the columns have text values instead of numeric. It is possible that the text entries would be the same for every day or they could vary between 2 or 3 different text values. I would like to know if there is a formula that would retrieve the most frequently entered TEXT. Ex: Jan 01 cat Jan 02 dog Jan 03 cat Jan 04 dog Jan 05 dog Jan 06 dog Jan 07 cat Jan 08 dog Jan 09 bird Jan 10 cat ============= Max dog ...

I'm creating a booklet. After creating page one how do you get t.
I'm creating a booklet. After typing page one how do I get to page two??? I can't find a button or anything that tells me how to proceed. Insert | New page Or look at the status bar and click on the next page. -- JoAnn Paules MVP Microsoft [Publisher] "MOB" <MOB@discussions.microsoft.com> wrote in message news:F976CC8B-B903-4133-9A0E-E6AE5270F65F@microsoft.com... > I'm creating a booklet. After typing page one how do I get to page two??? > I > can't find a button or anything that tells me how to proceed. --- Outgoing mail is certified Vir...

programmatically initialize properties of dialog controls
VC++6.0 I have created several dialogs in Resources. My dialogs have Static Texts, Edit Boxes, Buttons. Controls have IDs, some have member variables. After searching the web it is still a mystery to me how to initialize the properties of those controls in the code? I would like in OnInitDialog() set for the controls of the dialog: font size, format (for example, real number, date), acceptable string length, set tab stops in right order. And one more thing: I need to be able not only to write a text to an Edit Box programmatically but also to add (concatenate) some text to the existing Edit ...

calling modal dialog function from external c code
Howdy all, Problem: I have a dialog based MFC app, mixed in with some external C code, and want to be able to have a C callback function interact with the dialog. Something along the lines of: void MyAppDlg::OnTest() { m_ctlStaticText.SetWindowText("hello world"); } void appCallback(int msg) { switch(msg) { case FOO: // invoke MyAppDlg::OnTest here break; } } My first attempt was to try and get at the dialog directly: case FOO: ((MyAppDlg)theApp.m_pMainWnd).OnTest(); break; The result was an...

no limits assigned but user gets an error
We do not have any limitations either on our mailboxes nor on the message transfer, but when two of our users tried to attach files they received the following error message, "The message being sent exceeds the message size established for this user." Any ideas? I checked all the Servers and we do not have any limitations set up. Is it possible that the Outlook is confusing the error messages. We have Exchange 2003 in the background and Outlook 2000 for client. Thank you. "=?Utf-8?B?aCBncmVnb3JpYW4=?=" <hgregorian@discussions.microsoft.com> wrote in news:...

How do I get the right click function back(on my mouse)?
I try to right click on my mouse when I need to edit a cell but nothing happened. Can anyone tells me how to get that function back. I have been use this function forever but just lost it two days ago. Right-click on a cell should bring a menu, not put you into Edit Mode. What do you mean by "Edit a cell"? Where are you right-clicking? Did you mean to say "double-click" on a cell does not put you into Edit Mode? Maybe you unchecked "Edit directly in cell" in Excel Options? Gord Dibben MS Excel MVP On Wed, 3 Mar 2010 12:02:04 -0800, ...

How to get Last modified date of MPP files
Hi, I want to filter out all the project which has been not modified by since a date.how will I get the lost modified date of a Project ? Out of the box this isn't available, but could easily be done with some VBA and an Enterprise custom field. -- Regards, Ben. http://www.applepark.co.uk http://appleparkltd.spaces.live.com/ "GP" wrote: > Hi, > I want to filter out all the project which has been not modified by since a > date.how will I get the lost modified date of a Project ? On project server you could include the last published field. Buil...

Getting Outlook Express 7 but not Internet Explorer 7
Because I need to test my websites with Internet Explorer 6.0, since it will probably be around long enough that it is important to make sure sites work on it, I have installed the utilities that prevent Automatic Updates from automatically installing IE7 but still allow you to get all the other automatic updates. However, because I do not develop tools/accessories for Outlook Express, I do want to have the latest version of that. Is there any way to unblock updates to Outlook Express without unblocking IE7? When I have time, I will be looking at a free version of Microsoft Virtual PC t...

special size label
hi- i have an package of avery 3261R labels i want to use- this label is not listed and there are none in the list that match the size. how can i program to use these labels? thanks! You just set up a custom size and then change the number down and across to fit your page. You may find it helpful to look under menu HELP for assistance for your version of Publisher. -- The US should free all those illegally held prisoners they are torturing, abusing and denying human rights being held at Guantanamo Bay. i don't see a place for custom size?? Select the closest size label to what you ...

about the size limitation on the frame
I use vc6 with sp5 to create a Doc/View project . I split the window into two parts.I don't let user to drag the window to small without limit. How do I set the minimal size about the main window,left pane and right pane? Thanks. Regards, Miken _____________________________________________________ http://www.msale.net/bbs/ a Chinese-language message board for developers,including palm,ppc,symbian,and etc. http://www.zirong.net/blog/ my private life Miken wrote: > I use vc6 with sp5 to create a Doc/View project . > I split the window into two parts.I don't let user to dra...

Displaced text MS Publisher2002
When overlapping one text box with another -in 2003- the text in one of them is displaced. Moving one or the other to the back appears to have no effect. Ctrl T, which works when placing text over a picture, doesn't however work with text over text. I'm almost certain that this operation could be carried out in earlier versions of MS Publisher Where am I going wrong? After managing to set up OE-QuoteFix on his new PC, Ed reads a message from Serendipity <pill@blueyonder.co.uk>... > When overlapping one text box with another -in 2003- > the text in one of them is disp...

Getting the Information out of the program
Is there a way to get all the information out of the item database and into a spreadsheet? I am trying to create a item catalog for some of our customers and instead of re-entering all the information that we have spent weeks and weeks putting into RMS, there has to be a way to get that out easily. Thanks for all your help There are so many ways you can get the information out of the database. Below are a few. 1. Run a report and click the Export button on the top of the report page, choose File and CSV Comma Delimited.**Easiest 2. Run a SQL Query from SO Admin and export from the Fil...

Must edit (F2) and {enter} to get formula to calculate. Need better way.
I have an excel worksheet that adds two other worksheets in a data triangle. I copied it to create a new data set and used find & replace to change the worksheet references to the new ones. The cells still contain the result of the old formula referring to the previous worksheets. The only way I can get the formula to return the correct result is to edit (F2) each cell and press enter. Calc now (F9) does nothing. I've seen this before, but this time, I need to calculate many thousands of cells and don't have time for this workaround. Any ideas? Thanks. Don S On Tue, 25 Oct...

User deleted Anonymous permission for calendar...how to get back?
I've searched and searched and cannot find any way to Add the Anoynmous permission back to their calendar. Any pointers would be greatly appreciated. TIA Download PFDAVAdmin and then run it and go to the User, Top of Information Store. Right-click Top of Information Store and choose Propagate Folder ACE's. Make sure to choose Add/Replace as the option. This will re-add Default and Anonymous to the Calendar and the other folders. PFDAVAdmin can be found at http://www.microsoft.com/downloads/details.aspx?FamilyID=635be792-d8ad-49e3-ada4-e2422c0ab424&DisplayLang=en -- Ben...

Permanently changing font size of incoming message
My boss has a vision problem and needs to have the font enlarged on all incoming messages. We just switched from Novell GroupWise, which allowed her to do this. Is there a way to do this in Outlook 2007? There are several methods to deal with that. See; http://www.msoutlook.info/question/67 -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outlook.com/ Outlook FAQ, HowTo, Downloads, Add-Ins and more http://www.msoutlook.info/ Real World Questions, Real World Answers ----- "Geege" <Geege@discussions.microsoft.com> wrote in ...

Digits in text cannot format as Numbers ?
Hi, I receive a weekly report from our IT and the digits (in general format and align to the left though ) cannot be changed to ordinary numbers so that I can sort them in A-Z. When I highlight the whole digit column and format it to Numbers,nothing change. I am running Office 2000 and OS XP Pro. I once saw the latest Office 2003 having a feature to convert such digits to Numbers without any problem. Anyone has a solution or workaround ? Thanks Regards ST -- st24961 ------------------------------------------------------------------------ st24961's Profile: http://www.excelforum.com/m...