Solved

Non-printable printer margins

Posted on 1997-05-29
2
542 Views
Last Modified: 2008-03-06
In using VB 4.0 I am working on an app that does a lot of printing to the printer.  Since it will be used by different people (and different printers), I need to know how to programmatically find out what the four non-printable margins are.  Does this come from the "device context" and if so, how do I get at it?  Using the difference between Printer.Width and Printer.ScaleWidth (and dividing by 2) assumes that the top and bottom non-printable margins are the same and this is rarely the case.
0
Comment
Question by:stephani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
byang earned 100 total points
ID: 1426624
You can get the offset of the upperleft corner of the printable area using either Escape() or GetDeviceCaps() API function. You have to pass in Printer.hdc as the device context.  For example:

  uppery=GetDeviceCaps(printer.hdc,PHYSICALOFFSETY)
  status=Escape(printer.hdc,GETPRINTINGOFFSET,0,0,rc)

Of course, the values you get back this way are pixels, not twips.
The definition of API stuff is in winapi directory under your vb directory.
0
 

Author Comment

by:stephani
ID: 1426625
This is the sort of thing I was looking for!  I haven't tried it yet to see IF it works, but I've been pointed in the right direction.  It's time for me to start reading up on how to access the API
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month6 days, left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question