• Advertisement

Archived

This topic is now archived and is closed to further replies.

Need help whit C++ code..

This topic is 6522 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

what is wrong,, i get this error message: -----Configuration: noname - Win32 Debug-------------------- Compiling... noname.cpp c:\cpp\temp\noname.cpp(86) : error C2440: ''='' : cannot convert from ''void *'' to ''struct HBRUSH__ *'' Conversion from ''void*'' to pointer to non-''void'' requires an explicit cast Error executing cl.exe. noname.exe - 1 error(s), 0 warning(s) ..... heres some code from that lines(winmain)..:: // WINMAIN int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASS winclass; HWND hwnd; MSG msg; winclass.style = CS_DBLCLKS / CS_OWNDC / CS_HREDRAW / CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = GetStockObject(BLACK_BRUSH); ^^^^ this line gives error ^^^^^^^^^^^^^^^^^^^^^^^^^^^ winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; if(!RegisterClass(&winclass)) return(0); if(!(hwnd = CreateWindow(WINDOW_CLASS_NAME, "noname", // titel WS_OVERLAPPEDWINDOW / WS_VISIBLE, 0,0, // x,y startposition 320,200, // bredd, höjd NULL, // handtag till moder NULL, // handtag till meny hinstance, NULL))) return(0); main_window_handle = hwnd; Init(); while(1) { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if(msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } Main(); } Shutdown(); return(msg.wParam); } //========================================================== (sorry for the swedish comments) this code worked in borland c++ 5,, but now im trying to use MS-VC++,, It is possible i have some bad option or setting somewhere who coussing this.. plz hlp, tnx.. // dha^zynd!kate

Share this post


Link to post
Share on other sites
Advertisement
just cast the void* to a HBRUSH
winclass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);


Share this post


Link to post
Share on other sites

  • Advertisement