回复 14楼 sych
我想完成在三角形中渐变,但似乎没有成功,提示在dll中找不到入口点
调试时这句出错:
GradientFilltriangle(hdc,@cvertex,3,@cg_r,1,2)
我的系统是win7+foxpro 9.0 sp2!
代码如下:
程序代码:
Declare integer GradientFillRect IN msimg32 long, string @, long, string @, long, long
Declare integer GradientFillTriangle in "msimg32" Long, string @, Long, string @, Long, Long
DECLARE integer GradientFill IN msimg32 long, string @, long, string @, long, long
DECLARE integer GetWindowDC IN WIN32API integer
DECLARE integer GetLastError IN WIN32API
DECLARE integer ReleaseDC IN WIN32API integer,integer
DECLARE INTEGER GetDesktopWindow IN win32api
DECLARE INTEGER GetDC IN win32api INTEGER hwnd
clea
hdc=getdc(_screen.hwnd)
overtex=NEWOBJECT("trivertex")
overtex.n=3
overtex.set(1,100,100)
overtex.set(2,500,500)
overtex.set(3,50,400)
cvertex=overtex.getstruct()
og_r=NEWOBJECT("gradient_rect")
og_r.n=3
og_r.set(1,0,1,2)
cg_r=og_r.getstruct()
GradientFilltriangle(hdc,@cvertex,3,@cg_r,1,2)
RELEASE memo like o*
RELEASE memo like c*
releasedc(_screen.hwnd,hdc)
**************************************************
*-- 类: trivertex (d:\documents\visual foxpro 项目\myclass.vcx)
*-- 父类: struct (d:\documents\visual foxpro 项目\myclass.vcx)
*-- 基类: custom
*-- 时间戳: 08/22/24 05:03:08 PM
*
DEFINE CLASS trivertex AS custom
Height = 22
Width = 58
*-- 顶点数,决定所有数组大小,2为矩形,3为三角形,大于3则可以任意组合。
n = .F.
*-- 顶点x轴坐标数组
DIMENSION x[2]
*-- 顶点y轴坐标数组
DIMENSION y[2]
*-- 红色分量数组
DIMENSION r[2]
*-- 绿色分量数组
DIMENSION g[2]
*-- 蓝色分量数组
DIMENSION b[2]
*-- alpha透明度分量数组
DIMENSION a[2]
PROCEDURE n_assign
LPARAMETERS vNewVal
*To do: 为 Assign 方法程序修改此例程
IF m.vnewval<>this.n
DIMENSION this.x[m.vnewval]
DIMENSION this.y[m.vnewval]
DIMENSION this.r[m.vnewval]
DIMENSION this.g[m.vnewval]
DIMENSION this.b[m.vnewval]
DIMENSION this.a[m.vnewval]
ENDIF
THIS.n = m.vNewVal
ENDPROC
PROCEDURE getstruct
this.struct=''
FOR i=1 TO this.n
this.struct=this.struct+;
BINTOC(this.x[i],[4rs])+;
BINTOC(this.y[i],[4rs])+;
BINTOC(this.r[i],[2s])+;
BINTOC(this.g[i],[2s])+;
BINTOC(this.b[i],[2s])+;
BINTOC(this.a[i],[2s])
ENDFOR
RETURN this.struct
ENDPROC
PROCEDURE set
*!********* 在设置顶点结构前,需要确定有几个顶点,this.n=? **********!*
PARAMETERS nindex, x,y,nred,ngreen,nblue,nalpha
DO CASE
CASE PARAMETERS()=3
ocolor=NEWOBJECT([color],[myclass])
ncolor=GETCOLOR()
IF ncolor<0
RELEASE ocolor,ncolor
RETURN .f.
ELSE
ocolor.set(ncolor)
this.x[nindex]=x
this.y[nindex]=y
this.r[nindex]=ocolor.r
this.g[nindex]=ocolor.g
this.b[nindex]=ocolor.b
this.a[nindex]=ocolor.a
ENDIF
CASE PARAMETERS()=7
this.x[nindex]=x
this.y[nindex]=y
this.r[nindex]=nred
this.g[nindex]=ngreen
this.b[nindex]=nblue
this.a[nindex]=nalpha
OTHERWISE
RETURN .f.
ENDCASE
ENDPROC
ENDDEFINE
*
*-- EndDefine: trivertex
**************************************************
**************************************************
*-- 类:
gradient_rect (d:\documents\visual foxpro 项目\myclass.vcx)
*-- 父类:
struct (d:\documents\visual foxpro 项目\myclass.vcx)
*-- 基类:
custom
*-- 时间戳:
08/22/24 07:58:02 PM
*
DEFINE CLASS gradient_rect AS custom
*-- 确定矩形或三角形顶点的数量,总是2的倍数(长方形),或3的倍数(三角形)
n = 2
*-- 指定顶点结构数组中的索引数组
DIMENSION nindexs[2]
PROCEDURE n_assign
LPARAMETERS vNewVal
*To do: 为 Assign 方法程序修改此例程
*事实上矩形的数量可能多于顶点数/2,可能几个矩形共用某个顶点
IF m.vnewval<>this.n
DIMENSION this.nindexs[m.vnewval]
ENDIF
THIS.n = m.vNewVal
ENDPROC
PROCEDURE getstruct
this.struct=''
IF ASCAN(this.nindexs,.f.)!=0
MESSAGEBOX('有未定义的索引!')
ELSE
FOR i=1 TO ALEN(this.nindexs)
this.struct=this.struct+BINTOC(this.nindexs[i],"4rs")
ENDFOR
ENDIF
RETURN this.struct
ENDPROC
PROCEDURE set
PARAMETERS ngroup,nindex1,nindex2,nindex3
DO CASE
CASE PARAMETERS()=3 && 说明是矩形
IF ngroup<=this.n
this.nindexs[ngroup*2-1]=nindex1
this.nindexs[ngroup*2]=nindex2
ELSE
RETURN .f.
ENDIF
CASE PARAMETERS()=4 && 说明是三角形
IF ngroup<=this.n
this.nindexs[ngroup*3-2]=nindex1
this.nindexs[ngroup*3-1]=nindex2
this.nindexs[ngroup*3]=nindex3
ELSE
RETURN .f.
ENDIF
OTHERWISE
RETURN .f.
ENDCASE
ENDPROC
ENDDEFINE
*
*-- EndDefine: gradient_rect
**************************************************
[此贴子已经被作者于2024-8-22 20:15编辑过]