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

Forum AtoutFox : Re: dynamic current control   

Sujet

rss Flux RSS des derniers messages

Vous devez vous identifier pour pouvoir poser une question ou répondre.

lun. 22 janvier 2018, 18h31
eddymaue
atoutfox.public.association

Re: dynamic current control

il reste un p'tit bémol lorsqu'on click sur un bouton le caption prend
la valeur du click antérieur.

ex: click sur le bouton record 1 suivit du 2

a part cela cet excellent ...

Public oform
oform=Newobject("madagascar")
oform.Show
Return
*
Define Class madagascar As Form
  Top = 17
  Left = 130
  Height = 459
  Width = 808
  Caption = "Form1"
  Name = "Form1"

  Add Object grid1 As Grid With ;
    Anchor = 15, ;
    Height = 457, ;
    Left = 0, ;
    Top = 0, ;
    Width = 805, ;
    Name = "Grid1"

  Procedure showcaption
    Lparameters toButton, xtext
    toButton.Caption =Allt(xtext)
*!*      toButton.BackColor=Iif(Mod(Recno(),2)=0,Rgb(0,255,0),Rgb(255,120,140))
    toButton.BackColor=Iif(ycurs.title="Owner
"
,Rgb(0,255,0),Rgb(255,120,140))
    Retu
  Endproc

  Procedure Load
    Sele * From Home(1)+"samples\data\customer" Into Cursor ycurs
  Endproc

  Procedure grid1.Init
    With This
      .RecordSource="ycurs"
      .RecordSourceType=1
      .DeleteMark=.F.
      .RowHeight=20
      .GridLines=0
      .SetAll("fontbold",.T.,"header")
      oCol=.column3
      With oCol
        Try
          .AddObject("command1","commandbutton")
        Catch
        Endtry
        .CurrentControl="command1"
        .Sparse=.F.
        With .command1
          .Caption=""
          .BackColor=Rgb(0,255,0)
          .SpecialEffect=0
          .FontSize=10
          .FontName="courier new"
          .MousePointer=15
          .Visible=.T.
        Endwith
        .DynamicFontBold =
'thisform.showCaption(thisform.grid1.column3.command1,ycurs.contact)'
&&expression must be valid and evaluated at runtime otherwise error!
      Endwith
      Bindevent(oCol.command1,"mousedown",Thisform,"my")
      .Refresh
    Endwith
  Endproc

  Procedure my
    Lparameters nButton, nShift, nXCoord, nYCoord
    *--- aevent create an array laEvents
    Aevents( myArray, 0)
    *--- reference the calling object
    loObject = myArray[1]
    Messagebox("this is:"+loObject.Caption,0+32+4096,'',1300)
  Endproc

Enddefine
[vdp/]

 :
Bonjour
Tu peux utiliser une propriété "trompeuse/fake" telle que dynamicFontbold
pour remplir tes bouttons ajoutés à une colonne du grid avec les valeurs
réelles d'un champ. essaie ce bout de code:

[vfp]
PUBLIC oform
oform=NEWOBJECT("madagascar")
oform.Show
RETURN
*

DEFINE CLASS madagascar AS form
Top = 17
Left = 130
Height = 459
Width = 808
Caption = "Form1"
Name = "Form1"

ADD OBJECT grid1 AS grid WITH ;
Anchor = 15, ;
Height = 457, ;
Left = 0, ;
Top = 0, ;
Width = 805, ;
Name = "Grid1"

PROCEDURE showcaption
Lparameters toButton, xtext
toButton.Caption =allt(xtext)
toButton.backcolor=iif(mod(recno(),2)=0,rgb(0,255,0),rgb(255,120,140))
retu
ENDPROC

PROCEDURE Load
sele * from home(1)+"samples\data\customer" into cursor ycurs
ENDPROC

PROCEDURE grid1.Init
with this
.recordsource="ycurs"
.recordsourcetype=1
.deletemark=.f.
.rowheight=20
.gridlines=0
.setall("fontbold",.t.,"header")
oCol=.column3
with ocol
try
.addobject("command1","commandbutton")
catch
endtry
.currentcontrol="command1"
.sparse=.f.
with .command1
.caption=""
.backcolor=rgb(0,255,0)
.specialEffect=2
.fontsize=10
.fontname="courier new"
.mousepointer=15
.visible=.t.
endwith
.DynamicFontBold =
'
thisform.showCaption(thisform.grid1.column3.command1,ycurs.contact)'
&&expression must be valid and evaluated at runtime otherwise error!
endwith bindevent(ocol.command1,"mousedown",thisform,"my") .refresh
endwith
ENDPROC

procedure my
LPARAMETERS nButton, nShift, nXCoord, nYCoord
*--- aevent create an array laEvents

Aevents( myArray, 0)
*--- reference the calling object

loObject = myArray[1]
messagebox("this is:"+loObject.caption,0+32+4096,'
',1300)
endproc

ENDDEFINE
*

*-- EndDefine: madagascar



--
a+ Eddy
L'incompréhensible se réalise toujour avant le compréhensible parce que
tout simplement on ne l'a pas encore assimilé
Permalink : http://www.atoutfox.org/nntp.asp?ID=0000018809
20 088 messages dans le forum • Liste complète des messages

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