IonicWind Software

IWBasic => General Questions => Topic started by: ckoehn on June 03, 2013, 09:39:35 AM

Title: Win8 and GDI,GDI+
Post by: ckoehn on June 03, 2013, 09:39:35 AM
It appears that Win8 does not support all of the GDI functions.  I used GDI+ to produce a rounded rectangle with a color fading from one color to another.  The rounded rectangle appears but not the color fade.  Is there an alternative to GDI+ that will work in win7 and wn8?

SUB RoundRectangle(WINDOW win,INT l,INT t,INT Width,INT Height,INT Rad,UINT border,UINT lfill,UINT fill)
POINTER pPen=0,pGraphics=0,pBrush=0,pPath=0,mBrush=0
POINTL GpStart,GpEnd
INT phdc,pchdc

IF (!gdi_ret)
phdc = win.m_hPrintDC
win.m_hPrintDC=GETHDC(win)

SelectClipRgn(phdc,0)
IntersectClipRect(phdc,l,t,Width,Height)

hdc=gethdc(win)
GdipCreateFromHDC(hdc, &pGraphics)

GdipSetSmoothingMode(pGraphics,SmoothingModeAntiAlias)

GdipCreatePath(0,&pPath)

GdipStartPathFigure(pPath)
GdipAddPathArcI(pPath,l,t,rad,rad,180.0,90.0)
GdipAddPathLineI(pPath,l+rad,t,l+Width-rad,t)
GdipAddPathArcI(pPath,l+Width-rad,t,rad,rad,270.0,90.0)
GdipAddPathLineI(pPath,l+Width,t+rad,l+Width,t+Height-rad)
GdipAddPathArcI(pPath,l+Width-rad,t+Height-rad,rad,rad,0.0,90.0)
GdipAddPathLineI(pPath,l+Width-rad,t+Height,l+rad,t+Height)
GdipAddPathArcI(pPath,l,t+Height-rad,rad,rad,90.0,90.0)
GdipClosePathFigure(pPath)

GpStart.x=l+(Width*0.25f):GpStart.y=t
GpEnd.x=l+(Width*0.75f):GpEnd.y=t+Height
GdipCreateLineBrushI(GpStart, GpEnd, lfill, fill, 1, &pBrush)
GdipCreatePen1(border,2,UnitPixel,&pPen)

GdipFillPath(pGraphics,pBrush,pPath)
GdipDrawPath(pGraphics,pPen,pPath)

'Cleanup
IF pPath THEN GdipDeletePath(pPath)
IF pBrush THEN GdipDeleteBrush(pBrush)
IF mBrush THEN GdipDeleteBrush(mBrush)
IF pPen THEN GdipDeletePen(pPen)

IF pGraphics then GdipDeleteGraphics(pGraphics)

RELEASEHDC win,hdc

pchdc=win.m_hPrintDC
win.m_hPrintDC=phdc
RELEASEHDC win,pchdc

ELSE
'no gdi

ENDIF
ENDSUB


Later,
Clint
Title: Re: Win8 and GDI,GDI+
Post by: Brian on June 03, 2013, 11:39:18 AM
Clint,
Don't know whether these will help you or not, but they're handy to have on hand, anyway
I've converted them to IWB format. Don't forget to make a .lib file!
Brian
Title: Re: Win8 and GDI,GDI+
Post by: ckoehn on June 03, 2013, 11:45:51 AM
Thanks Brian,  will take a look.

Later,
Clint
Title: Re: Win8 and GDI,GDI+
Post by: ckoehn on June 04, 2013, 07:13:44 AM
That still uses "gdi32" since it is only a wrapper.  Is it possible to fade from one color to another on Win8 using IWB?

Later,
Clint
Title: Re: Win8 and GDI,GDI+
Post by: LarryMc on June 04, 2013, 09:11:57 AM
Sorry, I don't have a win8 machine to test on.