Answered by:
error while using graphics program using GDI+

Question
-
When ever or what ever i do i dont understand why the heck is this error coming its eating my head. Every time i complie i graphics program using graphics.h or GDI+ i get the same dam old error every time PLEASE HELP ME its getting on my nerves.
This time i used GDI+
this is my code:
#include "stdafx.h" #include "windows.h" #include <Gdiplus.h> using namespace Gdiplus; #pragma comment(lib, "gdiplus.lib") VOID OnPaint(HDC hdc) { Graphics graphics(hdc); Pen pen(Color(255, 0, 0, 255)); graphics.DrawLine(&pen, 0, 0, 200, 100); } LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow) { HWND hWnd; MSG msg; WNDCLASS wndClass; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; // Initialize GDI+. GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WndProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = hInstance; wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = TEXT("GettingStarted"); RegisterClass(&wndClass); hWnd = CreateWindow( TEXT("GettingStarted"), // window class name TEXT("Getting Started"), // window caption WS_OVERLAPPEDWINDOW, // window style CW_USEDEFAULT, // initial x position CW_USEDEFAULT, // initial y position CW_USEDEFAULT, // initial x size CW_USEDEFAULT, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL); // creation parameters ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } GdiplusShutdown(gdiplusToken); return msg.wParam; } // WinMain LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; switch(message) { case WM_PAINT: hdc = BeginPaint(hWnd, &ps); OnPaint(hdc); EndPaint(hWnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } }
and this little problem is troubling me
error1>------ Build started: Project: Development, Configuration: Debug Win32 ------ 1>Compiling... 1>Development.cpp 1>Linking... 1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup 1>C:\Users\Abhimanyu\Documents\Visual Studio 2008\Projects\Development\Debug\Development.exe : fatal error LNK1120: 1 unresolved externals 1>Build log was saved at "file://c:\Users\Abhimanyu\Documents\Visual Studio 2008\Projects\Development\Development\Debug\BuildLog.htm" 1>Development - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
PLEASE HELP ME PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASEWednesday, February 3, 2010 6:16 PM
Answers
-
Start a new project and select Win32 App instead of Win32 Console App.
Win32 Apps must start with WinMain().
Win32 Console Apps must start with main().- Proposed as answer by Nancy Shao Friday, February 5, 2010 10:05 AM
- Marked as answer by JackSparrowPirates Friday, February 5, 2010 2:10 PM
Wednesday, February 3, 2010 6:26 PM -
Hi,
Or you can try to change SubSystem to Windows(/SUBSYSTEM:CONSOLE ) by navigating Project Properties > Configuration Properties > Linker > System .
Best Regards,
Nancy
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked as answer by JackSparrowPirates Friday, February 5, 2010 2:10 PM
Friday, February 5, 2010 10:05 AM
All replies
-
Start a new project and select Win32 App instead of Win32 Console App.
Win32 Apps must start with WinMain().
Win32 Console Apps must start with main().- Proposed as answer by Nancy Shao Friday, February 5, 2010 10:05 AM
- Marked as answer by JackSparrowPirates Friday, February 5, 2010 2:10 PM
Wednesday, February 3, 2010 6:26 PM -
Hi,
Or you can try to change SubSystem to Windows(/SUBSYSTEM:CONSOLE ) by navigating Project Properties > Configuration Properties > Linker > System .
Best Regards,
Nancy
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked as answer by JackSparrowPirates Friday, February 5, 2010 2:10 PM
Friday, February 5, 2010 10:05 AM