October 30, 2025, 04:17:42 PM

News:

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


Win8 and GDI,GDI+

Started by ckoehn, June 03, 2013, 09:39:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ckoehn

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

Brian

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

ckoehn

Thanks Brian,  will take a look.

Later,
Clint

ckoehn

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

LarryMc

Sorry, I don't have a win8 machine to test on.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library