Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word and Spell Checking Focus Issues
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2003 Server
Divers
Thread ID:
01305615
Message ID:
01306950
Vues:
10
>No that doesn't work. The problem is that the modal COM call blocks even a timer from firing. While VFP is in a COM call the Windows message queue mostly (with the exception of refresh events of some sort I believe) stops.
>
>No Fox code runs... even in the 'background' since the VFP main thread is effectively tied up by the COM call.
>
>This may work with FoxPro modal windows, but it won't with COM objects.
>
>+++ Rick ---
>

Rick,

This works for me:

1. Create a separate VFP application like c:\ypushwindow.exe having code like this:
*Procedure yPushWindow
lParameter pWindowTitle, pSendKeys, pnTimeOut, pnCheckInterval

if version(2)=0
	_screen.left=-5000
endif
		
do case
case type("pnCheckInterval")="N"
case type("pnCheckInterval")="C" and isdigit(pnCheckInterval)
	pnCheckInterval=val(pnCheckInterval)
case type("pnTimeOut")="C" and " "$ALLTRIM(pnTimeOut)
	pnCheckInterval=val(;
		SUBSTR(ALLTRIM(pnTimeOut),rAT(" ",ALLTRIM(pnTimeout))+1))
otherwise
	pnCheckInterval=1000		&& 1 sec
endcase

do case
case type("pnTimeOut")="N"
case type("pnTimeOut")="C" and isdigit(pnTimeOut)
	pnTimeOut=val(pnTimeOut)
otherwise
	pnTimeOut=60000		&& 1 min
endcase

IF TYPE("pSendKeys") #"C"
	pSendKeys="{ENTER}"
ENDIF
IF TYPE("pWindowTitle") #"C"
	pWindowTitle="Window Title"
ENDIF

PRIVATE oShell, LtimerOL, Starttime
starttime=SECONDS()

oShell = CreateObject("WScript.Shell")
LtimerOL=createobject("PushWindow",pWindowTitle, pSendKeys,;
						pnTimeOut,pnCheckInterval)

read events

LtimerOL=.NUll.
oShell=.Null.

Return
*----------------------------------------
Define class PushWindow as Timer
	Interval 	= 1000
	Name 		= "PushWindow"
	timeoutdef 	= 60000
	WindowTitle = "Command Prompt"
	SendKeys = "exit{ENTER}"
	
	Procedure INIT
		Lparameter pWindowTitle, pSendKeys, pnTimeOut, pInterval
		if type("pWindowTitle")="C" AND NOT EMPTY(pWindowTitle)
			this.WindowTitle=pWindowTitle
		endif
		if type("pSendKeys")="C" AND NOT EMPTY(pSendKeys)
			this.SendKeys=pSendKeys
			this.SendKeys=pSendKeys
		endif
		if type("pnTimeOut")="N"
			this.timeoutdef=pnTimeOut
		endif
		if type("pInterval")="N"
			this.Interval=pInterval
		ENDIF
		
	endproc
	Procedure Timer
		WAIT wind NOWAIT "Looking for Window Title "+this.WindowTitle
		
		if oShell.AppActivate(this.WindowTitle)
			oShell.SendKeys(this.SendKeys)
		ENDIF
		
		IF SECONDS()-starttime>=this.timeoutdef/1000
			clear events
		ENDIF
	Endproc
Enddefine 
2. Example of Main application calling the utility above:
CLEAR

lcText="Plain Text - simple assign and retrieve, wrongword goes here"

LOCAL loWord as Word.Application
   loWord = CREATEOBJECT("Word.Application")
   loWord.Visible = .t.
   = loWord.Documents.Add(,,1,.T.)

   * call the timer, and accept ALL recommended spellings (ALT+l)
   oShell = CreateObject("WScript.Shell")
    oShell.Run([c:\ypushwindow "Spelling: "  "%l" 3000])

   WITH loWord.activedocument
	.Content.Text = lcText
	.CheckSpelling()

          lcText1 = .Content.Text
   
        ?lcText  && original text
        ?lcText1   && correct spelling   
   ENDWITH
   
   loWord.Quit(.f.)
   loWord = .null.
   
   oShell=.null.
Regards
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform