Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

object Printer PaperBin

Posted on 1997-03-24
1
Medium Priority
?
599 Views
Last Modified: 2012-05-04
I would like to have an example of a program which is using the property PaperBin of the Printer object.
As a matter of fact I would automatically in a program print in a certain sheet feeder
0
Comment
Question by:Alain032497
[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
1 Comment
 
LVL 2

Accepted Solution

by:
dirkmartin earned 200 total points
ID: 1424684
By using the Windows API Escape() function, an application can change the paper bin on the printer and obtain a list of available paper bins for the default printer.

To return a list of paper bin names and a list of corresponding of bin numbers, pass the ENUMPAPERBINS printer escape constant to the Escape() function. You can use the first list to display the available paper bins for the user, and use the second list to change the paper bin.

To change the paper bin, pass the GETSETPAPERBINS printer escape constant along with the bin number to the Escape() function. GETSETPAPERBINS returns the current bin and the number of bins supported by the default printer.

The example code listed below demonstrates how to use both ENUMPAPERBINS and GETSETPAPERBINS with the Windows API Escape() function.

Note

The Windows API Escape() function is provided in Windows versions 3.0 and 3.1 for backward compatibility with earlier versions of Microsoft Windows. Applications are supposed to use the GDI DeviceCapabilities() and ExtDeviceMode() functions instead of the Escape() function, but neither DeviceCapabilities() nor ExtDeviceMode() can be called directly from Visual Basic. This is because they are exported by the printer driver, not by the Windows GDI. The only way to use ExtDeviceMode() or DeviceCapabilities() in Visual Basic is to create a DLL and call them from there.

1.Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default. 2.From the File menu, choose New Module (ALT, F, M). Module1 is created by default. 3.Add the following code to the general declarations section of Module1:

Global Const MaxBins = 6 Type PaperBin ' Used for EnumPaperBins

      BinList(1 To MaxBins) As Integer
      PaperNames(1 To MaxBins) As String * 24
End Type

Type BinInfo ' Used for GetSetPaperBins

      CurBinNumber As Integer  ' Current Bin
      NumBins As Integer       ' Number of bins supported by printer
      Reserved1 As Integer     ' Reserved
      Reserved2 As Integer     ' Reserved
      Reserved3 As Integer     ' Reserved
      Reserved4 As Integer     ' Reserved

End Type ' Enter each of the following Declare statements on one, single line. Declare Function EnumPaperBinEscape% Lib "GDI" Alias "Escape"

      (ByVal hDC%, ByVal nEscape%, ByVal nCount%, NumBins%,
      lpOutData As Any)

Declare Function GetPaperBinEscape% Lib "GDI" Alias "Escape"

      (ByVal hDC%, ByVal nEscape%, ByVal nCount%, InBinInfo As Any,
      OutBinInfo As Any)

Global Const ENUMPAPERBINS = 31 Global Const GETSETPAPERBINS = 29 4.Add a command button (Command1) to Form1. 5.Add a list box (List1) to Form1. 6.Add the following code to the Command1_Click event procedure:

Sub Command1_Click ()

      Dim InPaperBin As PaperBin
      Dim InBinInfo As BinInfo
      ' Enter each of the following result% statements on one, single line:
      result% = GetPaperBinEscape(Printer.hDC, GETSETPAPERBINS, 0,
         ByVal 0&, InBinInfo)
      result% = EnumPaperBinEscape(Printer.hDC, ENUMPAPERBINS, 2,
         MaxBins, InPaperBin)

      List1.Clear
      For I% = 1 To InBinInfo.NumBins ' Fill list1 with available bins
         List1.AddItem InPaperBin.PaperNames(I%)
         List1.ItemData(List1.NewIndex) = InPaperBin.BinList(I%)
      Next I%

End Sub 7.Add the following code to the List1_Click event procedure:

Sub List1_Click ()

      Dim InBinInfo As BinInfo
      Dim NewBinInfo As BinInfo

      NewBinInfo.CurBinNumber = List1.ItemData(List1.ListIndex)
      ' Enter the following result% statement on one, single line.
      result% = GetPaperBinEscape(Printer.hDC, GETSETPAPERBINS,
         Len(NewBinInfo), NewBinInfo, NewBinInfo)


      MsgBox "Sending Sample Output to printer using Bin: " + List1.Text
      Printer.Print "This should of have come from Bin: "; List1.Text
      Printer.EndDoc

End Sub
 8.From the Run menu, choose Start (ALT, R, S) to run the program. 9.Choose the Command1 button to see a list of available paper bins for the default printer listed in the List1 box.
10.Select one of the paper bins listed in the List1 box. A message box
    appears to tell you that a sample printout is being sent to the printer
    using the paper bin you selected.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

618 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