Problem with GotFocus and Shell

epsharp

Member
Licensed User
Longtime User
I have in a very large database system where a shell command opens two duplicate programs. To avoid uploading a ton of stuff, the attached duplicates my problem.

In my program, I use a textbox superimposed on a combobox that is loaded by a database table for updating, but clicking the textbox takes you to the database table update program.

No matter what I have tried, I always get two programs running.:sign0085:

Regards,

Ed Sharp
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
A possible solution is too use a timer with a small interval to run Shell:
B4X:
Sub Globals
    'Declare the global variables here.
End Sub

Sub App_Start
    Form1.Show
    AddTimer("timer1")
    timer1.interval = 10
End Sub

Sub tCalc_GotFocus
    bExit.Focus
    Timer1.Enabled = True
End Sub
Sub Timer1_Tick
    Timer1.Enabled = False
    Shell("calc.exe","")
End Sub

Sub bExit_Click
    AppClose
End Sub
 

epsharp

Member
Licensed User
Longtime User
Thank you Erel for your assistance.

Having previous Table Selection Focus problems, I had already tried the "Timer" solution . My program already had a timer running but with a 1000 interval. Unfortunately, I used a switch to call a "new" focus routine instead of simply placing the Shell command in the Timer Tick and this still produced duplicate programs.

Using your code as Timer2 worked perfectly.

Thanks again.

Ed Sharp