|
I have gotten much further in my quest to print from a Dialog based app. The following code enables me to determine the height of the font I have selected. When I print text then move down by the height of the font the second line prints over the top of the lower part of lowercase charactersie. the dangly bit of the g.
LOGFONT* pLogFont = new LOGFONT;
pLogFont->lfHeight = -MulDiv (lfFontSize, dc.GetDeviceCaps (LOGPIXELSY), 72);
How can I determine the height including dangly bits of a given font.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Use positive lfHeight. This will instruct font mapper to interpret this value as 'cell height'. Cell height should include 'dangling bits' (called external leading in fontalese).
You'll find more details in Platform SDK LOGFONT docs.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz to the rescue yet again.
I actually tried this this afternoon as I couldn't see a good reason to have pFontLog->lfHeight as a negative value. As you mentioned the whole character was displayed but at a reduced size.
I printed some text out in Verdana 16 Bold and Verdana 10 Normal. When pFontLog->lfHeight was negative the printed size was the same as from Word 2000. When it was positive the size was considerably smaller.
Is this how it should be? Will I find the answers when I look into the LOGFONT documentation more fully. (I have look fairly extensively at this doco and it hasn't clicked yet).
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Michael,
The code sample I sent before prints out multiple lines without overlapping of ascenders or descenders. Let me have a look at your code and I'll see what I can do to help.
Derek - Salamander Software Ltd.
|
|
|
|
|
When it was positive the size was considerably smaller. Is this how it should be?
Yes. Assume that you pass +20 as height, device and logical units are identical for simplicity. This will be the height of the character cell - actual letters have to be smaller to fit into 20 pixels.
Pass -20. Font mapper uses absolute value (20) as character height. Character height is only part of the character cell, so actual character cell is higher than 20 pix, say 24. Letters are larger when displayed/printed.
Word and other apps use MulDiv trick to get 'point size'. To make lines spaced correctly, you should call GetTextMetrics after selecting the font. Add tmHeight and tmExternalLeading to get the vertical space for single line of text.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
Is there any macro or some thing to avoid memory leak.I am finding problems with linked lists.
I have 10-12 lists and these are causing(actually my code )during relase.
It not only crashes the program but also the OS.
How to check where exactly is the problem without crashing the program and eventually windows itself.
thanks
|
|
|
|
|
Try using debugger walking your code step by step.
You could also try using BoundsChecker program to catch memory leaks.
Miroslav Rajcic
|
|
|
|
|
Use _CrtDumpMemoryLeaks().
These leaks can be seen in after using the debugger and exiting the
program(Your exit, not stopping the dbgr).
Then follow the addresses.
#include <crtdbg.h>
Joy...
--Bar Cochva--
|
|
|
|
|
Hello there,
Someone please tell me which are the minimal places in the registry where I should add an ODBC entry.
It would help if someone tells the minimal entries too.
Thanx
|
|
|
|
|
use SQLConfigureDataSource(...)
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
can someone please help me with this piece of code. i was at work and bored so i started writing this. It should generate 9999 random numbers and count how many times it was 5 (according to me anyways). i'm really confused because i've programmed some heavy stuff already in MFC and i just dont get this. The problem is that v turns out to be 75536 every time i run it...
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
int main(int argc, char *argv[])
{
srand((unsigned)time(NULL));
int i;
int v;
for (i=0;i<=9999;i++)
{
int a = rand()%(9-0);
cout << a;
if(a=5)
{
v = v+1;
}
}
cout << "\n";
cout << "\n";
cout << "The number of times 5 was generated:";
cout << v;
cout << " / 9999\n";
getch();
return 0;
}
Thankya
Kuni
|
|
|
|
|
ok the includes are:
stdio.h
iostream.h
conio.h
stdlib.h
time.h
(yes there was one include too many :p)
kuni
|
|
|
|
|
ok the includes are:
stdio.h
iostream.h
conio.h
stdlib.h
time.h
(yes there was one include too many :p)
kuni
|
|
|
|
|
if (a=5)
Shouldn't that be if (a==5) ?
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
no i tried that before, it gives something even more odd, v becomes negative....
kuni
|
|
|
|
|
Perhaps you should initialize v variable at the start of the program
int v = 0;
Miroslav Rajcic
http://www.spacetide.com
|
|
|
|
|
lol i just figured that out thx anyways
|
|
|
|
|
Also, you never initialize v to be 0 -- probably explains why v is always 75536.
|
|
|
|
|
|
Can someone give me some tips on programming the systems control panels in code. Specifically the display control panel.
Thanks.
|
|
|
|
|
use the platform SDK version
|
|
|
|
|
I'm creating a program from which the user pick an item from a dropdown combo box then depend on what it is, display a short description in a text edit field, how can this be done? I'm pretty familar with the variables and classes and stuff, just need a way to do this... Please help.
|
|
|
|
|
You need to use the CCombobox::GetItemData() method.
But you first need to add the strings in the ComboBox and Set the Itemdata of each string. For this you have the CComboBox::SetItemData.
When the user pick in the combox you can get the ItemData and with this value you can search for a associated string with that value.
Good Luck!!!!
Carlos Antollini.
|
|
|
|
|
I'm trying to use the function AVISave, which takes as a parameter a callback function:
AVISAVECALLBACK lpfnCallback
with the prototype:
LONG PASCAL SaveCallback(int nPercent)
When it comes to passing a function to another function, we leave the realm of any C++ that I understand. How do I call AVISave? And, where does the "Pascal" come from?
thanks,
Jake
|
|
|
|
|
I don't know the prototype for AVISave, but this is the general idea:
LONG PASCAL SaveCallback(int nPercent)
{
UpdateProgress(nPercent);
}
void SaveAVIFile()
{
AVISave(SaveCallback, );
}
So really, in essence, you just treat the function as a variable.
Hope that helps,
> Andrew.
|
|
|
|