Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automated printing of Word doc files from Wordview
Message
From
09/01/1999 21:04:40
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00174307
Message ID:
00174434
Views:
25
Christof,

Thanks! This may just be what I'm looking for.

By the way, do you (or anyone else) know what the value should be for stuffing a CTRL+V (for pasting from the clipboard) via the API call:
declare integer keybd_event in win32api integer, integer, integer, integer
vk_key=??
=keybd_event(vk_key,0,0,0)

Thanks for your input.

Mike

>Hi Michael,
>
>>Essentially, I'm looking for a way to distribute Doc files and automate the printing for end users who don't have Word.
>
>This is some demo code from my API session last DevCon. It remote controls Notepad in order to print a DOC file. Be aware that this is just a demo, but maybe it gives you some ideas.
>
>* Einige Konstanten
>#DEFINE WM_CLOSE			16
>#DEFINE WM_SYSCHAR		262
>#DEFINE WM_CHAR				258
>#DEFINE WM_COMMAND		273
>#DEFINE SW_SHOW			5
>#DEFINE ALT_KEY				BitSet(0,29)
>#DEFINE IDOK					1
>
>
>* Wordpad starten
>Local lnHWNDVfp, lnHINSTANCE
>Declare Integer ShellExecute in Shell32.Dll ;
>	Long Hwnd, ;
>	String lpOperation, ;
>	String lpFile, ;
>	String lpParameters, ;
>	String lpDirectory, ;
>	Integer nShowCmd
>Set Library to (Home()+"FoxTools.Fll") ;
>	Additive
>lnHWNDVfp = _WhToHwnd(_WMainWind())
>lnHINSTANCE = ShellExecute( ;
>	m.lnHWNDVfp, ;
>	"open", ;
>	"Write.Exe", ;
>	"Demo.Doc", ;
>	Sys(5)+CurDir(), ;
>	SW_SHOW ;
>)
>If lnHINSTANCE <= 32
>	Return
>Endif
>
>
>* Das Fenster suchen, maximal 5 Sekunden
>Local lnHWND, lnStart
>Declare Integer FindWindow in Win32API ;
>	String lcClass, ;
>	String lcTitle
>lnStart = Seconds()
>lnHWND = 0
>Do While lnHWND == 0 ;
>         and lnStart+5 > Seconds()
>	lnHWND = ;
>		FindWindow( ;
>			NULL, ;
>			"demo.doc - WordPad" ;
>		 )
>Enddo
>If m.lnHWND == 0
>	Return
>Endif
>
>
>* File|Print auswählen
>Declare Integer PostMessage in Win32API ;
>	Long nHWND, ;
>	Long nMessage, ;
>	Long wParam, ;
>	Long lParam
>PostMessage( ;
>	m.lnHWND, ;
>	WM_SYSCHAR, ;
>	Asc("f"), ;
>	ALT_KEY ;
>)
>PostMessage( ;
>	m.lnHWND, ;
>	WM_CHAR, ;
>	Asc("p"), ;
>	0;
>)
>
>
>* Nun den Drucker bestätigen
>Local lnHWNDPrinter, lnStart
>lnStart = Seconds()
>lnHWNDPrinter = 0
>Do While lnHWNDPrinter == 0 ;
>        and lnStart+1 > Seconds()
>	lnHWNDPrinter = ;
>		FindWindow( NULL, "Print" )
>Enddo
>If m.lnHWNDPrinter == 0
>	Return
>Endif
>PostMessage( ;
>	m.lnHWNDPrinter, ;
>	WM_COMMAND, ;
>	IDOK, ;
>	0 ;
>)
>
>
>* Dem Programm etwas Zeit zum
>* Drucken geben...
>Inkey(1)
>
>
>* Und zu guter letzt das Programm
>* beenden
>PostMessage( ;
>	m.lnHWND, ;
>	WM_CLOSE, ;
>	0, ;
>	0 ;
>)
>Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform