Hi all,
I am currently on PB 2021 Build 1506, and am trying to add Microsoft Word Spell and Grammar check into our Application. I am able to get the SpellCheck to work, however most of the time the window popups behind everything and make it often look like the Application has frozen unless you know to ALT+Tab to find the window. We currently want to make the Microsoft Word invisible expect for the Spell and Grammar Window. I did find some old post about this very same issue, using SetForegroundWindow((ll_Hwnd)) , SetActiveWindow(ll_Hwnd) , BringWindowToTop(ll_Hwnd) to bring the window up. My issue right now is since Powerbuilder waits for the Spellcheck window to close before running the next line of code, is there a way to trigger the bringtotop function while Powerbuilder is waiting? Or if anyone has a better solution please let me know. I will post my code for reference
Your help is much appreciated!
Here is code for grammar check execution:
string as_text
Long ll_RC
// Connect to Word and do a spell-check
lole_Spell = CREATE OleObject
ll_RC = lole_Spell.ConnectToNewObject( 'Word.Application' )
IF ll_RC <> 0 THEN
DESTROY lole_Spell
END IF
as_text = sle_1.text
lole_Spell.Application.Visible = false
lole_Spell.Application.WindowState = 2
lole_Spell.Documents.Add()
lole_Spell.Selection.TypeText( as_Text )
lole_Spell.Selection.HomeKey()
lole_Spell.Selection.MoveStart()
lole_Spell.ActiveDocument.CheckGrammar()
lole_Spell.ActiveDocument.Select()
as_Text = lole_Spell.Selection.Text
lole_Spell.ActiveDocument.Close( False )
lole_Spell.Application.Quit
lole_Spell.DisconnectObject()
DESTROY lole_Spell
sle_1.text = as_text
Code for BringToTop of Window
string ls_null
SetNull (ls_Null)
// Get handle of Spell Check window
ll_Hwnd = FindWindowA ( ls_Null, 'Spell and Grammar Check')
SetForegroundWindow((ll_Hwnd))
SetActiveWindow(ll_Hwnd)
BringWindowToTop(ll_Hwnd)