Microsoft KB Archive/177260

= BUG: Execution of the REPORT FORM command sets the focus to the application in Visual FoxPro =

Article ID: 177260

Article Last Modified on 2/17/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q177260



SYMPTOMS
Executing a REPORT FORM command while an application is running minimized, sets focus to the application and restores the application's window. After the REPORT FORM command finishes executing, the application loses focus and continues running minimized.



RESOLUTION
Setting the visible property of the form to false before the REPORT FORM command is executed prevents the form from being restored and displayed on screen.

The following code snippet illustrates changing the visible property before and after a REPORT FORM command is encountered. In the example below, this code would appear in the Timer Event method of the timer object. ThisForm.Visible=.F.  REPORT FORM prtsrv FOR RECNO < 5 TO PRINT NOCONSOLE NOWAIT ThisForm.Visible=.T.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



MORE INFORMATION
When an application compiled with Visual FoxPro version 5.0 is running as a minimized background process and a REPORT FORM command is encountered, the application's window is restored from its minimized state and displayed on screen. After the REPORT FORM command has finished executing, the application's window is minimized and the application continues executing as a background process.

Applications compiled with Visual FoxPro version 3.0 that are running as a minimized background process remain minimized when a REPORT FORM command is encountered.

Steps to Reproduce Behavior
 Using Visual FoxPro version 5.0, create a new project called Prtsrv. Click Data, Databases and add the Testdata database from the VFP\Samples\Data folder. Click Documents, Reports and create a new quick report using the Customer table of the Testdata database. Save the report as Prtsrv.  Click Code, Programs and create a new program file named Prtsrv with the following code: PUBLIC rollcounter rollcounter=0 DO FORM prtsrv READ EVENTS

_SCREEN.WINDOWSTATE=2 _SCREEN.VISIBLE=.T.     _SCREEN.SHOW ZOOM WINDOW SCREEN MAX  Set Prtsrv.prg as the main program file.  Click Documents, Forms and create a new form called Prtsrv with the following properties: AutoCenter = .T.     Height     = 130 ShowWindow = 2 Width     = 192 </li>  In the form's Activate event, add the following code: _SCREEN.WINDOWSTATE=1 _SCREEN.VISIBLE=.f.     HIDE WINDOW SCREEN thiswin=WONTOP ZOOM WINDOW &thiswin MIN </li>  Add a Timer control to the form with the following properties: Interval=3000 </li>  Add the following code to the Timer Event method of the timer object: rollcounter=rollcounter+1 REPORT FORM prtsrv FOR RECNO < 5 TO PRINT NOCONSOLE NOWAIT IF rollcounter=3 ThisForm.Command1.Click ENDIF </li>  Add a command button to the form with the following code in the Click event of the command button: RELEASE THISFORM CLEAR EVENTS </li> From the Project Manager, build an executable file. Open Windows Explorer and double-click the executable file. At 30 second intervals, the Prtsrv form is restored and visible on screen.</li></ol>

Additional query words: VFoxWin form print visible timer

Keywords: kbnofix kbprb KB177260

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.