Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Vilhelm-Ion Praisach
  Where is Vilhelm-Ion Praisach?
 Resita
 Romania
 Vilhelm-Ion Praisach
 To: David Mustakim
  Where is David Mustakim?
 Jakarta
 Indonesia
 David Mustakim
 Tags
Subject: RE: DIFFRERENT SHAPE VFP FORMS
Thread ID: 395778 Message ID: 395815 # Views: 73 # Ratings: 7
Version: Not Applicable Category: Win32API programming
Date: Monday, January 20, 2014 9:17:24 AM         
   


> my guess is one can develop it further for producing much more smoother cuts by either playing with smaller pixel regions and / or the "elliptical cuts" (?)

I got a new toy and I'm playing with it. :-)

For smoother cuts I set the curvature property:

DEFINE CLASS ClickShape AS Shape
    curvature=3
    FUNCTION Click
        thisForm.Click
ENDDEFINE


Eliptical cuts.

demo1
#define RGN_OR 2
#define RGN_AND 1
#define RGN_XOR 3
#define RGN_DIFF 4
#define RGN_COPY 5
#define NULLREGION 1
#define SIMPLEREGION 2
#define COMPLEXREGION 3
#define r_ERROR 0
Declare Long CombineRgn IN WIN32API Long hrgnDest, Long hrgnSrc1, Long hrgnSrc2, Long fnCombineMode
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, String bRedraw
Declare Long CreateEllipticRgn IN WIN32API Long X1, Long Y1, Long X2, Long Y2
Declare Long CreateRectRgn IN WIN32API Long X1, Long Y1, Long X2, Long Y2

PUBLIC ofrm
ofrm=CREATEOBJECT("MyForm")
oFrm.visible=.T.

DEFINE CLASS MyForm as Form
	PROCEDURE lOAD
		This.reshape
	ENDPROC
	PROCEDURE resize
		This.reshape
	ENDPROC
	PROCEDURE reshape
		LOCAL lox0,x1,x2,x3
		lnPow0=1
		lox0 = CreateRectRgn(0, 0, This.width+2*SYSMETRIC(3), This.height+2*SYSMETRIC(4)+SYSMETRIC(9))
		x1=CreateEllipticRgn(This.width*3/8,This.height*3/8,This.width*5/8,This.height*5/8)
		x2=CreateEllipticRgn(This.width*7/16,This.height*7/16,This.width*9/16,This.height*9/16)
		CombineRgn(x1,x1,x2,RGN_DIFF)
		CombineRgn(lox0,lox0,x1,RGN_DIFF)
		SetWindowRgn(thisform.hwnd, lox0, "True")
	ENDPROC
ENDDEFINE


demo2
#define RGN_OR 2
#define RGN_AND 1
#define RGN_XOR 3
#define RGN_DIFF 4
#define RGN_COPY 5
#define NULLREGION 1
#define SIMPLEREGION 2
#define COMPLEXREGION 3
#define r_ERROR 0
Declare Long CombineRgn IN WIN32API Long hrgnDest, Long hrgnSrc1, Long hrgnSrc2, Long fnCombineMode
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, String bRedraw
Declare Long CreateEllipticRgn IN WIN32API Long X1, Long Y1, Long X2, Long Y2
Declare Long CreateRectRgn IN WIN32API Long X1, Long Y1, Long X2, Long Y2

PUBLIC ofrm
ofrm=CREATEOBJECT("MyForm")
oFrm.visible=.T.

DEFINE CLASS MyForm as Form
	nHoles=5
	PROCEDURE lOAD
		This.reshape
	ENDPROC
	PROCEDURE resize
		This.reshape
	ENDPROC
	PROCEDURE reshape
		LOCAL lox0,lax[This.nHoles],lnPow0,lnLeft,lnRight,lni,lnWidth,lnHeight
		lnPow0=1
		lox0 = CreateRectRgn(0, 0, This.width+2*SYSMETRIC(3), This.height+2*SYSMETRIC(4)+SYSMETRIC(9))
		FOR lni=1 TO This.nHoles
			lnLeft=(2^(lni+lnPow0)-1)/2^(lni+lnPow0+1)
			lnRight=(2^(lni+lnPow0)+1)/2^(lni+lnPow0+1)
			lax[lni]=CreateEllipticRgn(This.width*lnLeft,This.height*lnLeft,This.width*lnRight,This.height*lnRight)
			IF lni>1
				CombineRgn(lax[1],lax[1],lax[lni],RGN_XOR)
			ENDIF
		NEXT
		CombineRgn(lox0,lox0,lax[1],RGN_DIFF)
		SetWindowRgn(thisform.hwnd, lox0, "True")
	ENDPROC
ENDDEFINE


