|
I have a CEdit control and I would like to be able to zoom the text by a floating factor (i.e 0.75 or 1.25 for 80% or 100% zoom). I manage to resize the box to shrink or expand depending on the factor. However, I cannot get a scaled text. I tried the following code
<br />
XFORM xForm;<br />
<br />
xForm.eM11 = xForm.eM22 = (FLOAT)m_rZoomingFactor;<br />
xForm.eM12 = xForm.eM21 = xForm.eDx = xForm.eDy = (FLOAT)0.0;<br />
<br />
HDC hDC = this->GetWindowDC()->GetSafeHdc();<br />
<br />
SetGraphicsMode(hDC, GM_ADVANCED);<br />
<br />
ModifyWorldTransform( hDC, &xForm, MWT_LEFTMULTIPLY );<br />
either by calling it directly or by placing it inside the OnPaint message handler but I get no change.
I also thought that I may need to change the existing font. However, I looked to CFont class and to LOGFONT structure and I haven't seen a simple way to get a font which is a zoomed version of the current font.
How can I zoom a text in a CEdit control? Can I do it but somehow scaling the device context or should I change the font? How do I get a scaled version of the current font?
Note that this change may happen on fly. I 'd like to be able whilst the user is editing the text to zoom in and out. Resizing the box is not a problem but zooming the text is.
|
|
|
|
|
Dimitris Vikeloudas wrote: I haven't seen a simple way to get a font which is a zoomed version of the current font.
If you can obtain the LOGFONT structure of the font that the CEdit control uses, the create a font that has an increased point size by your zoom factor, then do a set font call on the CEdit control and then invalidate the window to get it repainted. You will also have to delete the font you created, otherwise it will leak.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
I can obtain the LOGFONT and I know how to handle the font that I 've created. My problem with the LOGFONT (and the CFont class) is that having the structure I do know in which fields should my zooming factor applied (I assume multiplied) to get a bigger or smaller font aesthetically pleasing. Any help on that please?
I thought that another way doing that could be applying a transformation to the device context of the CEdit window (maybe using the ModifyWorldTransform to scale it?) but it does not seems to affect the text in a CEdit. Is it possible to scale a CEdit window??
|
|
|
|
|
The first field of the LOGFONT structure is height. Increase this using your zoom factor and set the second field, the width, to NULL. The call to CreateFont will calculate an appropriate width, I believe.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
In my endless search for memory leaks, I've started to second-guess some things I once thought to be true. I just want to confirm something about CString here, to be certain:
Let's say I have code like this:
std::string displayStr;
displayStr = "Hello";
CString tmp(displayStr.c_str());
Do I need to free any memory here? I'm worried that perhaps in that particular usage of the CString constructor, heap memory is allocated, so I just want to make sure it isn't.
Kelly Ryan
|
|
|
|
|
When tmp goes out of scope, memory will be freed.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
How do I take each character from an array, convert it into its ascii and store the values into another array? Someone please respond. Thanks.
samita_friendly
|
|
|
|
|
a char already contains the ascii value...
char c = 'd';
int i = c;
|
|
|
|
|
But, I have an array of about 100 characters in it. How do I convert all of them into ascii?
|
|
|
|
|
One at a time. What's the problem?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
An array of characters already contains the ascii values of those characters, no conversion is necessary. If you want to copy them to another array, just loop through.
Kelly Ryan
|
|
|
|
|
If my array a[] has three characters A,B,C. If I print the array it is giving just the characters. I want 65,66,67.
|
|
|
|
|
Just print them as integers.
printf("%d %d %d", (int)a[0], (int)a[1], (int)a[2]);
Kelly Ryan
|
|
|
|
|
no need to cast into (int)
|
|
|
|
|
I like to avoid my old g++ UNIX compiler warnings
KR
|
|
|
|
|
then, prefer using static_cast<int>()
|
|
|
|
|
how do you print ? use %d instead of %c in printf()
|
|
|
|
|
did you understand my answer ? NO conversion actually NEEDED !!!
|
|
|
|
|
a simple for loop... utilizing the above ASCII conversion example for each iteration of the array
|
|
|
|
|
Thanks guys, I'll try them out.
|
|
|
|
|
hi all,
can we remove desktop icon programatically ?
venu
|
|
|
|
|
You already asked this question. Be patient.
|
|
|
|
|
Hey, we have money. We can pay for it.
We have to format a SD Data card from with-in a program. It has to be FAT16, and we don't want XP's format dialog box to come up.
We have been searching on several sites that sell C++ libraries, nothing exists! It looks like we will have to go raw and manually format the drive.
Thing is, this code has to have been written a hundred times. It doesn't seem like something we should have to write again.
Does anyone know of a library that can be purchased to do this?
Thanks for the responses - I love the Code Project site!
-Matt
|
|
|
|
|
YOu mean like this[^] ?
led mike
|
|
|
|