|
Use EnumFontFamilies() (or EnumFontFamiliesEx() ). The ntmCharSet field in the NEWTEXTMETRIC structure passed to your callback function should do the trick
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
May you tell me detailed information? thank you.
|
|
|
|
|
Try this:
int CALLBACK FontProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, int FontType, LPARAM lParam)
{
*(BYTE*)lParam = lpntme->ntmentm.tmCharSet;
return 1;
}
BYTE GetFontCharSet(LPCTSTR lpszFont)
{
CClientDC dc(NULL);
LOGFONT lf;
lf.lfCharSet = DEFAULT_CHARSET;
_tcscpy(lf.lfFaceName, lpszFont);
lf.lfPitchAndFamily = 0;
BYTE bCharSet = DEFAULT_CHARSET;
EnumFontFamiliesEx(dc.m_hDC, &lf, (FONTENUMPROC)FontProc, &bCharSet);
return bCharSet;
} It should work, although I haven't tested it. It basically outlines what you need to do.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I am developing a project using .NET Remoting technology to achieve the talk between client and server. The shared object interface in the server is written in C# and compilered into a DLL, which will be used in the client code. So how to access the object in the C# DLL?Here are the source code:
=======IInfoMan.cs->IInfoMan.dll===========
using System;
using System.Runtime.Remoting;
namespace InfoMan
{
///
/// Summary description for IInfoMan.
///
public interface IInformationManager
{
string DataItem(int whichItem);
int DataCollectionLength();
}
}
and Here is the implementation for the interface
=======InformationManager.cs========
using System;
using System.Runtime.Remoting;
namespace InfoMan
{
///
/// Summary description for InfoManager.
///
public class InformationManager: MarshalByRefObject, IInformationManager
{
private string[] theData = new string[ARRAY_SIZE];
private const int ARRAY_SIZE = 3;
public InformationManager()
{
theData[0] = "In a village of LaMancha, ";
theData[1] = "the name of which I have to desire ";
theData[2] = "to call to mind, there lived ";
}
public string DataItem(int whichItem)
{
string theItem = null;
if(whichItem >= 0 && whichItem < ARRAY_SIZE)
{
theItem = theData[whichItem];
}
return theItem;
}
public int DataCollectionLength()
{
return ARRAY_SIZE;
}
}
}
I know that I should use #using keyword to use the C# dll in the Visual C++ code. That is #using "IInfoMan.dll" and also #using <mscorlib.dll>. But when I tried to using the following codes to connect to the server and create a instance of the remote object, I got the error message. Why?
try
{
::RemotingConfiguration::Configure(S"AioTest.exe.config");
InformationManager *m_InfoMan = new InformationManager();//Maybe this line has an error.But I don't know why.
}
catch(Exception * exp)
{
CString msg = exp->Message;
MessageBox(msg);
}
error C3828: 'InfoMan::InformationManager': placement arguments not allowed while creating instances of managed classes
Can someone help me to solve the problem? Thanks!
|
|
|
|
|
the following is my "ftp visit" program:
/////////////////////////////////////////////
//in "stdAfx.h"
#include <wininet.h>
//in CXXXApp::InitInstance()
if(InternetAttemptConnect(0)!=ERROR_SUCCESS)
AfxMessageBox("connect error");
//in application function
HINTERNET hInetSession;
HINTERNET hSecondary;
if(!(hInetSession=InternetOpen(AfxGetAppName(),INTERNET_OPEN_TYPE_PRECONFIG,
NULL,NULL,0)))
{
AfxMessageBox("InterOpen() error");
return;
}
hSecondary=InternetConnect(hInetSession,g_ipAddress,g_FTPPort,
g_account,g_password,INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
if(!FtpGetFile(hSecondary,remoteFileName,localFileName,FALSE,
FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_ASCII |
INTERNET_FLAG_NO_CACHE_WRITE,0))
{
AfxMessageBox("get ftp file error");
return;
}
////////////////////////////////////////////////////////
error will occur if i choose "using MFC in a shared DLL" in menu "project setting" and build,while no error happen if i choose "using MFC in a static library" and build,why?
the error infomation is as follows:
Bank2.obj : error LNK2001: unresolved external symbol __imp__InternetAttemptConnect@4
D160ABank.obj : error LNK2001: unresolved external symbol __imp__FtpGetFileA@28
D160ABank.obj : error LNK2001: unresolved external symbol __imp__InternetConnectA@32
D160ABank.obj : error LNK2001: unresolved external symbol __imp__InternetOpenA@20
Debug/Bank2.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
the problem is how can i build it successfully in "using MFC in a shared DLL" choice.
be friends
|
|
|
|
|
anyone can help me?
to be or not to be
|
|
|
|
|
Does anyone know of any Natural Language Processing open source for
C++?
at this point in my search, I will take any suggestions, even a link to a free VB source nah forget that. But maybe Java.
I have posted a question to Google answers, and they are trying to find me one too but no answer yet
Hopefully someone here knows of something I could use for the NLP part for Carl v2 I am working on, currently. Thanks.
Later, JoeSox www.humanaiproject.org
"Dream as if you'll live forever; live as if you'll die tomorrow."
- James Dean(ISTP)
|
|
|
|
|
I've got a strong feeling I'm missing the blindingly obvious, but here goes...
I can fire up Internet Explorer from my app and open a url of my choice with the following:
ShellExecute (NULL, "open", urlMap [bReturn].data (), NULL, NULL, SW_MAXIMIZE);
But if I already have a web page open, it is replaced by my URL. This is annoying!
What I want is to start a *new* instance of explorer with my URL. Something like:
ShellExecute (NULL, "open", urlMap [bReturn].data (), NULL, NULL, SW_MAXIMIZE | IE_START_IN_NEW_WINDOW);
Any ideas?
Iain.
|
|
|
|
|
This is controlled by an IE option - reuse existing windows for shortcuts.
I think you can run iexplore.exe -new http://blahblah but then you lose the convenience of automagically using the user's default browser.
--Mike--
"I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage."
-- Chris Maunder, relativistic system administrator
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
I don't know whether to be glad I haven't missed an easy way or not...
I've had a look for IExplore -new equivalent flags, and none are
documented. The -new doesn't work.
But I may be able to find the reg entry corresponding to the
"reuse flag" (which worked, ta), and temporarily set it to off...
Or maybe I could just leave it up to the user to turn it off
themselves...
Thanks,
Iain.
|
|
|
|
|
|
You need to fetch the browser EXE from the registry and use this when calling ShellExecute thus:
#define LINK_KEY _T("http\\shell\\open\\command")
void CLink::Open(LPCTSTR lpszURL)
{
ShellExecute(NULL, NULL, lpszURL, NULL, NULL, SW_SHOWNORMAL);
}
void CLink::OpenNew(LPCTSTR lpszURL)
{
CString strBrowser = GetBrowser();
if (strBrowser.IsEmpty())
{
Open(lpszURL);
return;
}
ShellExecute(NULL, NULL, strBrowser, lpszURL, NULL, SW_SHOWNORMAL);
}
CString CLink::GetBrowser() const
{
CString str;
HKEY hKey = NULL;
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, LINK_KEY, 0, KEY_READ, &hKey) ==
ERROR_SUCCESS)
{
DWORD cbData = 0;
if (RegQueryValueEx(hKey, NULL, NULL, NULL, NULL, &cbData) ==
ERROR_SUCCESS)
{
if (cbData > 0)
{
TCHAR* psz = new TCHAR [cbData];
if (psz != NULL)
{
if (RegQueryValueEx(hKey, NULL, NULL,
NULL, (LPBYTE)psz, &cbData) ==
ERROR_SUCCESS)
{
str = psz;
}
delete [] psz;
}
}
}
RegCloseKey(hKey);
}
if (str.GetLength())
{
int nStart = str.Find('"');
int nEnd = str.ReverseFind('"');
if (nStart >= 0 && nEnd >= 0)
{
if (nStart != nEnd)
{
str = str.Mid(nStart + 1, nEnd - nStart - 1);
}
}
else
{
int nIndex = str.ReverseFind('\\');
if (nIndex > 0)
{
int nSpace = str.Find(' ', nIndex);
if (nSpace > 0)
str = str.Left(nSpace);
}
}
}
return str;
}
When I am king, you will be first against the wall.
|
|
|
|
|
Thanks for the long answer. I have the sneaking suspicion you've used this code already?
As I said to Michael, its kind of nice not having a one line solution. That would be
a touch embarassing. I usually *answer* (some of) the questions here after all!
Iain.
|
|
|
|
|
Excellent!! Have a think about writing an article...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Yes, I think I will package up my little CLink class into an article ASAP...
When I am king, you will be first against the wall.
|
|
|
|
|
Robert Edward Caldecott wrote:
Yes, I think I will package up my little CLink class into an article ASAP...
It would make a pretty good article. Very, very handy
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Does anybody know a good LZW conversion shareware? I am writing a sofware that imports and export graphics and I was hoping to use shareware to handle LZW data and also avoid Unisys LZW patent... Help!!!! Thanks
|
|
|
|
|
I've been running into a weird problem. I have a header file that has the following in it:
#ifdef _DEBUG
#pragma comment(lib, "SomeLib_Debug.lib")
#else
#pragma message("Argh")
#pragma comment(lib, "SomeLib.lib")
#endif
This header file is included in a static library, we'll call it "A.lib".
I have a program, "B", that includes "A.lib". A and B have Debug, Release, Unicode Debug, and Unicode Release builds. SomeLib just has a Debug and Release build.
B uses A.lib, but does NOT include the header shown above. In other words, it should not need "SomeLib.lib".
When I compile it in Debug or Release, it compiles fine. If I compile it in Unicode Debug or Unicode Release, it seems to require SomeLib.lib, and the link fails.
Any idea as to why this might happen? I've scoured through the project settings and can't find any differences that would explain this.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
When A.lib compiles this file, it will place the requirement for SomeLib.lib (or SomeLib_Debug.lib) into the associated obj file, which is then included inside A.lib. That means that when the linker is used to link A.lib into an executable, it will find the comment, and so try and link with SomeLib.lib as well. You can turn this behaviour off by checking the "Ignore all default libraries" option on the Project->Link settings, but this will mean you will have to manually link with all the standard libraries (MFC links with about 8 libraries using this method).
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
That makes sense, and that's kindo f what I was afraid of, but it doesn't make sense that it would fail to link only for some configurations (namely, the Unicode ones only.) I guess I was wondering why some configurations would behave differently from others, even though their settings regarding libraries seem the same?
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
How do i open an Dialog BOx from the SDI Main Frame Menu. I tried to use Do.Modal()with the Dialog class object , but it caused an assetion. If i ignore the assertion, it runs perfectly fine. I want to get rid of that assertion.
|
|
|
|
|
What causes the assertion? SDI menu has nothing to do with a dialog box. I suspect that the dialog box is not initialized correctly.
Kuphryn
|
|
|
|
|
I created an object of my Dialog class called Window.In order to open the dialog class i did Window.DoModal();
That is when assertion came up.
|
|
|
|
|
|
assertion says
Debug Assertion failed.
File:afxwin2.inl
Line 162.
i think it is due to some inappropraite use of function DoModal().
|
|
|
|
|