Link to home
Create AccountLog in
Avatar of Mike Jacobs
Mike JacobsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Invoking a Visual Studio Printer Class within VFP

Microsoft have created a Printer Class described here

It gives the invocation syntax for C#, C++, F# and VB

Anyone know how to invoke it in VFP?
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

VB mentioned in the article is VB.NET in fact so nothing similar to VFP like e.g. VB6...

You would need some .NET interoperability between VFP and .NET. You may find code samples here:

Sorry I have to say that but it is better to write it in C# or VB.NET than in VFP...
Avatar of Mike Jacobs


Greetings PCElba

I have a current Westwind licence so'll I'll take a good look at that. Coding outside VFP is not an option in this case.

I'll describe the problem I'm trying to address and perhaps you'll know another way around it.

One of my (long term) customers has been running his business using my software since 1996. Over that period we've generated a couple of thousand bespoke reports (so much so I've had to create a report management module just to keep track of them) and he alone probably prints a dozen a day.

He's acquired an HP OfficeJet printer which has developed a fault and, yes, we'll almost certainly fix the problem by replacing the printer. But in the process of attempting to troubleshoot it from my side, I suddenly realised that I had no way, from within VFP, to control sundry printer settings. The one which would have helped in this case would have been the ability to set a bottom margin but that doesn't really matter. It could have been any one of a couple of dozen useful parameters.

I could have sworn that this functionality was there a few years back (prior to Win 10 perhaps?) from within the system "page setup" screens;  but it's been so rare that I or my users have ever had to meddle with such niceties, that I simply hadn't noticed that we could no longer access those areas.  Equally surprising, I found that even with the device properties in the windows device manager, these controls were unavailable and, again, I could have sworn they used to be!

So I'm not really trying to solve a one off problem which we've already proved to be caused by a printer malfunction, I'm considering how to provide support for that kind of formatting functionality within my software more generally.

The perfect answer would be that some VFP genius has already done it. Failing that, I'm prepared to roll my own if it's likely to be a week's work rather than several months. So that microsoft api did look like an obvious starting point.
Yes, I would say the code exists and it has been published on which is unavailable now. Some more hints are here:

BUT you could also create a standalone application in .NET which is much easier than to control printers from VFP today and invoke it from your VFP application.

BTW, we are converting all VFP reports to .NET and it takes hours and hours...
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Closing the question. Haven't had the time, inclination or pressing need to return to the problem. Thanks to both for your input