on 10-21-2015 11:26 AM
Hi Everyone,
I am using PB11.1 build 8123. I want to add a functionality to checking the spelling. I write below code but I have a problem that MS WORD open as minimized state. I want this at front of user. Please suggest.
string ls_current_text
ls_current_text=mle_1.text
If ls_current_text = "" then Return
If Clipboard(ls_current_text) = "" Then RETURN
OleObject myOleObject
myOleObject = CREATE OLEObject
If myOleObject.ConnectToNewObject("word.application") <> 0 Then Return
myoleobject.Application.Visible = True
myoleobject.Application.WindowState = 2
myoleobject.Application.Documents.Add.Content.Paste
myoleobject.Application.ActiveDocument.CheckSpelling
myoleobject.Application.ActiveDocument.Content.Copy
myoleobject.ActiveDocument.Close(0)
myoleobject.Application.Quit
myOleObject.disconnectobject()
Destroy myOleObject
messagebox("Information", "The spelling and grammer check is complete.")
mle_1.text=Clipboard(ls_current_text)
Hello Vikrant,
Try to use the FindWindow and SetForegroundWindow APIs as a possible workaround:
unsignedlong hwnd
hwnd = FindWindow ( 0, "Document1")
if hwnd > 0 then
SetForegroundWindow ( hwnd)
end if
Obviously, you need to declare these APIs as local or global external functions before using them.
P.S.: Please use the SAP PowerBuilder Developer Center to post your questions as this forum is more active than the SAP PowerBuilder
HTH,
Jacob
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jacob,
Thanks for your suggestion. I have tried to implemented above functions but it is not use full for me. after debug, i found that hwnd = 0. I am not able to understand the problem. please suggest.
I use below code:-
Global external function
------------------------------------------
PUBLIC FUNCTION unsignedlong FindWindow (long &
classname, string windowname) LIBRARY "user32.dll" &
ALIAS FOR FindWindowW
PUBLIC FUNCTION int SetForegroundWindow (unsignedlong &
hwnd) LIBRARY "user32.dll" ALIAS FOR SetForegroundWindowW
code
------------
string ls_current_text
ls_current_text=mle_1.text
If ls_current_text = "" then Return
If Clipboard(ls_current_text) = "" Then RETURN
OleObject myOleObject
myOleObject = CREATE OLEObject
If myOleObject.ConnectToNewObject("word.application") <> 0 Then Return
unsignedlong hwnd
hwnd = FindWindow ( 0, "Document1")
myoleobject.Application.Visible = True
myoleobject.Application.WindowState = 1
myoleobject.Application.Documents.Add.Content.Paste
if hwnd = 0 then
//
else
SetForegroundWindow ( hwnd)
end if
myoleobject.Application.ActiveDocument.CheckSpelling
myoleobject.Application.ActiveDocument.Content.Copy
myoleobject.ActiveDocument.Close(0)
myoleobject.Application.Quit
myOleObject.disconnectobject()
Destroy myOleObject
messagebox("Information", "The spelling and grammer check is complete.")
mle_1.text=Clipboard(ls_current_text)
Thanks,
Vikrant
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.