demo3
#define RGN_OR 2
#define RGN_AND 1
#define RGN_XOR 3
#define RGN_DIFF 4
#define RGN_COPY 5
#define NULLREGION 1
#define SIMPLEREGION 2
#define COMPLEXREGION 3
#define r_ERROR 0
Declare Long CombineRgn IN WIN32API Long hrgnDest, Long hrgnSrc1, Long hrgnSrc2, Long fnCombineMode
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, String bRedraw
Declare Long CreateEllipticRgn IN WIN32API Long X1, Long Y1, Long X2, Long Y2
Declare Long CreateRectRgn IN WIN32API Long X1, Long Y1, Long X2, Long Y2

PUBLIC ofrm
ofrm=CREATEOBJECT("MyForm")
oFrm.visible=.T.

DEFINE CLASS MyForm as Form
	shp1=.Null.
	shp2=.Null.
	PROCEDURE lOAD
		This.reshape
	ENDPROC
	PROCEDURE resize
		This.reshape
	ENDPROC
	PROCEDURE reshape
		LOCAL lox0,x1,x2,x3,loShp,lcName
		lnPow0=1
		lox0 = CreateRectRgn(0, 0, This.width+2*SYSMETRIC(3), This.height+2*SYSMETRIC(4)+SYSMETRIC(9))
		x1=CreateEllipticRgn(This.width*3/8,This.height*3/8,This.width*5/8,This.height*5/8)
		x2=CreateEllipticRgn(This.width*7/16,This.height*7/16,This.width*9/16,This.height*9/16)
		x3=CombineRgn(x1,x1,x2,RGN_DIFF)
		IF x3!=r_ERROR
			IF CombineRgn(lox0,lox0,x1,RGN_DIFF)!=r_ERROR
				SetWindowRgn(thisform.hwnd, lox0, "True")
			ELSE
				MESSAGEBOX(1)
			ENDIF
		ELSE
			MESSAGEBOX(2)
		ENDIF
		IF !ISNULL(This.shp1)
			This.RemoveObject(This.shp1.name)
		ENDIF
		IF !ISNULL(This.shp2)
			This.RemoveObject(This.shp2.name)
		ENDIF
		lcName=SYS(2015)
		This.AddObject(lcName,"shape")
		This.shp1=GETPEM(This,lcName)
		This.shp1.borderwidth=3
		This.shp1.left=This.width*3/8-(SYSMETRIC(3))-This.shp1.borderwidth
		This.shp1.top=This.height*3/8-(SYSMETRIC(4)+SYSMETRIC(9))-This.shp1.borderwidth
		This.shp1.width=This.width*2/8+2*This.shp1.borderwidth
		This.shp1.height=This.height*2/8+2*This.shp1.borderwidth
		This.shp1.curvature=99
		This.shp1.visible=.T.


		lcName=SYS(2015)
		This.AddObject(lcName,"shape")
		This.shp2=GETPEM(This,lcName)
		This.shp2.borderwidth=3
		This.shp2.left=This.width*7/16-(SYSMETRIC(3))
		This.shp2.top=This.height*7/16-(SYSMETRIC(4)+SYSMETRIC(9))
		This.shp2.width=This.width*2/16-This.shp2.borderwidth
		This.shp2.height=This.height*2/16-This.shp2.borderwidth
		This.shp2.curvature=99
		This.shp2.visible=.T.
	ENDPROC
ENDDEFINE




My respects

ENTIRE THREAD

DIFFRERENT SHAPE VFP FORMS Posted by David Mustakim @ 1/19/2014 7:48:34 AM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Rick C. Hodgin @ 1/19/2014 1:46:10 PM
RE: DIFFRERENT SHAPE VFP FORMS Posted by David Mustakim @ 1/19/2014 3:18:13 PM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Rick C. Hodgin @ 1/19/2014 7:03:23 PM
RE: DIFFRERENT SHAPE VFP FORMS Posted by David Mustakim @ 1/19/2014 7:16:59 PM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Vilhelm-Ion Praisach @ 1/20/2014 9:17:24 AM
RE: DIFFRERENT SHAPE VFP FORMS Posted by David Mustakim @ 1/20/2014 10:16:40 AM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Vilhelm-Ion Praisach @ 1/20/2014 11:22:19 AM
RE: DIFFRERENT SHAPE VFP FORMS Posted by David Mustakim @ 1/20/2014 11:32:48 AM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Vilhelm-Ion Praisach @ 1/19/2014 7:44:58 PM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Rick C. Hodgin @ 1/19/2014 11:17:05 PM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Jun Tangunan @ 1/20/2014 12:00:40 AM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Tony Vignone @ 1/19/2014 8:48:24 PM
RE: DIFFRERENT SHAPE VFP FORMS Posted by David Mustakim @ 1/19/2014 8:53:07 PM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Tony Vignone @ 1/20/2014 3:35:10 AM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Vilhelm-Ion Praisach @ 1/19/2014 9:27:53 PM
RE: DIFFRERENT SHAPE VFP FORMS Posted by Tony Vignone @ 1/20/2014 3:33:57 AM