i want to fill in the ellipse with a gray background but when i run this code, it return the following error:
cannot convert from 'void *' to 'struct HBRUSH__ *'
Here is the code:
Code:#include <windows.h> LRESULT CALLBACK WndProc(HWND hwnd, UINT imsg, WPARAM wparam, LPARAM lparam) { HDC hdc; PAINTSTRUCT ps; HPEN hpen; HBRUSH hbrush; hbrush = GetStockObject(GRAY_BRUSH); switch(imsg) { case WM_PAINT: hdc= BeginPaint(hwnd, &ps); SelectObject(hdc, hbrush); Ellipse(hdc, 0, 0, 23, 23); EndPaint(hwnd, &ps); DeleteObject(hbrush); return 0; case WM_CLOSE: DestroyWindow(hwnd); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, imsg, wparam, lparam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { WNDCLASSEX wc; MSG msg; HWND winhwnd; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "myclass"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Error in Class Registeration", "Error", MB_OK); return 0; } winhwnd = CreateWindowEx( WS_EX_CLIENTEDGE, "myclass", "the title", WS_OVERLAPPEDWINDOW, 0, 0, 340, 304, NULL, NULL, hInstance, NULL); if(winhwnd == NULL) { MessageBox(NULL, "Error in hwnd Registeration", "Error", MB_OK); return 0; } ShowWindow(winhwnd, nShowCmd); UpdateWindow(winhwnd); while(GetMessage(&msg, NULL, 0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
Please help me and find the solution!




Reply With Quote