|
Thanks again for your patience.
I checked each of the TEXTMETRIC members and didn't see the answer.
tmHeight is the font size and tmOverhang is the extra width if I use Italic or Bold which I use none of them.
Still, If I choose "Ariel" with the size X and "Comic Sans MS" with the same size, the display font height are different. In addition, Using the same font, the letter 'a' and the letter 'b' have a different height. Therefore to know the real height of a specific font, the query method needs to the recieve the specific text in addition to the HDC. I am not sure there is such a method and I will be satisfied with known the difference between fonts
please advise
Thanks in advance, Udi Raz
|
|
|
|
|
I hope you don't mind me sneaking in here. I have the same problem with showing numbers in CEdit controls. How to find the TRUE pixel width of the text? I need to know how many digits can be shown in the control so that I can put in as many as possible, and round the number correctly.
It is easy enough to use DrawText() with the DT_CALCRECT flag, making sure that SetFont is done correctly, and for small font sizes the code works well. But as the fonts get bigger, DrawText's calculations just do not agree with those of CEdit.
I'm stumped too, and have temporarily had to restrict the font face and size, and apply magic numbers to get the stuff to work.
Shraddhan
|
|
|
|
|
Hi Shraddhan,
I get the filling that there is no way to get the real height, but as regarding the width, although I can't help you right now, I think in one of my attempts I got the real width using one of the following methods GetTextMetrics(), GetTextExtentPoint32(). It depands whether you are using a raster font or a open type/true type font.
I think that is works for me, but don't remember how. I still trying to find the real height...
Udi Raz
|
|
|
|
|
I couldn't find information on GetTextExtentPoint32.
GetTextMetrics returns a TEXTMETRIC structure that gives average and maximum character width, which are no good for my purposes.
Under GetTextExtent and GetOutputTextExtent, Microsoft notes:
Since some devices do not place characters in regular cell arrays (that is, they carry out kerning), the sum of the extents of the characters in a string may not be equal to the extent of the string.
So clearly ambiguous!
My notes on my problem with fitting strings into CEdit controls mention that the text is shown with white space on either side. In fact, with large font sizes. the output is chopped on the right if it gets anywhere near the edge of the edit box. But I have no idea what the whitespace allowance should be. It depends on the face as well as the size.
So is this a feature of CEdit controls?
As for finding the overall height, one last ditch method occurred to me: draw the text to a bitmap and measure the height of the drawn area by scanning the pixels. Don't ask me how, though.
Shraddhan
|
|
|
|
|
Thanks, I know how ( by using DC::Getpixel() ) but will not take a reasonable time...
|
|
|
|
|
Last weekend I discovered the new features of VC 2005. One of them is very interesting for me: the new compiler flag /arch:[SSE|SSE2]. Currently I have to be able to deactivate the parts of my code I have optimized with SSE/SSE2. So I use precompiler statements to switch between SSE/SSE2 and ordinary C++. This means that I have to write a lot of code twice. The new compiler flag would reduce the time I spend to optimize my code considerably.
Unfortunately the documentation of the discussed compiler flag is not very large and it does not say how to find out which parts of the code were optimized by the compiler or even how to write C++ code to help the compiler with optimizing. I did not found much on the web about this topic so I would be happy if you could send me your experiences with this new compiler flags or a link to an expressive description on the web.
Thank you in advance.
Philipp Grohs
-- modified at 13:25 Monday 16th January, 2006
|
|
|
|
|
hiii i'm making a Calculator in Visual C++ but having sum probs, in code i've created all the buttons n now i don't know how to add two numbers wich are pressed on buttons.. Can neone help me out..
Paritosh Tripathi
B.Tech. (C.S.)
|
|
|
|
|
Take a look at CP, I think you can find some example calculators.
But it is not a trivial problem. You have to keep track of the states that you are in. Look at the book "Practical Statecharts in C/C++" by Miro Samek for a description of how to create a robust solution.
But if all that you are looking for is adding two numbers (i.e. no other functionality for this program) your states can be trivial. If you only have the digits 0-9 and a + and =, I think you can get by doing the following:
For each number pressed: Add that digit to the display field
For +: store the integer in the display and prepare to clear the display when the next number is pressed.
For =: get the number currently displayed and ADD it to the stored number.
Draw a state diagram to make sure you cover various cases, such as pressing 1010 + = : this should have the effect of 1010 + 1010 = 2020.
+ 1010 = : this should have the effect of 0 + 1010 = 1010
And what about 1010 + + = : 1010 + 1010 + 1010 = 3030
The book I mention covers a calculator example and should be very helpful in general for learning how to handle statemachines.
|
|
|
|
|
hi techno,
ok, lets sum up.
there are many ways to make a calculator, that i think my VisualCalc is not exactly what you are designing, am i wrong ?
you're having buttons on the GUI, so, i think you have to store the result in a member each time it is recalculated.
as you seem very beginner, i'll consider you're calculation engine class is written within the UI dialogBox class (still wrong with this ? )
- so, add a member in the class to store the result (lets say float m_fResult; )
- then, when you press an operation button (like '+' ) you have to store somewhere that it is an addition to be performed (design an type which enumerated the possible operations, and make a member of that type (say m_Operation ) in your class which will store the operation to perform (here, ADDITION).
- then, the user types its number, and when then equal button is pressed ('=' ), you test the m_Operation variable.
if m_Operation == ADDITION Then
Add m_Result + lastly typed value
store the new value into m_Result
End If
any more help ?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
...hello every body,
well the night calmed me down, and all your answers were nice enough.
so, not only i decided do delete the outrageous post, but i too wanted to say this here.
i'm very sorry if some of you didn't understand my reaction. i had to say this, because i was very angry because of thy stupid guy. that's all.
have a good day all of you (yeah, i sad ALL OF YOU, even you, yes, YOUUUU who don't like me )
|
|
|
|
|
tox, I just rated the above-mentioned post a 5, and it still says there's only 1 vote and the score is still 1.0. I don't understand the logic behind that. maybe the math behind that is messed up. But I still think you let someone get you a little too heated for that. People that have been around CP know that you've got some VERY good ideas and wouldn't vote you a 1 even if your answer did sound crazy. To the people who would, f*** them. Don't let them get their jollies by replying back to them like that. You're better than that
My articles
BlackDice
|
|
|
|
|
Hello Tox
While I appreciate why you are upset, I think you should delete your post. It contains profanity that's not fitting this forum or your public profile for that matter.
Regards,
Nish
|
|
|
|
|
Here is a 5 to help offset.
Don't be discouraged, you are helpful to a lot of people around here.
-- modified at 16:34 Monday 16th January, 2006
I agree with Nish, delete that post. It detracts from your character - even if you are justified in being upset.
|
|
|
|
|
mine too correct the Vote Offset
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Nish is correct. I did not expect this from tox. He was honored as one of the most useful members of 2005. I do not understand what is his need to come down to this level. Tox, pls delete that post. Let them vote whatever they want. We know that you have something to contribute to this society.
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
Technobizz wrote: Paritosh Tripathi
B.Tech. (C.S.)
I have heard this name before..Anyways you can look for this article
CONTROL ARRAY[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
U have already got the answer to you questions
but u should start refering some good book's
and there is lots of stuff on codeproject to help u
Vikas Amin
Embin Technology
Bombay
|
|
|
|
|
I have a project that I have different configurations which compile different libraries for different versions. Is there a way to link the Version resource to my configuration?
I basically want configuration A to ahve version 7.2, configuration B to ahve version 7.02 etc.
Any ideas? I asked this questions awhile back I think and got the correct answer, and I completely forgot how to do it.
Thanks.
-C
|
|
|
|
|
Wheatbread wrote: I basically want configuration A to ahve version 7.2, configuration B to ahve version 7.02 etc.
You can specify different libraries for different configurations in the project settings.
|
|
|
|
|
I've done that. But when I compile it, I want the DLL that I create to have different version numbers depending on the configuration selected.
|
|
|
|
|
VisualC++ IDE: ResourceView -> Version -> Properties -> Condition ?
|
|
|
|
|
What version of the IDE are you using VC 6.0? VS 200? what?
In VC 6.0, you can specify different preprocessor definitions for each configuration in the project.
Move your version resource into the RC2 header file.
Inside there, use the preprocessor identifiers to filter the file or product version resource data.
|
|
|
|
|
I prepared (in Visual Studio 2003 + MFC) "Dialog Based" Application. Now, I have one dialog window where I want to add two book marks.
I have two objects:
class DlgPage1 : public CPropertyPage
// variable mPage1
class DlgPage2 : public CPropertyPage
// variable mPage2
In the resource window I have done two dialogs with properties:
Style = child
Border = thin
TitleBar = true
Disabled = true
In the OnInitDialog (main window) function I have code:
mPropertySheet = new CPropertySheet("Simple PropertySheet");
mPage1 = new DlgPage1();
mPage2 = new DlgPage2();
mPropertySheet->AddPage(mPage1);
mPropertySheet->AddPage(mPage2);
mPropertySheet->Create(this, WS_CHILD | WS_VISIBLE, 0);
mPropertySheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT);
mPropertySheet->ModifyStyleEx(0, WS_TABSTOP);
mPropertySheet->ModifyStyleEx(0, WS_MAXIMIZE);
// now, I want to resize windows for almost maximum size
CRect rect;
GetClientRect(&rect);
int Width = rect.Width()-7;
int mHeight = rect.Height()-7;
mPropertySheet->SetWindowPos(NULL, 7, 7, mWidth, mHeight, SWP_NOZORDER);
================
The SetWindowPos doesn't do what I expect.
Why the windows doesn't resize?
It has the size - I designed in the Resource.
Regards
mwgomez/Poland
|
|
|
|
|
gomez_a wrote: It has the size - I designed in the Resource.
And this is exactely what you request by doing this:
CRect rect;
GetClientRect(&rect);
int Width = rect.Width()-7;
int mHeight = rect.Height()-7;
mPropertySheet->SetWindowPos(NULL, 7, 7, mWidth, mHeight, SWP_NOZORDER);
If you want to maximize your widows, use GetSystemMetrics to get the screen size, and use SetWindowPos to update your window size:
int cx,cy;
cx=GetSystemMetrics(SM_CXSCREEN);
cy=GetSystemMetrics(SM_CYSCREEN);
mPropertySheet->SetWindowPos(NULL, 7, 7, cx-7, cy-7, SWP_NOZORDER);
~RaGE();
|
|
|
|
|
I have the same effect like before...
Regards
mwgomez
|
|
|
|
|