IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: Haim on September 26, 2009, 12:54:40 AM

Title: GDIPLUS
Post by: Haim on September 26, 2009, 12:54:40 AM
Hello,
Can anyone post a sample of using GDIPLUS in AURORA to draw lines, circles etc.

Haim

Title: Re: GDIPLUS
Post by: sapero on September 29, 2009, 11:37:25 AM
#include "windows.inc"
#include "gdiplus.inc"

sub OnPaint(PAINTSTRUCT *ps)
{
GpGraphics *graphics;
if (!GdipCreateFromHDC(ps->hdc, &graphics))
{
// create pen
GpPen *pen;
if (!GdipCreatePen1(0xFF000000 | rgb(0,0,0), 2f, UnitPixel, &pen))
{
GdipDrawLineI(graphics, pen, 10,10,200,110);
GdipDrawEllipseI(graphics, pen, 200,200, 300,400);

GdipDeletePen(pen);
}
GdipDeleteGraphics(graphics);
}
}

sub MyDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam),BOOL
{
switch (uMsg)
{
case WM_CLOSE:
DestroyWindow(hwnd);

case WM_KEYDOWN:
if (wParam == VK_ESCAPE) DestroyWindow(hwnd);

case WM_PAINT:
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
OnPaint(&ps);
EndPaint(hwnd, &ps);
return TRUE;
}
return FALSE;
}

sub gdiplusMain()
{
HWND hwnd = CreateWindow(WC_DIALOG, "",WS_SYSMENU|WS_OVERLAPPEDWINDOW,
0,0,88,88,0,0,0,0);

SetWindowLong(hwnd, DWL_DLGPROC, &MyDlgProc);
ShowWindow(hwnd, SW_MAXIMIZE);
while (IsWindow(hwnd)) {wait();}
}

sub main()
{
int gi[4]; // GdiplusStartupInput
gi = 1,0,0,0;
ULONG_PTR token;
GdiplusStartup(&token, &gi, 0);
gdiplusMain();
GdiplusShutdown(token);
}

Haim, more usefull functions you can find in msdn, browsing the TOC by Graphics&multimedia/Gdi+/reference/flat api
Title: Re: GDIPLUS
Post by: Haim on September 29, 2009, 11:33:52 PM
Thanks Sapero for your help
I will look into it this evening

Haim
Title: Re: GDIPLUS
Post by: Haim on September 30, 2009, 12:00:07 AM
Sapero,
One more question, if I may..,
I noted that you use a non Aurora window.
Can GDIPlus work with aurora windows as well?

Haim
Title: Re: GDIPLUS
Post by: sapero on September 30, 2009, 01:08:48 AM
Sure, WC_DIALOG is an numeric alias for the default system dialog class. For build-in window you can use GetHDC and pass the returned value to OnPaint function instead PAINTSTRUCT.

mywindow::repaint()
{
HDC dc = GetHDC();
GpGraphics *graphics;
GdipCreateFromHDC(dc, &graphics)
...
ReleaseHDC(dc);
}
Title: Re: GDIPLUS
Post by: Haim on September 30, 2009, 01:24:35 AM
Thank You very much Sapero

Haim