Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer Event on fire bring back form to front 1

Status
Not open for further replies.

Ris1

Programmer
Dec 8, 2017
26
IN
I have a form which refreshes grid data in 1 min. using timer. On drilldown another form is opened showing details of that record.
Now, while viewing 2 form if timer event of first form is fired then it comes above 2nd form. How can I avoid such behaviour . I want timer to just update data in that grid but that form should not come in front of any other form opened.
 
Well, Disable the timer on form.deactivate and enable it on activate, that would be one simple solution.

I'm not sure you could Refresh() without that causing to let focus go to the grid, but the other way around, if you set focus to the grid, you sure cause the form to become active, too. So avoid that.

Bye, Olaf.
 
The way I would do this would be to NOT refresh the grid. In your timer, update the grid's underlying data, that is, the cursor or table that is used to populate the grid, but don't refresh to grid or the form. If the user is working in Form 1, that won't be a problem because the grid will show the fresh data as soon as it receives focus. If you are working on Form 2, nothing will appear to happen, but when you close Form 2, focus will return to Form 1 and the grid will automatically be refreshed.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I think a difference is still possible in Refresh() vs Setfocus(), so you might even be able to show new data in the form if it's inactive and only partially showing.

But anyway, just requerying data is enough and if you only aim for the form becoming active again, that's easiest to do when disabling/enabling the timer as it is programmed currently. A Timer has an Enabled property, and that's all you toggle.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top