yform=createObject("ydegrade")
yform.show
read events
return
**************************************************
*-- Class Library: c:\ydegrade.vcx
**************************************************
**************************************************
*-- Class: ydegrade (c:\ydegrade.vcx)
*-- ParentClass: form
*-- BaseClass: form
*
DEFINE CLASS ydegrade AS form
Height = 473
Width = 739
ShowWindow = 2
DoCreate = .T.
ShowTips = .T.
AutoCenter = .T.
BorderStyle = 0
Caption = "Test de dégradés sur objet FORM"
Name = "Form1"
ADD OBJECT combo1 AS combobox WITH ;
RowSourceType = 1, ;
RowSource = "Gradient1,Gradient2,Gradient3,Gradient4,Gradient5,Gradient6,Gradient7,Gradient8,Gradient9,Gradient10,Gradient11,Gradient12,Gradient13,Gradient14,Gradient15", ;
Value = 1, ;
Height = 24, ;
Left = 612, ;
Style = 2, ;
ToolTipText = "Afficher le dégradé", ;
Top = 396, ;
Width = 100, ;
Name = "Combo1"
ADD OBJECT combo2 AS combobox WITH ;
RowSourceType = 1, ;
RowSource = "R,V,B,RV,RB,VB,RVB", ;
Value = 1, ;
Height = 24, ;
Left = 612, ;
Style = 2, ;
ToolTipText = "Sélectionner une couleur (RVB)", ;
Top = 372, ;
Width = 100, ;
Name = "Combo2"
ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
FontSize = 30, ;
WordWrap = .T., ;
Alignment = 2, ;
BackStyle = 0, ;
Caption = "TEST DE DEGRADE SUR FORMULAIRE VFP6.0 (sans appels API)", ;
Height = 137, ;
Left = 0, ;
Top = 9, ;
Width = 512, ;
Name = "Label1"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 204, ;
Left = 528, ;
Height = 27, ;
Width = 84, ;
Caption = "Command1", ;
Name = "Command1"
ADD OBJECT text1 AS textbox WITH ;
Value = "12345678910", ;
Height = 36, ;
Left = 624, ;
Top = 180, ;
Width = 108, ;
Name = "Text1"
ADD OBJECT edit1 AS editbox WITH ;
Height = 53, ;
Left = 516, ;
Top = 132, ;
Width = 100, ;
Value = "ABCDEFGHIJKLM", ;
Name = "Edit1"
ADD OBJECT combo3 AS combobox WITH ;
RowSourceType = 1, ;
RowSource = "1,2,3,4,5,6,7", ;
Height = 25, ;
Left = 636, ;
Top = 132, ;
Width = 72, ;
Name = "Combo3"
ADD OBJECT command2 AS commandbutton WITH ;
Top = 432, ;
Left = 612, ;
Height = 27, ;
Width = 84, ;
Caption = "Transparent", ;
Name = "Command2"
ADD OBJECT label2 AS label WITH ;
AutoSize = .T., ;
FontBold = .T., ;
FontSize = 14, ;
BackStyle = 0, ;
Caption = "X", ;
Height = 25, ;
Left = 708, ;
Top = 12, ;
Width = 15, ;
ForeColor = RGB(255,0,0), ;
Name = "Label2"
ADD OBJECT label3 AS label WITH ;
AutoSize = .T., ;
FontBold = .T., ;
FontSize = 14, ;
BackStyle = 0, ;
Caption = "-", ;
Height = 25, ;
Left = 684, ;
Top = 12, ;
Width = 8, ;
ForeColor = RGB(255,0,0), ;
Name = "Label3"
ADD OBJECT label4 AS label WITH ;
AutoSize = .T., ;
FontBold = .T., ;
FontSize = 11, ;
WordWrap = .T., ;
BackStyle = 0, ;
Caption = "Faire varier les couleurs et les types de gradients sur les combo.Le form redessine les conrôles sans les altérer grâce à <LOCKSCREEN>.Le form est déplaçable et peut être rendu transparent.", ;
Height = 92, ;
Left = 48, ;
Top = 360, ;
Width = 305, ;
ForeColor = RGB(255,0,0), ;
Name = "Label4"
PROCEDURE MouseDown
LPARAMETERS nButton, nShift, nXCoord, nYCoord
DECLARE INTEGER GetFocus IN WIN32API
lnHandle = GetFocus()
param1 = 274
param2 = 0xF012
DECLARE INTEGER ReleaseCapture IN WIN32API
DECLARE INTEGER SendMessage IN WIN32API INTEGER, INTEGER, INTEGER, INTEGER
bb=ReleaseCapture()
bb=SendMessage(lnHandle, param1, param2,0)
ENDPROC
PROCEDURE Activate
if tour=1
tour=0
thisform.resize
endi
ENDPROC
PROCEDURE Resize
*this.resizable1.adjustcontrols()
this.combo1.click
ENDPROC
PROCEDURE Init
thisform.titlebar=0
publi tour,w1,w2,w3
tour=1
w1=0
w2=255
w3=0
*messagebox("non finalisé")
*THISFORM.resizepubli tour,w1,w2,w3
ENDPROC
PROCEDURE Load
ENDPROC
PROCEDURE combo1.Click
grad=this.value
h=thisform.height
w=thisform.width
vv=w+h
thisform.cls
thisform.lockscreen=.t.
do case
*******************************
case grad=1 &&gradient Vertical
FOR i = 0 TO h
if w1>0
x1=w1*(1-i/h)
else
x1=0
endi
if w2>0
x2=w2*(1-i/h)
else
x2=0
endi
if w3>0
x3=w3*(1-i/h)
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(0, i, w,i)
endfor
*************************************
case grad=2 &&Gradient horizontal
FOR i = 0 TO w
if w1>0
x1=w1*(1-i/w)
else
x1=0
endi
if w2>0
x2=w2*(1-i/w)
else
x2=0
endi
if w3>0
x3=w3*(1-i/w)
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(i,0,i,h)
endfor
****************************
case grad=3 &&gradient diagonal left-->right
FOR i = 0 TO w+h
if w1>0
x1=w1*(1-i/(w+h))
else
x1=0
endi
if w2>0
x2=w2*(1-i/(w+h))
else
x2=0
endi
if w3>0
x3=w3*(1-i/(w+h))
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(0,i,i,0)
endfor
*****************************************
case grad=4 &&gradient bottom right-left
FOR i = w+h to 0 step -1
if w1>0
x1=w1*(i/(w+h))
else
x1=0
endi
if w2>0
x2=w2*(i/(w+h))
else
x2=0
endi
if w3>0
x3=w3*(i/(w+h))
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(i,0,0,i)
endfor
**************************************
case grad=5 &&gradient diagonal right-->left
FOR i = 0 TO w+h
if w1>0
x1=w1*(1-i/(w+h))
else
x1=0
endi
if w2>0
x2=w2*(1-i/(w+h))
else
x2=0
endi
if w3>0
x3=w3*(1-i/(w+h))
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(w-i,0,w,i)
endfor
****************************************
case grad=6 &&gradient diagonal right-->left
FOR i = 0 TO w+h
if w1>0
x1=w1*(i/(w+h))
else
x1=0
endi
if w2>0
x2=w2*(i/(w+h))
else
x2=0
endi
if w3>0
x3=w3*(i/(w+h))
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(w-i,0,w,i)
endfor
*************************************
case grad=7 && gradient perso 1
vv=(w+h)
FOR i =0 TO vv
if w1>0
x1=w1*(i/vv)
else
x1=0
endi
if w2>0
x2=w2*(i/vv)
else
x2=0
endi
if w3>0
x3=w3*(i/vv)
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(0,0,i,vv)
thisform.line(0,0,vv,i)
endfor
************************************
case grad=8 && gradient perso 2
vv=(w+h)
FOR i =0 to vv
if w1>0
x1=w1*(1-i/vv)
else
x1=0
endi
if w2>0
x2=w2*(1-i/vv)
else
x2=0
endi
if w3>0
x3=w3*(1-i/vv)
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(0,0,i,vv)
thisform.line(0,0,vv,i)
endfor
*************************************
case grad=9 && gradient perso 3
vv=(w+h)
FOR i =0 TO vv
if w1>0
x1=w1*(1-i/vv)
else
x1=0
endi
if w2>0
x2=w2*(1-i/vv)
else
x2=0
endi
if w3>0
x3=w3*(1-i/vv)
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(vv,0,i,i)
thisform.line(i,i,0,vv)
endfor
*********************************
case grad=10 && gradient perso 4
vv=(w+h)
FOR i =0 TO vv
if w1>0
x1=w1*(i/vv)
else
x1=0
endi
if w2>0
x2=w2*(i/vv)
else
x2=0
endi
if w3>0
x3=w3*(i/vv)
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
ThisForm.Line(i,i,vv,0)
thisform.line(0,vv,i,i)
endfor
***********************************
case grad=11
for i=0 to vv
if w1>0
x1=w1*(i/(w+h))
else
x1=0
endi
if w2>0
x2=w2*(i/(w+h))
else
x2=0
endi
if w3>0
x3=w3*(i/(w+h))
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
thisform.line(0,0,i,vv)
thisform.line(vv,i,0,0)
endfor
**************************************
case grad=12
for i=0 to vv
if w1>0
x1=w1*(i/(w+h))
else
x1=0
endi
if w2>0
x2=w2*(i/(w+h))
else
x2=0
endi
if w3>0
x3=w3*(i/(w+h))
else
x3=0
endi
ThisForm.ForeColor = RGB(x1,x2,x3)
&&2
thisform.line(w/2,h/2,i,vv)
thisform.line(vv,i,w/2,h/2)
thisform.line(w/2,h/2,-i,-vv)
thisform.line(-vv,-i,w/2,h/2)
thisform.line(w/2,h/2,-i,vv)
thisform.line(vv,-i,w/2,h/2)
thisform.line(w/2,h/2,i,-vv)
thisform.line(-vv,i,w/2,h/2)
endfor
**************************************
case grad=13
for i=0 to vv
if w1>0
x1=w1*(i/(w+h))
else
x1=0
endi
if w2>0
x2=w2*(i/(w+h))
else
x2=0
endi
if w3>0
x3=w3*(i/(w+h))
else
x3=0
endi
&&3
ThisForm.ForeColor = RGB(x1,x2,x3)
thisform.line(w,h,i,0)
thisform.line(0,i,w,h)
endfor
***********************************
case grad= 14
for i=0 to vv
if w1>0
x1=w1*(i/(w+h))
else
x1=0
endi
if w2>0
x2=w2*(i/(w+h))
else
x2=0
endi
if w3>0
x3=w3*(i/(w+h))
else
x3=0
endi
&&4
ThisForm.ForeColor = RGB(x1,x2,x3)
thisform.line(h,w,i,0)
thisform.line(0,i,w,h)
endfor
***********************************************
case grad= 15
for i=0 to vv
if w1>0
x1=w1*(i/(w+h))
else
x1=0
endi
if w2>0
x2=w2*(i/(w+h))
else
x2=0
endi
if w3>0
x3=w3*(i/(w+h))
else
x3=0
endi
&&5
ThisForm.ForeColor = RGB(x1,x2,x3)
thisform.line(vv/2,vv/2,i,0)
thisform.line(0,i,vv/2,vv/2)
endfor
************************************************************************************************
endcase
if thisform.label1.forecolor<=16700000
thisform.label1.forecolor=thisform.label1.forecolor+150000
else
thisform.label1.forecolor=0
endi
thisform.lockscreen=.f.
ENDPROC
PROCEDURE combo2.Click
x=this.value
do case
case x=1 &&R
w1=255
w2=0
w3=0
case x=2 && V
w1=0
w2=255
w3=0
case x=3 &&B
w1=0
w2=0
w3=255
************
case x=4 &&RV
w1=255
w2=255
w3=0
case x=5 &&RB
w1=255
w2=0
w3=255
case x=6 &&VB
w1=0
w2=255
w3=255
case x=7 &&RVB
W1=255
w2=255
w3=255
endcase
thisform.combo1.click
ENDPROC
PROCEDURE command2.Click
#DEFINE LWA_COLORKEY 1
#DEFINE LWA_ALPHA 2
#DEFINE GWL_EXSTYLE -20
#DEFINE WS_EX_LAYERED 0x80000
DECLARE INTEGER GetActiveWindow IN user32
yHWnd=getActiveWindow()
DECLARE INTEGER GetWindowLong IN user32;
INTEGER hWnd, INTEGER nIndex
DECLARE INTEGER SetWindowLong IN user32;
INTEGER hWnd, INTEGER nIndex, INTEGER dwNewLong
DECLARE INTEGER SetLayeredWindowAttributes IN user32;
INTEGER hwnd, INTEGER crKey,;
SHORT bAlpha, INTEGER dwFlags
do case
case this.caption="Transparent"
this.caption="NTransparent"
transpa=.t.
****************************************************
&&transparence
LOCAL nExStyle, nRgb, nAlpha, nFlags
yHWnd=getActiveWindow()
nExStyle = GetWindowLong(yHWnd, GWL_EXSTYLE)
nExStyle = BITOR(nExStyle, WS_EX_LAYERED)
= SetWindowLong(yHWnd, GWL_EXSTYLE, nExStyle)
nRgb=rgb(255,0,255)
nAlpha=100
nFlags=2
= SetLayeredWindowAttributes(yHWnd, m.nRgb, m.nAlpha, m.nFlags)
*******************************************************************
case this.caption="NTransparent"
this.caption="Transparent"
transpa=.f.
&&PROCEDURE command2.ClearTransparentMode
LOCAL nExStyle
nExStyle = GetWindowLong(yHWnd, GWL_EXSTYLE)
nExStyle = BITXOR(nExStyle, WS_EX_LAYERED)
= SetWindowLong(yHWnd, GWL_EXSTYLE, nExStyle)
endcase
ENDPROC
PROCEDURE label2.Click
clea
thisform.release
ENDPROC
PROCEDURE label3.Click
thisform.windowstate=1
ENDPROC
PROCEDURE DESTROY
clea events
ENDPROC
ENDDEFINE
*
*-- EndDefine: ydegrade
**************************************************
|
Sans API?
DECLARE INTEGER GetWindowLong
DECLARE INTEGER SetWindowLong
DECLARE INTEGER SetLayeredWindowAttributes
DECLARE INTEGER ReleaseCapture
DECLARE INTEGER SendMessage
Au moins 6, non?