Gdi+ С++Builder
От: Mihay  
Дата: 20.04.06 08:57
Оценка:
Здравтвуйте!
Сколько лазил по форуму не нашел ответа на свой вопрос! Так что прошу помочь!
У меня была проблема с подключением Gdi+ к С++ Builder. Но мне посказали как это сделать (ниже приведен пример подключения). Также посоветавали в GdiplusGraphics.h сменить код в конструкторе Graphics(IN HWND hwnd, IN BOOL icm = FALSE) на Graphics(IN HWND hwnd, IN BOOL icm/* = FALSE*/), т.е убираем FALSE. Теперь файл комплируется, видает ошибки при линкеровке, например:

[Linker Error] Unresolved external 'GdiplusStartup' referenced from D:\WINSHOW\UNIT1.OBJ
[Linker Error] Unresolved external 'GdiplusShutdown' referenced from D:\WINSHOW\UNIT1.OBJ
[Linker Error] Unresolved external 'GdipFree' referenced from D:\WINSHOW\UNIT1.OBJ
[Linker Error] Unresolved external 'GdipDeleteGraphics' referenced from D:\WINSHOW\UNIT1.OBJ
[Linker Error] Unresolved external 'GdipCreateFromHDC' referenced from D:\WINSHOW\UNIT1.OBJ

Вот сам код:


#pragma hdrstop
#include <vcl.h>
#include <windows.h>

#include <algorithm>
using namespace std;
#include <GdiPlus.h>

using namespace Gdiplus;

static ULONG_PTR gdiplusToken;

void GDIppStartup()
{
GdiplusStartupInput gdiplusStartupInput;
// Initialize GDI+.
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
}


#pragma argsused

HINSTANCE hin;

extern "C"
{
__declspec(dllexport) int Window_1(HINSTANCE hinstDLL);

}


void OnPaint(HDC hdc, const RECT& rc);
LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM);
ATOM winclass();
HWND makeexamplewin();
void messageprocess();



void OnPaint(HDC hdc, const RECT& rc)
{
WCHAR welcome[] = L"Welcome GDI+ !";
Gdiplus::Graphics g(hdc);
// ----------------------------------------------------------------
// и так далее (я не привожу полностью код, тк. это будет нечитаемо)
}


LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_PAINT:
RECT rc;
HDC hdc;
PAINTSTRUCT ps;
GetClientRect(hwnd, &rc);
hdc = BeginPaint(hwnd, &ps);
OnPaint(hdc, rc);
EndPaint(hwnd, &ps);
break;

default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}

ATOM winclass()
{
WNDCLASSEX winexam1;
winexam1.cbSize = sizeof(WNDCLASSEX);
winexam1.style = CS_OWNDC|CS_HREDRAW|CS_VREDRAW;
winexam1.lpfnWndProc = WinProc;
winexam1.cbClsExtra = 0;
winexam1.cbWndExtra = 0;
winexam1.hInstance = hin;
winexam1.hIcon = LoadIcon(hin, IDI_APPLICATION);
winexam1.hCursor = LoadCursor(hin, IDC_APPSTARTING);
winexam1.hbrBackground = HBRUSH(COLOR_WINDOW+1);
winexam1.lpszMenuName = NULL;
winexam1.lpszClassName = "exemplewinclass";
winexam1.hIconSm = LoadCursor(hin, IDC_APPSTARTING);
return RegisterClassEx(&winexam1);
}

HWND makeexamplewin()
{ //CW_USEDEFAULT
return CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "exemplewinclass",
"Îêíî âèçóàëèçàöèè", WS_OVERLAPPEDWINDOW, 100,
100, 700, 700, NULL, NULL, hin, NULL);
}

void messageprocess()
{
MSG msg;
while (GetMessage(&msg, (HWND)NULL, 0, 0))
{
DispatchMessage(&msg);
}
}


int Window_1(HINSTANCE hinstDLL)
{
hin = hinstDLL;
winclass();
HWND winhandler = makeexamplewin();
ShowWindow(winhandler, SW_SHOW);
messageprocess();
return 1;
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
GDIppStartup();

// --------------------------------------------------
здесь тоже убрано
// --------------------------------------------------
GdiplusShutdown(gdiplusToken);
return 1;
}

Кто знает в чем проблема? Может я чего то не дописал?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.