|
Probably the second time the CString objects contain the same values as for the first time. You should check if the CString data really contain information you expect before writting to file.
|
|
|
|
|
Do you have error checking in place?
CString str;
CFile pFile;
CFileException ex;
char szError[255];
if( !pFile.Open(szFile, CFile::modeCreate|CFile::modeWrite, &ex) )
{
ex.GetErrorMessage(szError, 255, NULL);
AfxMessageBox("File Error: " + szError, MB_OK|MB_ICONERROR);
return;
}
if( !str.IsEmpty() )
{
pFile.Write((LPCTSTR)str, str.GetLength());
}
pFile.Close();
HTH
Mark
|
|
|
|
|
I have a truetype font file, named "LSANSI.TTF" but which if i open is shown as Lucida Sans Italic and windows also displays it correctly as Lucida Sans Italic instead of showing it as LSANSI.TTF
How do I get this "Lucida Sans Italic" information from the font file? Is there any api call like GetFontName() or anything similar?
Regards,
padma gahlot
|
|
|
|
|
padma_01 wrote: How do I get this "Lucida Sans Italic" information from the font file? Is there any api call like GetFontName() or anything similar?
-Use CreateFontIndirect method to create with facename "Lucida Sans Italic"
-Select the font into device context
-Use GetTextMetrices method to get the current text Metric
-The structure contains information about your selected font.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
A_Laxman wrote: -Use CreateFontIndirect method to create with facename "Lucida Sans Italic"
But what if you used "My Favorite Font" instead? Would GetTextMetric() still report the font as "Lucida Sans Italic" or would it be "My Favorite Font" instead?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: But what if you used "My Favorite Font" instead? Would GetTextMetric() still report the font as "Lucida Sans Italic" or would it be "My Favorite Font" instead?
Here is the sample given only for the specific problem and BTW if you are unable to trace that one then
Pick your bag and go to school..;P
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
A_Laxman wrote: Here...
Where?
What part of the TEXTMETRIC structure do you propose the font's facename come from?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
It is used to get information of the known font only.
You have to specify the font face name to get information of the font.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
A_Laxman wrote: You have to specify the font face name...
Which is the information that the OP was looking for.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
padma_01 wrote: Is there any api call like GetFontName() or anything similar?
Use GetTextFace() .
If, however, you don't actually need/want to "load" the font, use EnumFontFamiliesEx() .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I need to purchase a visual studio for my project/study. but heard from microsoft product vender that, there is only visual studio 2005 now....
does visual studio 2005 support earlier vc++6.0 MFC projects?
|
|
|
|
|
Visual Studio 2005 supports VC++ 6.0 MFC. But once you convert to Visual studio 2005 version you cannot run it again VC++ 6.0.
Visual Studion 2005 does not provide that backward compatibility.
Karthik M
|
|
|
|
|
zeus_master wrote: heard from microsoft product vender that, there is only visual studio 2005...
...that can be purchased from him/her. You can always find a copy of VC++ v6 from other resources.
zeus_master wrote: does visual studio 2005 support earlier vc++6.0 MFC projects?
Opening a VC++ v6 project with VS 2005 will cause it to be converted. Is that what you meant?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'v download a the visual studio 2005 express editions from microsoft homepage.but there seems no MFC resource.
Opening a VC++ v6 project with VS 2005 cause it to be converted. while build the project in vs2005, the error occurs.
information is all of the follow files cann't be found. and the MFC resources cann't be found.
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
I found on microsoft homepage that vs 2005 express editions doesn't support MFC. but I want to know the other Version such as VS 2005 standard edition and vs 2005 professional edition can support MFC?
|
|
|
|
|
zeus_master wrote: but I want to know the other Version such as VS 2005 standard edition and vs 2005 professional edition can support MFC?
Yes.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
how to call or integrate DLL within vc++ application.
I have developed one vc++ application now i want to integrate one tool into this application which ll cal this DLL.
reply soon
thanx
FutureSE
|
|
|
|
|
You can:
1) Load programmatically the DLL using LoadLibrary(). In this case you have to load the functions entry points the dll exports via GetProcAddr()
2) Usually DLLs come with a LIB file. Include the LIB file into your project. The functions exported by the DLL are now available.
3)Use the delay loading feature with the /delayload:dllname linker switch
|
|
|
|
|
Use CoCreateInstance()
You should know how to invoke a COM and work with COM objects.This applies when you have the class id of the interface.
else
You can also use LoadLibrary() alongwith GetProcAddress() to invoke the functions
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 6:18 Tuesday 13th June, 2006
|
|
|
|
|
FutureSE wrote: how to call or integrate DLL within vc++ application.
I have developed one vc++ application now i want to integrate one tool into this application which ll cal this DLL.
reply soon
Try GetModuleHandle which returns the handle of your DLL through which you can get the addresses of the method using GetProcAddress..
The GetProcAddress Fails when the method is Mangled (in case of C++ Dll).
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
ok i ll try tht n get back to u
FutureSE
WhiteHawk
|
|
|
|
|
Good luck.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
in project setting , under link tab give reference to the .lib file, give its path.
in your program add the header file..
header file should have
__declspec (dllimport) <funname classname="">
not
__declspec (dllexport) <funname classname="">
go get going.
|
|
|
|
|
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
|
|
|
|