Can some kindly person please explain what is wrong with this snippet of code from TheForgers WinAPI Tutorial?
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
HFONT hfDefault;
HWND hEdit;
hEdit = CreateWindowEx
(WS_EX_CLIENTEDGE, "EDIT", "",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
if(hEdit == NULL)
MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
hfDefault = GetStockObject(DEFAULT_GUI_FONT);
SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
}
break;
// Switch statement continues...............
The problem is with this line
hfDefault = GetStockObject(DEFAULT_GUI_FONT);
I get the following error when I try to compile (vc6)....
error C2440: '=' : cannot convert from 'void *' to 'struct HFONT__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Error executing cl.exe.
aptest.exe - 1 error(s), 0 warning(s)
I looked up GetStockObject() at MSDN and it seems that the function does take an integer argument and should return the type HFONT (a pointer or handle?) so I'm a confused beginner.
Thanks In Advance
dicky