Unknown crash. LOGFONT, static, MSDN.

This is a discussion on Unknown crash. LOGFONT, static, MSDN. within the Windows Programming forums, part of the Platform Specific Boards category; I'm a little confused. I found this: http://msdn.microsoft.com/library/default..../usingmenus.asp
And in the link it does this.
Code:
HFONT GetAFont(int fnFont)
{
...

Doesn't do anything. But that's because, hey, it crashes! Before it hits the break, it calls some procedure that um, does some wierd stuff, and then crashes I think with an unhandled exception (that may have been raised in this procedure). Disassembly ends up like this yo.

That CALL Dialog_T.004013CC there at the end does it. Um. Yeah, that CALL is made unconditionally, and I can't understand it. But the wierd part is, after being all mystified by the fact that it was crashing, I made my LOGFONT structure static, like in MSDN's code, and it did not crash. In fact, the disassembly does not contain that last call.

Why does my LOGFONT structure have to be static, and if possible, why did it crash in the first place? Nothing in the CreateFontIndirect/LOGFONT documentation about such craziness. All replies appreciated.

I don't know, but that call to _tcsncpy seems quite weird to me even though I don't know what this function does. It's probably some kind of strcpy() alter-ego and well, you can juste make the pointer point to the string:

Code:

lFont.lfFaceName = "Courier New";

Also, sizeof doesn't return the number of character, you need strlen() for that and its return value doesn't count the null terminator.

1>.\main.cpp(128) : error C2440: '=' : cannot convert from 'const wchar_t [12]' to 'WCHAR [32]'
1> There is no context in which this conversion is possible

It's not a pointer, it's an array. WCHAR is a typedef for wchar_t.

Code:

WCHAR lfFaceName[LF_FACESIZE];

I can't assign to the array like that outside of initialization. I could have used strlen (_tcslen) but sizeof works, if it isn't copying more than the sizeof the array, I can say that it's doing it's job.