changing fonts in Windows API

i have this code to display some text but i want to make the text bigger. I was told it has something to do with the font but i have no idea what to do and everything on google seems so advanced. Is there an easy way to change the font size?
heres my code for displaying the text:

wchar_t message[20], buffer[10];
	LPPAINTSTRUCT lpPaint;

	wcscpy(message, L"score is "); 

case IDC_BUTTONRESULT:
	hdc = GetDC(hWnd);
	_itow(score, buffer,10);
	 wcscat(message, buffer);
				
	 TextOut(hdc,100,200,message,wcslen(message));

the message displays fine i just want to change the size
thanks
Last edited on
Just do some research, you will get there eventually.
i didnt find anything, i have done some research and like i said, the code i found just looks so complicated. Could some one how me the code and explain it to me? I'm sure its a simple one line code but i cant find it
I think you have to do this when you are setting up your output fonts. I believe this is required before you output any text. Look up http://msdn.microsoft.com/en-us/library/ms632642. That may help.

Sorry I couldn't help more. I'm new to that stuff too.
This looks more interesting

http://www.functionx.com/win32/Lesson14.htm
ok that helps a bit. i know i need int nHeight and int nWidth but i still dont know how to use them. i tried using the code from the link and i got errors. that code is doing way more than i want anyway. i just want to increase the text size
anyone?
This looks like a pretty good tutorial:

http://www.functionx.com/win32/Lesson14.htm
i tried using this tutorial and i just get errors

I put this on the top of my program
1
2
3
4
5
6
typedef struct tagLOGFONT { 
LONG lfHeight; 
LONG lfWidth; 
} LOGFONT, *PLOGFONT;

BOOL CreateFontIndirect(const LOGFONT* lpLogFont);


heres the rest of the code for the text box
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
case IDC_BUTTONRESULT:
hdc = GetDC(hWnd);
_itow(score, buffer,10);
 wcscat(message, buffer);

LogFont.lfHeight = 20;
LogFont.lfWidth = 20;

font = CreateFontIndirect(&LogFont); //this lines has a error and code still doesnt work if i take it out
SelectObject(hdc, font);
				
TextOut(hdc,100,200,message,wcslen(message));

DeleteObject(font);
break;


theres also in the code
1
2
LOGFONT LogFont;
HFONT font;


sorry i cant show the whole program because its too big but hopefully the bits of code i put up will be enough
You must not define the LOGFONT structure or forward declare the CreateFontIndirect() function. That is #included for you when you #include the windows header file.

You also don't seem to be drawing in the right place. You draw in WM_PAINT. That's it, unless you have a very very good reason to draw elsewhere, which is usually never the case.

In general, I'd recommend that you read a good tutorial or book on how to program for Windows. Otherwise you'll have headaches over this.
thanks i got it to work. and i was drawing in WM_PAINT i just didnt copy that part of the code over
Topic archived. No new replies allowed.