| | |
GDI
![]() |
•
•
Join Date: Mar 2003
Posts: 1
Reputation:
Solved Threads: 0
Hello fellow programmers,
I have a problem that I have been trying to figure out for a while now. I am trying to use the GDIPLUS library but am having troubles. To test this code as it is meant to be used, open a new solution in MSVC6.0 or 7.0. Open a Win32 project an make sure it is a hello world program. Then replace the .cpp program it creates for you with the following .cpp. Include the linker path for gdiplus.lib and gdiplus.h and you should be ready to compile. Now for the errors:
: error C2871: 'Gdiplus' : a namespace with this name does not exist
: error C2653: 'Gdiplus' : is not a class or namespace name
I am using the .NET version but have the same problem on MSVC6.0. This does not make sense because Gdiplus is a namespace. Here is the code
If anyone could help me figure out why I am getting this error I would greatly appreciate it. There might be a bunch of other problems with the code, but it is just practice with GDI+.
Seriously thankful,
Kendal
I have a problem that I have been trying to figure out for a while now. I am trying to use the GDIPLUS library but am having troubles. To test this code as it is meant to be used, open a new solution in MSVC6.0 or 7.0. Open a Win32 project an make sure it is a hello world program. Then replace the .cpp program it creates for you with the following .cpp. Include the linker path for gdiplus.lib and gdiplus.h and you should be ready to compile. Now for the errors:
: error C2871: 'Gdiplus' : a namespace with this name does not exist
: error C2653: 'Gdiplus' : is not a class or namespace name
I am using the .NET version but have the same problem on MSVC6.0. This does not make sense because Gdiplus is a namespace. Here is the code
C Syntax (Toggle Plain Text)
// Sample.cpp : Defines the entry point for the application. // #include <gdiplus.h> #include <windows.h> #include "stdafx.h" #include "Sample.h" #define MAX_LOADSTRING 100 //using namespace Gdiplus; //added just to see what would happen. ULONG_PTR gdiplusToken; Gdiplus::GdiplusStartupInput gdiplusStartupInput; // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name // Forward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_SAMPLE, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SAMPLE); Gdiplus::GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } Gdiplus::GdiplusShutdown(gdiplusToken); } return (int) msg.wParam; } // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // // COMMENTS: // // This function and its usage are only necessary if you want this code // to be compatible with Win32 systems prior to the 'RegisterClassEx' // function that was added to Windows 95. It is important to call this function // so that the application will get 'well formed' small icons associated // with it. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SAMPLE); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = (LPCTSTR)IDC_SAMPLE; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex); } // // FUNCTION: InitInstance(HANDLE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } // // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); ////////////////////THE ONLY CODE THAT I HAVE ADDED OTHER THAN HEADER INCLUDES Gdiplus::Graphics gs(hdc); Gdiplus::Image image(L"misc0001.tif"); gs.DrawImage(&image,0,0); EndPaint(hWnd, &ps); ////////////////////////////////////////////////////////////////////////////// EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Message handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } return FALSE; }
If anyone could help me figure out why I am getting this error I would greatly appreciate it. There might be a bunch of other problems with the code, but it is just practice with GDI+.
Seriously thankful,
Kendal
![]() |
Similar Threads
- GDI information please (Advertising Sales Strategies)
- News Story: Microsoft Patches Critical Flaws in GDI+ (Network Security)
- Generic error in GDI+ (C#)
- Directx or GDI+ (C#)
- GDI+ Bounding Box Idea (C#)
- New to C#. GDI driving me crazy! (C#)
Other Threads in the C Forum
- Previous Thread: need programmers
- Next Thread: Spider websearch
| Thread Tools | Search this Thread |
#include * adobe ansi api array asterisks binarysearch centimeter changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork frequency function getlasterror getlogicaldrivestrin givemetehcodez global grade graphics gtkgcurlcompiling gtkwinlinux hacking highest histogram include incrementoperators infiniteloop input interest kernel keyboard kilometer linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft mqqueue number odf opendocumentformat owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape single socket socketprograming standard string systemcall threads turboc unix user voidmain() wab whythiscodecausesegmentationfault windows.h windowsapi





