|
From: Daniel G. <sp...@ho...> - 2003-11-22 06:47:36
|
You need to use a typecast.
> hpenOld = (HPEN)SelectObject(hdc, hpen);
Something like that.
Daniel
>From: "Noorez Kassam" <coo...@ho...>
>To: dev...@li...
>Subject: [Dev-C++] windows program error
>Date: Fri, 21 Nov 2003 15:18:21 -0700
>
>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=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: SF.net Giveback Program.
>Does SourceForge.net help you be more productive? Does it
>help you create better code? SHARE THE LOVE, and help us help
>YOU! Click Here: http://sourceforge.net/donate/
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
|