Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Display and Refresh a Form without taking focus
Message
From
25/04/2011 22:26:55
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
 
 
To
25/04/2011 20:56:11
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01508151
Message ID:
01508349
Views:
48
I change my program so form1.timer calls form2.refresh(). Form2 refresh has the following code.
* form 1 code timer code
form1.refresh() 

*form 2 load() 
DODEFAULT()
CREATE CURSOR cr_test (id i(4), cname c(30), ctest c(30))

INSERT INTO cr_test VALUES (1,'test1','test11')
INSERT INTO cr_test VALUES (1,'test2','test21')
INSERT INTO cr_test VALUES (1,'test3','test31')
INSERT INTO cr_test VALUES (1,'test4','test41')

* form 2 refresh code
this.Print('refresh: ')
select cr_test 
TRY 
	SKIP 
	IF EOF() 
		GO TOP 
	ENDIF 
CATCH TO aaa
	WAIT WINDOW aaa.message NOWAIT 
ENDTRY 
DODEFAULT()
</pre

Form 1 did not loose focus.  

 
>It grabs focus as soon as I start deleting records or moving the record position in the underlying table of the grid on form 2 (from a prg)...
>
>
>>I am using private data sessions and I added a method to my form called updatecol(tccolname,tcvalue).  Still focus stays where it belongs.  This goes with my strategy of having my own business object that would do the replace from form1 and the just call refresh to form2.  I am not sure if that is what you are doing.  Does your form2 get focus if you just call refresh()?
>>
>><pre>
>>FOR EACH xx IN _vfp.Forms
>>	IF ! xx.name = thisform.Name
>>                xx.upatecol('cnotes','test1') 
>>		xx.refresh() 
>>	ENDIF 
>>NEXT 
>>
>>
>>
>>
>>>does it grab focus when you update the underlaying table of the grid?
>>>
>>>>I ran a little test using 4 basic forms with a grid and a command button. This code was in the command button and I don't see focus changing at all
>>>>
>>>>
>>>>FOR EACH xx IN _vfp.Forms
>>>>	IF ! xx.name = thisform.Name
>>>>		xx.refresh() 
>>>>	ENDIF 
>>>>NEXT 
>>>>
>>>>
>>>>I was not sure how you were calling refresh but this seemed to be a nice indirect way to do it.
>>>>
>>>>Hope this helps.
>>>>
>>>>
>>>>>>>>>>Is there a way to do this? I have data coming in that gets displayed in a form that is open (one of many) but I do not want it to take focus away from the other forms in an app that are open unless the user intentionally clicks on the form. Whenever I refresh the form (it has two grids of data), it takes focus.
>>>>>>>>>
>>>>>>>>>Are you sure there's no .SetFocus() in the code? Also, when that form is deactivated, was the focus on the grid? Refreshing a grid which has the focus, while busy elsewhere, has some weird side effects sometimes (i.e. I have no clue what it may do, but moving focus off it may help).
>>>>>>>>
>>>>>>>>Pretty sure. I searched through all levels for any setfocus and activate.... I found a way to set focus back to the form that was open and had focus when the other form launches or refreshes the grids. I would rather the updating and efresh of the grid didn't grab focus at all...
>>>>>>>
>>>>>>>Couldn't it be that you have a setfocus in the grid's superclass on refresh? I know, it wouldn't make sense, but a refresh alone should not activate the form. I have a similar form also with a grid that works well on refresh.
>>>>>>
>>>>>> I resolved this in the activate of the form...
>>>>>
>>>>>All, I would still prefer to prevent the form from grabbing focus at all unless the user clicks on it. Right now I am setting focus to the calling form in the activate of form #2 (the called form with the grids), but still focus goes away from form #1 briefly and then there is the issue of cursor position when it goes back and if the user has moved to another control (I catch currentcontrol when the 2nd form loads but may have changed before it gets set back)....
>>>>>
>>>>>any ideas on how to make a form not take focus away from where it is called from unless the user clicks anywhere on the form after it loads?
Previous
Reply
Map
View

Click here to load this message in the networking platform