Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding code to events programmatically
Message
De
09/02/2016 14:48:18
 
 
À
09/02/2016 13:52:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01631115
Message ID:
01631141
Vues:
53
There is many solutions to your problem:

1-the form designer can of course accept a listbox added manually.then configure all wanted
properties,methods, events in the VFP PEM sheet (fired with form designer).

2-if you want to work with a single prg save this form as a class .Run the class explorer and
point to the class saved and then can obtain the class code...add the call from the header prg.
this works as well if there is not container(s) on form.

3-use Bindevent() function ( recquire vfp9)
can bind any vfp object on the form (property,method,event) as the first syntax described in bindevent()
help (foxhelp)
BINDEVENT(oEventSource, cEvent, oEventHandler, cDelegate [, nFlags])

4-write a class for your listbox(properties, methods, events) and add it to your form programmatly
by AddObject & visible=.t. or drop it manually form the design mode onto your form.

for ex. to bind a click and the rightclick on your listbox this is a working sample (from your code):
(you can write in this code any valid event with bindevent)
Publi yform
yform=Newobject("asup")
yform.Show
Read Events
Retu
*
Define Class asup As Form
    Caption = "Click or rightclick on listbox"
    Name = "Form1"

    Procedure myevt
        Sele ycurs
        _Cliptext=company
        Messagebox("company= "+company,0+32+4096,'added to clipboard',1000)
    Endproc

    Procedure myevt1
        _Cliptext=fax
        Messagebox("fax= "+fax,0+32+4096,"added to clipboard",1000)
    Endproc

    Procedure Destroy
        Clea Event
    Endproc

    Procedure Init
        Sele company,fax From Home(1)+"samples\data\customer" Into Cursor ycurs
        Thisform.ShowTips=.T.
        Thisform.AddObject('oList1','ListBox')
        With Thisform.oList1
            .RowSource = "ycurs"      &&"oldjobs"
            .RowSourceType=2
            .Visible=.T.
            .Top=186
            .Left=350
            .Width=250
            .ColumnCount=2
            .ColumnWidths='150,150'
            .SelectedItemBackColor=Rgb(70,60,50)
            .SelectedItemForeColor=Rgb(10,191,160)
            .SpecialEffect=1
            .ItemBackColor=Rgb(40,40,40)
            .ItemForeColor=Rgb(255,204,153)
            * .BorderStyle = 1  &&inexistant property
            .BorderColor=Rgb(235,132,0)

            &&added for test
            .ItemTips=.T.
            .Move(10,10)
            .Anchor=15
            .MousePointer=15

        Endwith
        With Thisform
            .Width=640
            .Height=480
        Endwith
        Bindevent(This.oList1,"click",Thisform,"myevt")
        Bindevent(This.oList1,"rightclick",Thisform,"myevt1")

    Endproc


Enddefine
*
*-- EndDefine: asup
***********************
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform