Code:
winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
I'm using MSVC++6 to compile my windows program. This line of code is pointed out by the compiler as having a conversion error from void* to struct HBRUSH__*. I used this same exact line of code in a similar program that I wrote earlier and it worked properly but now it's not compiling. What is the problem here?? Posted below is the entire source code file.
Code:
// INCLUDES /////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <math.h>
// DEFINES //////////////////////////////////////
#define WINDOW_CLASS_NAME "WINCLASS1"
// GLOBALS //////////////////////////////////////
// FUNCTIONS ////////////////////////////////////
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){
//this is the main message handler of the system
PAINTSTRUCT ps;
HDC hdc;
//what is the message
switch(msg){
case WM_CREATE:{
//do initialization stuff here
//return success
return(0);
}break;
case WM_PAINT:{
//validate the window
hdc = BeginPaint(hwnd, &ps);
//do all painting stuff here
EndPaint(hwnd, &ps);
//return success
return(0);
}break;
case WM_DESTROY:{
//kill the application
PostQuitMessage(0);
//return success
return(0);
}break;
default:break;
}
//process any messages that weren't handled
return(DefWindowProc(hwnd, msg, wparam, lparam));
}
// WINMAIN //////////////////////////////////////
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int nshowcmd){
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
//fill in the window clas structure
winclass.cbSize = sizeof(WNDCLASSEX);
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);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
//register the window class
if(!RegisterClassEx(&winclass))
return(0);
//create the window
if(!(hwnd = CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"Your Basic Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0,
400, 400,
NULL,
NULL,
hinstance,
NULL)))
return(0);
//enter main event loop
while(GetMessage(&msg, NULL, 0, 0)){
//translate
TranslateMessage(&msg);
//send the message to the window proc
DispatchMessage(&msg);
}
//return to windows
return(msg.wParam);
}