May 23, 2019, 06:59:36 am

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


GDIPLUS

Started by Haim, September 26, 2009, 12:54:40 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haim

September 26, 2009, 12:54:40 am Last Edit: September 26, 2009, 01:00:04 am by Haim
Hello,
Can anyone post a sample of using GDIPLUS in AURORA to draw lines, circles etc.

Haim


sapero

Code Select
#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

Haim

Thanks Sapero for your help
I will look into it this evening

Haim

Haim

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

sapero

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.

Code Select
mywindow::repaint()
{
HDC dc = GetHDC();
GpGraphics *graphics;
GdipCreateFromHDC(dc, &graphics)
...
ReleaseHDC(dc);
}

Haim

Thank You very much Sapero

Haim