Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SetFocus Error...
Message
 
To
26/08/1999 08:56:01
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00257837
Message ID:
00258203
Views:
18
When I need to call setfocus() or any any other method or command that can't be executed directly, I use the following technique:

Pass the command to a Timer, that indirectly execute my command.

Here is a sample procedure that:

- Accept a command string as parameter
- Create a timer
- Execute the command
- Release the timer.

Examples: ExecCmd('DO FORM Form1 Name cFrm1')
ExecCmd('cFrm1.Texbox1.SetFocus()')
LParam pcExecCmd

Local oCmd
oCmd = CreateObject('clstimer')
oCmd.DoCmd(pcExecCmd)
Release oCmd

ENDPROC

DEFINE CLASS clstimer AS timer

    Enabled = .F.
    Interval = 55
    *-- command to execute in the timer event.
    timercmd = (Space(0))
    Name = "clstimer"
    *-- Indicate completion of the command.
    cmddone = .F.

    *-- Set the command, and activate the timer.
    PROCEDURE docmd
        LPARAM pctimercmd

        this.cmddone = .f.
        this.timercmd = pctimercmd
        this.enabled = .t.
        Do While !this.cmddone
            DoEvents
        EndDo
    ENDPROC

    PROCEDURE Timer
        this.enabled = .f.
        Local ccmd
        ccmd = this.timercmd
        If vartype(ccmd)='C' .and. !Empty(ccmd)
            &ccmd
        Endif
        this.cmddone = .t.
    ENDPROC

ENDDEFINE

Just an opinion... Not a fact.
Previous
Reply
Map
View

Click here to load this message in the networking platform