|
-
Oct 27th, 2002, 10:17 AM
#1
Thread Starter
Addicted Member
Creating controls at runtime - Error
I get the followin error while trying to compile a program that creates an EDIT box at runtime:
--------------------Configuration: TextPad - Win32 Debug--------------------
Compiling...
Main.cpp
C:\Documents and Settings\Gustavo1\Desktop\henrique\TextPad\Main.cpp(82) : 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.
TextPad.exe - 1 error(s), 0 warning(s)
-------------------------------------------------------------------------------
This is the part where my errorr is supposed to be at...I have also included the #define which is at the beginning of the program
Code:
#define IDC_MAIN_EDIT 101
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));
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
Thanks.
-
Oct 28th, 2002, 08:50 AM
#2
hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
You need to explicitly cast the return value of GetStockObject.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|