|
From: Noorez K. <coo...@ho...> - 2003-11-21 22:18:28
|
this windows program isn't working. It says i have invalid conversions at
the lines where there is a comment that says so.
#include <windows.h>
long FAR PASCAL _export WndProc(HWND hwnd, UINT message, UINT wParam, LONG
lParam)
{
HDC hdc;
HPEN hpen, hpenOld;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
hpen = CreatePen(PS_SOLID,6,RGB(0, 0, 255));
hpenOld = SelectObject(hdc, hpen); //invalid conversion from void*
Rectangle(hdc, rect.left + 10,
rect.top + 10,
rect.right - 10,
rect.bottom - 10);
DrawText(hdc, "Hello, world!", -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
SelectObject(hdc, hpenOld);
DeleteObject(hpen);
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR
lpszCmdParam, int nCmdShow)
{
static char szAppName[] = "Hello";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
if(!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH); //invalid
conversion from void*
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
}
hwnd = CreateWindow(szAppName, //window class name
"HELLO Program", //windows caption
WS_OVERLAPPEDWINDOW, //window style
CW_USEDEFAULT, //inital x position
CW_USEDEFAULT, //inital y position
CW_USEDEFAULT, //inital x size
CW_USEDEFAULT, //inital y size
NULL, //parent window handle
NULL, //window menu handle
hInstance, //program instance handle
NULL); //creation paramaters //invalid
conversion from void
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=dept/features&pgmarket=en-ca&RU=https%3a%2f%2f2.zoppoz.workers.dev%3a443%2fhttp%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
|