ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

TEST DE DIFFERENTS TYPES DE DEGRADES SUR UN FORM SANS API windows   



L'auteur

ybenam
Algérie Algérie
Membre Simple
# 0000002080
enregistré le 21/04/2008


Fiche personnelle


Note des membres
pas de note

Contributions > 02 - SCX : Formulaires

TEST DE DIFFERENTS TYPES DE DEGRADES SUR UN FORM SANS API windows
# 0000000576
ajouté le 20/05/2008 15:35:24 et modifié le 20/05/2008
consulté 7453 fois
Niveau initié

Version(s) Foxpro :
VFP 6.0

Description
Créer différents types de dégradés sur un form sans altérer les contrôles et en les raffraîchissant.J'ai remarqué qu'avec la commande les contrôles sont convenablement redessinés. Lockscren :Détermine si un formulaire traite par lots la totalité des changements apportés aux paramètres de propriété du formulaire et des objets qu'il contient. Disponible pendant la création et l'exécution. Admirer les différents types de gradients avec les différentes couleurs et même le choix aléatoire de couleur pour écrire sur le label de titre avec des commandes purement Visual Foxpro et sans appel d'API (GDI+ pourrait elle faire mieux ?). Le form est déplaçable (voir le code mouseDown) et peut être rendu transparent (en passant obligatoirement par les API). benameuryousfi1@gmail.com :
Code source :
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 INTEGERINTEGERINTEGERINTEGER
    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 hWndINTEGER nIndex

        DECLARE INTEGER SetWindowLong IN user32;
            INTEGER hWndINTEGER nIndex, INTEGER dwNewLong

        DECLARE INTEGER SetLayeredWindowAttributes IN user32;
            INTEGER hwndINTEGER 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
**************************************************

Commentaires
le 20/05/2008, Mike Gagnon a écrit :
Sans API?
DECLARE INTEGER GetWindowLong
DECLARE INTEGER SetWindowLong
DECLARE INTEGER SetLayeredWindowAttributes
DECLARE INTEGER ReleaseCapture
DECLARE INTEGER SendMessage

Au moins 6, non?

le 22/05/2008, ybenam a écrit :
Les API que vous avez mentionné n'entrent pas dans l'élaboration des gradients mais uniquement pour faire bouger le form sur l'écran averc la souris(évènement MouseDown) et pour rendre le form transparent-circonstance inépendante du sujet !
Merci pour le feed back.
L'objet de mes posts est que cela profite à tous les foxeurs qu'ils puissent enrichir la base Foxpro qui est en retard dans beaucoup de domaines de la programmation orientée objet principalement,il faut le dire.
A tout seigneur tout honneur, je donne tout ce que j'ai....sans restriction...


Publicité

Les pubs en cours :


www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2024.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3