So, I am starting with the other nessasary things, but I already ran into a problem...
I wrote the code needed to make a window (I believe), but I keep getting an error I can't figure out.
The Error is:
Code:
[Linker error] undefined reference to "GetStockObject@4"
id returned 1 exit status
[Build Error] [windowmenu.exe] Error 1
I use Dev C++ 4.9.9.2
The code is...
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <math.h>
#define WINDOW_CLASS_NAME "WINCLASS1"
HWND main_window_handle = NULL;
//////////////////////////////////////
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{return(0);} break;
case WM_PAINT:
{hdc=BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);} break;
case WM_DESTROY:
{PostQuitMessage(0);
return(0);}break;
default:break;
}
}
//////////////////////////////////////
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=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName=NULL;
winclass.lpszClassName=WINDOW_CLASS_NAME;
if(!RegisterClass(&winclass))
return(0);
if (!(hwnd=CreateWindow(WINDOW_CLASS_NAME,
"Title",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
320,200,
NULL,
NULL,
hinstance,
NULL)))
return(0);
main_window_handle=hwnd;
while(1)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(msg.message==WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
That is the code that my C++ book has in it. If you know of a better way to do make a window, feel free to say so.