Article ID: 195404
Article Last Modified on 7/1/2004
***** Begin code sample *****
DECLARE LONG FindWindowA IN WIN32API ;
STRING class, ;
STRING title
DECLARE SetWindowPos IN WIN32API ;
LONG HWND, ;
LONG hwndafter, ;
LONG x, ;
LONG y, ;
LONG cx, ;
LONG cy, ;
LONG flags
oWord = CREATEOBJECT("Word.Application" )
oWord.Documents.Add
* Check background printing.
lBackground = oWord.Options.PrintBackground()
IF lBackground
oWord.Options.PrintBackground = .F. && Turn off.
ENDIF
dlg = oWord.Dialogs(88) && Open Print dialog box in Word.
dlg.SHOW
* Get the window handle to Word 97.
wordhandle = 0
DO WHILE wordhandle = 0
* Pass the class name for Word 97 "OpusApp" to FindWindowA
wordhandle = FindWindowA("OpusApp", NULL)
ENDDO
* Variables used in the SetWindowPos API.
swp_nosize = 1
swp_nomove = 2
hwnd_topmost = -1
hwnd_notopmost = -2
* Call SetWindowPos to make the print dialog stay on top.
lretval = 0
lretval = SetWindowPos(wordhandle,hwnd_topmost,;
0,0,0,0,swp_nosize+swp_nomove)
* Turn on background printing if it was on before.
IF lBackground
oWord.Options.Printbackground = !oWord.Options.Printbackground
ENDIF
oWord.Quit
RETURN
***** End code sample *****
NOTE: On some machines, Word displays briefly and disappears whenever the
print dialog box closes.
Keywords: kbhowto kbapi KB195404