|
I'm experiencing an odd behaviour with GetTextMetrics() (used sooo many times).
I've created two fonts with CreateFont.
Select the first font in the device context (PDFWriter printer device context) and do a TextOut().
To increase the y, I call GetTextMetrics() to read the tmHeight and tmExternalLeading values but the program hangs on GetTextMetrics().
If TextOut is not called, GetTextMetrics works.
I'm using VC++ 6.0.
|
|
|
|
|
Nyarlatotep wrote: 've created two fonts with CreateFont.
Select the first font in the device context (PDFWriter printer device context) and do a TextOut().
To increase the y, I call GetTextMetrics() to read the tmHeight and tmExternalLeading values but the program hangs on GetTextMetrics().
If TextOut is not called, GetTextMetrics works.
You may need to select the font again so that the device context gets new tmHeight and tmExternalLeading values that you updated.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
uhm. the code is like this ...
SelectObject(hfont1);
GetTextMetrics(hdc,tm1); // it works
TextOut(hdc, ....);
y += tm1.tmHeight + tm1.tmExternalLeading;
SelectObject(hfont2);
GetTextMetrics(hdc,tm2); // it hangs the program
if TextOut() is not called, the second GetTextMetrics() does not hang.
The only solution i've found is to retrieve all the text metrics before doing any TextOut()
SelectObject(hfont1);
GetTextMetrics(hdc,tm1);
SelectObject(hfont2);
GetTextMetrics(hdc,tm2);
SelectObject(hfont1);
TextOut(hdc, ....);
y += tm1.tmHeight + tm1.tmExternalLeading;
...
...
-- modified at 5:44 Tuesday 13th June, 2006
|
|
|
|
|
Nyarlatotep wrote: SelectObject(hfont1);
GetTextMetrics(hdc,tm1);
SelectObject(hfont2);
GetTextMetrics(hdc,tm2);
I have tested that when you create the font and retrive the external leading it returns '0' mostly.
why you don't try using the tmHeight parameter of the CreateFont when tmExternalLeading is 0 without making call for GetTextMetrics repeatlly.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
I could. But GetTextMetrics() is called only at the beginning of the code and not every time TextOut is called.
The question is why GetTextMetrics hangs. Never happened before !!!
|
|
|
|
|
Nyarlatotep wrote: The question is why GetTextMetrics hangs. Never happened before !!!
This may due to following.
-You have taken the device context of the printer where lots of jobs may pending
-When you get the device context of printer and textout the text the device context is in use while jobs may pending or your process is not scheduled.
-and you are trying to get/set the information of the device context which may denied as exclusive access to device context
Hope you got the issue.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
please try the following code:
---------------------------------------
hOldFont = SelectObject(hfont1);<br />
GetTextMetrics(hdc,tm1);<br />
TextOut(hdc, ....);<br />
y += tm1.tmHeight + tm1.tmExternalLeading;<br />
<br />
SelectObject(hdc, hOldFont);<br />
DeleteObject(hfont1);<br />
<br />
hOldFont = SelectObject(hfont2);<br />
GetTextMetrics(hdc,tm2);
---------------------------------------
|
|
|
|
|
Selecting the old font and destroyng hfont1 works.
But in this way i've to re-create hfont1 each time (i use it in many places along with hfont2).
|
|
|
|
|
Hello,All
I have a application by Win32.I want to package it.
Please help me .
Thanks ...
|
|
|
|
|
Use NSIS installer for packaging it..you just have to write a simple script for that.
You can download the nsis installer from here[^]
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Package as in make an installer? The good free ones should be Inno Setup and NSIS.
|
|
|
|
|
Tran Ngoc Minh wrote: I have a application by Win32.I want to package it.
Please help me .
Use setup and deployment projects wizard of the VS2003
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hope I understood your question
one way that you dont need to any software you can use from IExpress.exe in XP from start menu and in window Run enter IExpress.exe now you can see a window Welcome
whitesky
|
|
|
|
|
Hi all,
My question is here :
To create a console application with the Class Hierarchy for the below XML Structure.
<Employees>
<Employee>
<name>Malar</name>
<designation>SE</designation>
<reportingTo>
<Employee>
<name>Prakash</name>
<designation>PL</designation>
</Employee>
</reportingTo>
</Employee>
</Employees>
//******************
I have to write a C++ program to add, modify, delete type application.
This application should append, delete, or modify the XML file.
I think each tag should be represented as seperate class since we have append the XML as tags
Advance thanks for the one who will help to solve the problem,
Regards,
Karthik M
Karthik M
|
|
|
|
|
karthikoncodeproject wrote: I think each tag should be represented as seperate class since we have append the XML as tags
This is not a good idea: imagine, you want to add a new tag. Then you have to create another class... Not very practical.
Take a look at tinyXML[^], it's a quite powerfull library.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
See IXMLDOM* interfaces which provides what you want.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Thanks for your valid suggestions.
But i have to write a C++ code manually for an assignment.
Kindly design a class for the above mentioned XML hierarchy.
Regards,
Karthik M
Karthik M
|
|
|
|
|
Hi,
Can someone explain why this code crashes (when calling ReleaseBuffer()) ?
<br />
#define PROFILE CString("config.ini");<br />
CString result;<br />
GetPrivateProfileString("MySection","MyString","",result.GetBuffer(),512,PROFILE);<br />
result.ReleaseBuffer();<br />
And how can I avoid this ?
|
|
|
|
|
I think you should specify the size of the allocated buffer:
GetPrivateProfileString("MySection", "MyString", "", result.GetBuffer(512), 512, PROFILE);
|
|
|
|
|
Hi
Please remove ';' in define line
KK
|
|
|
|
|
My guess is the crash is due to writing past the allocated buffer memory that the CString has. Debug builds have some checks to see if you make this mistake. Get the CString to return a buffer that has a certain minimum size.
<br />
#define PROFILE CString("config.ini");<br />
CString result;<br />
GetPrivateProfileString("MySection","MyString","",result.GetBuffer(512),512,PROFILE);<br />
result.ReleaseBuffer();<br />
|
|
|
|
|
Tnarol wrote:
GetPrivateProfileString("MySection","MyString","",result.GetBuffer(),512,PROFILE);
Result of the string where you get the data from ini file, it should be LPTSTR buffer, specify the size of that buffer instead of 512.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Try this:
#define PROFILE "config.ini";
CString result(_T(" "),512);
GetPrivateProfileString("MySection","MyString","",result.GetBuffer(),512,PROFILE);
result.ReleaseBuffer();
May be you are trying to release some memory not allocated.
|
|
|
|
|
For GetBuffer method :
Call this method to return the buffer contents of the CSimpleStringT object.
You are having this string empty.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|