I'm doing a lesson from a book call "Tricks of the Window Game Programming Gurus", where it trys to teach you how to make the basic parts of a window.
Sorry for cloggin the place up with comments but thats how I remember what the certain things do.
However, when linking the file i get 2 errors:
heres my codeCode:Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Demo.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Demo.exe - 2 error(s), 0 warning(s)
Any suggestions? Oh yeah, I'm usin Visual C++.Code://DEMO2_3.C - A complete windows program //INCLUDES///////////////////////////////////////////////////// #define WIN32_LEAN_AND_MEAN #include <windows.h> //include all the windows headers #include <windowsx.h> //include useful macros #include <stdio.h> #include <math.h> //DEFINES////////////////////////////////////////////////////// //defines for windows #define WINDOW_CLASS_NAME "WINCLASS1" //FUNCTIONS//////////////////////////////////////////////////// //the event handler LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { //this is the main message handler of the system PAINTSTRUCT ps; //used in WM_PAINT HDC hdc; //handle to a device context //what is the message switch(msg) { case WM_CREATE: { //do initialization stuff here //return success return(0); } break; case WM_PAINT: { //simply validate the window hdc = BeginPaint(hwnd, &ps); //you would do all your painting here EndPaint(hwnd, &ps); //return success return(0); } break; case WM_DESTROY: { //kill the application, this sends a WM_QUIT message PostQuitMessage(0); //return success return(0); } break; default:break; } //ends switch //process any messages that we didn't take car of return (DefWindowProc(hwnd, msg, wparam, lparam)); } //ends WinProc //WINMAIN////////////////////////////////////////////////////////// int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; //this will hold the class we make HWND hwnd; //generic window handle MSG msg; //generic message // first fill in window class 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 = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName ="WINCLASS1"; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //this registers our class with windows if(!RegisterClassEx(&winclass)) return(0); //this creates the window, bails if there is a problem if(!(hwnd = CreateWindowEx(NULL, //extended style "WINCLASS1", //this points to the class "Your Basic Window", //the title of the window WS_OVERLAPPEDWINDOW | WS_VISIBLE, //a few styles for the window 0,0, //initial x,y coordinates 400,400, //initial width and height NULL, //makes the handle to the parent, NULL makes desktop the parent NULL, //handle to the menu hinstance, //instance of this application NULL))) //extra creation parameters return(0); //enter main event loop while(GetMessage(&msg,NULL,0,0)) { //translate any accelerator keys TranslateMessage(&msg); //send the message to the window proc DispatchMessage(&msg); }//end while //return to windows like this return(msg.wParam); }//end WinMain



LinkBack URL
About LinkBacks


