|
I try to measure the dimension for a text say "Hello".
I set mapping mode to MM_LOENGLISH.
CFont font;
font.CreatePointFont(360,"Verdana");
pDC->SelectObject(&font);
CSize sz = pDC->GetTextExtent("Hello");
the width sz.cx (1.19 inch) seems ok in real printing. But sz.cy (0.57inch) is greater than the actual (0.344inch) in printout. Can anyone tell me how to calculate the real height???
|
|
|
|
|
I believe that when windows calculates the height of characters it includes the height of the ascending and descending line of the font, not just the height of the character that you see. I am not 100% certain of this, but one way that you could test this is by calling getTextExtent on 5 different characters, and I believe the same height should come back for all of the characters.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
look up the font metrics stuff in msdn
there are all sorts of bits and pieces added together to get the bounding 'box' of text ... leading, ascenders, descenders, etc
all fun stuff if you have nothing else to do
---
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
|
|
|
|
|
Hello all -
I don't know if this is a limitation of the library or if it's just my computer. I can make 16 sucessfull calls to this function, and i get back a valid timer id, and the callback function i specify is called. After the 16th, it fails.
I should be clearer...i can Queue up 16 of them. if i try to call this 17 times before the 1st callback is fired, the 17th call fails. Anyone know if this is a limitation of the library - or just my computer?
Marcus Spitzmiller
"Ha ha, Stupid bloropope.." - Homer
|
|
|
|
|
This has been spammed here before, and the general consensus was that not only was this not a terribly compelling app, but it's offensive that you post your ads in the forums when there is a facility provided for people to buy advertising on the site if they want it.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
CRichEditCtrl wants me to set the fontsize in twips, whatever that is. How can I set the font to something like Verdana 9.
Sprudling
|
|
|
|
|
|
Thanks, this was exactly what I wanted
Sprudling
|
|
|
|
|
CFont font;
font.CreatePointFont(90,"Verdana");
richctrl.SetFont(&font);
|
|
|
|
|
1440 twips = 1 inch
hmmmm ... wonder why guys don't use the twip measuring system more often?
---
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
|
|
|
|
|
I want the text in a CRichEditCtrl to appear as in a console, with the "latest" line at the bottom and all text bottomaligned, so that if there is just one line it'll be alone at the bottom. Is there a way of implementing this...?
Sprudling
|
|
|
|
|
You can use CRichEditCtrl::SetRect(). Apply the number of lines, the font height and some math.
|
|
|
|
|
Or might want to try CRichEditCtrl::SetParaFormat
|
|
|
|
|
How could CRichEditCtrl::SetParaFormat help me?
Sprudling
|
|
|
|
|
Thanks; how to calculate a font's height?
And what if I've turned on wrapping (no horizontal scoll). Will that count as a new line or not? (When returned from CRichEditCtrl::GetLineCount())
Sprudling
|
|
|
|
|
The height can be calculated using CDC::GetTextExtent(). As for the wrapping, I have no clue You will have to try it.
|
|
|
|
|
Niklas Lindquist wrote:
The height can be calculated using CDC::GetTextExtent().
or rather use the lfHeight member of the LOGFONT structure. Can be retreived from CFont::GetLogFont() I think.
|
|
|
|
|
Hi,
I insert a resource script into my Win32 Application and create a menu named "menu01", when run the project, no menu appear but an empty window.
What's wrong?
By the way, I want know how to add color and format my codes for better readability.
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
NicholasCougar wrote:
I insert a resource script into my Win32 Application and create a menu named "menu01", when run the project, no menu appear but an empty window.
What's wrong?
If I am not mistaken, you cannot add a menu to the console window through regular application means. It is mainly for stdout and stdin. If you want menus and things like that why don't you create a WIN32 application with the user interface elements. It is also possible to redirect stdout and stdin windows components if this is what you need.
NicholasCougar wrote:
By the way, I want know how to add color and format my codes for better readability.
I am unclear what you are asking here. Do you want your source code in the editor to be syntax highlighted, or the codes in your program window? What editor are you using for your code?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Please have a look at your post, it's very neaty and readable, for you use small font, hightlight, and italic. In the message box where I currently typing words in, no such this like small font, italic etc. I want use them in my post here for better readability.
Thank you.
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
Use HTML tags when typing your post. Note, not all tags are recognized. Plus, you can use special tags like <pre></pre> to display source code, like this:
int nFoo = 43; /ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
hey, im using boost::RegEx to do regular expression stuff
im trying to get a string like "word...!" to work with the regular expression "\w+", but not include the "...!" in the match... whenenver i try this using
boost::RegEx re("\\w+");
bool b = re.Match("word...!");
it returns false.... how do i get it to return true, but it should tell me where the regex was completed (at the position of the first dot, or character index 4) or the position of the last character part of the match (the 'd')
thanks for the help guys
- Roman -
|
|
|
|
|
Dunno if this will help.. but in PCRE you could do like...
Pcre re("^([^\.]+)");
if (re.search("word...!") == true) {
cout << re.get_match(0) << endl;
}
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
well, that kinda helps, but im really looking for a type of thing that will allow me to pump tokens using a regular expression... e.g.:
"int main();"
i want tokens: "int", <space>, "main", (, ), and ;
and using regular expressions to parse each token. the point is, i dont want to have to handle each case, i just need it to parse the string until at some point it doesn't match the regular expression anymore... then that's the beginning of a new token
- Roman -
|
|
|
|
|
I've done something like this to parse lines inbetween \r\n ...
Pcre regex("^[\r\n]*([^\r\n]+)[\r\n]+(.*)$", "s");
while (regex.search(data) == true) {
data = regex.get_match(1);
}
I am sorry if this doesn't help you.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|