Archived

This topic is now archived and is closed to further replies.

xegoth

Why can't I use a string variable for logtext?

Recommended Posts

I am trying to define a font using logfont but its not letting me use a string variable. Heres what happens:

char sString[32];

LOGFONT LogFont = {72,0,0,0,FW_NORMAL,false,false,false,DEFAULT_CHARSET,
	OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH, sString};
I get the error: error C2440: ''initializing'' : cannot convert from ''char []'' to ''char'' I looked up the defintion of the logfont struct and theirs is an array of chars also (a string). the following works:
LOGFONT LogFont = {72,0,0,0,FW_NORMAL,false,false,false,DEFAULT_CHARSET,
	OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH, "Arial"};
What do I need to do to feed it a variable instead of a straight string? Note LOGFONT can be found in windows.h or wingdi.h

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try this:

char sString[32];

LOGFONT LogFont = {72,0,0,0,FW_NORMAL,false,false,false,DEFAULT_CHARSET,
OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH, (char *)sString};

Share this post


Link to post
Share on other sites
Nope, unfortunately that doesn''t work. engine.cpp(126) : error C2440: ''initializing'' : cannot convert from ''char *'' to ''char''

The problem as I see it is microsoft declared the string in their struct as:

#define LF_FACESIZE 32

typedef struct tagLOGFONTA
{
LONG lfHeight;
LONG lfWidth;
LONG lfEscapement;
LONG lfOrientation;
LONG lfWeight;
BYTE lfItalic;
BYTE lfUnderline;
BYTE lfStrikeOut;
BYTE lfCharSet;
BYTE lfOutPrecision;
BYTE lfClipPrecision;
BYTE lfQuality;
BYTE lfPitchAndFamily;
CHAR lfFaceName[LF_FACESIZE];
}

as far as I can tell if they had done char* lfFaceName;
it would work, but they didn''t. So how can I send it a string variable without changing microsoft files

Share this post


Link to post
Share on other sites