Solved

Non-printable printer margins

Posted on 1997-05-29
2
534 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

734 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