October 09, 2024, 04:09:43 PM

News:

IWBasic runs in Windows 11!


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

#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.

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

Haim

Thank You very much Sapero

Haim