Results 1 to 14 of 14

Thread: How to set Borderless Property on Printer?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    Gold Coast, Australia
    Posts
    71

    How to set Borderless Property on Printer?

    Howdy People,

    I want to be able to read/write the borderless property on a printer using code. My app has a printer dialog (the dialog that ships with the printer) allowing users to change the printer preferences. Of course this only a dialog, it only records the users choices it DOES NOT implement the changes, I must do that in code. I can implement all the user choices in the printer object EXCEPT the borderless property. Does something like SetDeviceCaps as opposed to GetDeviceCaps exist where I can change the PHYSICALOFFSETX or HORZREZ value of the printer?

    Doe's anybody know how this can be done? Or some kind of hack to achieve the same result?

    Thanks in advance!

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: How to set Borderless Property on Printer?

    how do you mean borderless?
    do you mean margins?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    Gold Coast, Australia
    Posts
    71

    Re: How to set Borderless Property on Printer?

    By borderless I mean the property that some printers have that eanbles you to print to the edge of the paper. Like photo printers for example. So yes, I guess you could call it the margins. The printer object only lets you read margins not set them though (to the best of knowledge!).

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: How to set Borderless Property on Printer?

    that is margins. i'll need to see your code. it looks like you're using some sort of custom print component?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    Gold Coast, Australia
    Posts
    71

    Re: How to set Borderless Property on Printer?

    My code is simply using the printer object. There is nothing unique here. All I want is to be able to read/write the borderless property of a printer, its a boolean value. I need to be able to do that exactly the same as I can with the Duplex property, or copies property etc etc.

    Below are two functions. One too show the printer dialog where the user can select a printer AND set preferences. The second function applies the users choices.

    Cheers

    Code:
    Public Function ShowPrinterDialog(FormName As Form) As Boolean
        'an example call would be DialogOpened = ShowPrinterDialog(Me)
        'or simply ShowPrinterDialog Me for no return value
        
        Dim NewPrinterName As String
        Dim objPrinter As Printer
        Dim OrigPrinter As String, OrigPaper
        
        On Error GoTo Cancel
        
        'remember our original printer & paper
        OrigPrinter = Printer.DeviceName
        OrigPaper = Printer.PaperSize
        
        'Set the starting information for the dialog box based on the current printer settings
        printDlg.PrinterName = Printer.DeviceName
        printDlg.DriverName = Printer.DriverName
        printDlg.Port = Printer.Port
        printDlg.Copies = Printer.Copies
        printDlg.Orientation = Printer.Orientation
        printDlg.ColorMode = Printer.ColorMode
        printDlg.Duplex = Printer.Duplex
        printDlg.PaperBin = Printer.PaperBin
        printDlg.PaperSize = Printer.PaperSize
        printDlg.PrintQuality = Printer.PrintQuality
        
        'Set the flags for the PrinterDlg object in the Print style
        printDlg.flags = VBPrinterConstants.cdlPDNoSelection Or VBPrinterConstants.cdlPDNoPageNums Or VBPrinterConstants.cdlPDReturnDC
        Printer.TrackDefault = False
        printDlg.CancelError = True
        
        'show dialog
        If Not printDlg.ShowPrinter(FormName.hWnd) Then Exit Function
        
        ' Locate the printer that the user selected in the Printers collection and set properties.
        SetNewPrinter printDlg.PrinterName
        
        ShowPrinterDialog = True
        
        Exit Function
        
    Cancel:
        If Err.Number = 32755 Then
            'the user cancelled, add xtra code here if you wish
        Else
            MsgBox "A Printer Dialog Error Occured" & vbCrLf & vbCrLf & Err.Number & vbCrLf & Err.Description, vbCritical, "Error"
        End If
    End Function
    
    Public Function SetNewPrinter(strPrinterName As String) As Boolean
        'sets the printer by name
        Dim P As Printer
        Dim S As String
        
        strPrinterName = LCase(strPrinterName)
        
        For Each P In Printers
            S = LCase(P.DeviceName)
            If InStr(1, S, strPrinterName) > 0 Then
                'if its already the loaded printer then no need to set it
                If P.DeviceName = Printer.DeviceName Then Exit For
                'change the printer to selection
                Set Printer = P
                Exit For
            End If
        Next
        
        'not all printers support all properties (pdf printers for example) so...
        On Error Resume Next
        'Apply any changes to the printer
        Printer.Copies = printDlg.Copies
        Printer.Orientation = printDlg.Orientation
        Printer.ColorMode = printDlg.ColorMode
        Printer.Duplex = printDlg.Duplex
        Printer.PaperBin = printDlg.PaperBin
        Printer.PaperSize = printDlg.PaperSize
        Printer.PrintQuality = printDlg.PrintQuality
        
        'reset the paper props
        EnumPaperSizes
        SetNewPrinter = True
        
    End Function

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    Gold Coast, Australia
    Posts
    71

    Re: How to set Borderless Property on Printer?

    This thread was supposed to have been in the VB6 or earlier section. I obviously failed!
    Does anyone know how to move it?
    Thanks

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: How to set Borderless Property on Printer?

    i've informed a moderator for you

  8. #8
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How to set Borderless Property on Printer?

    If this is VB6 question...

    Then this is probably your answer

    http://www.vbforums.com/showthread.p...ight=printarea

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    Gold Coast, Australia
    Posts
    71

    Re: How to set Borderless Property on Printer?

    Quote Originally Posted by szlamany View Post
    If this is VB6 question...

    Then this is probably your answer

    http://www.vbforums.com/showthread.p...ight=printarea
    Thanks but I already have all of that. I can GET my printer margins no problem using GetDeviceCaps. I need to SET them! That's why I was wondering if there was an API similar to GetDeviceCaps that sets the values rather than gets them.

    Any other ideas anyone?

    Really appreciate help on this.

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    Gold Coast, Australia
    Posts
    71

    Re: How to set Borderless Property on Printer?

    Quote Originally Posted by .paul. View Post
    i've informed a moderator for you
    Thanks .paul

  11. #11
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How to set Borderless Property on Printer?

    As far as I know that unprintable area of the printer is real and not changeable.

    I was under the impression it was a hardware restriction.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  12. #12
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to set Borderless Property on Printer?

    Thread moved from the 'VB.Net' forum to the 'VB6 and Earlier' forum thanks .paul.
    Quote Originally Posted by FromDownUnder View Post
    Does anyone know how to move it?
    Only moderators/admins can move threads, and the best way to let us know about something is to click the "Report" triangle icon on the left of a post - as .paul. did for you.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    Gold Coast, Australia
    Posts
    71

    Re: How to set Borderless Property on Printer?

    OK thanks Si. And thanks again .paul.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Location
    Gold Coast, Australia
    Posts
    71

    Re: How to set Borderless Property on Printer?

    Quote Originally Posted by szlamany View Post
    As far as I know that unprintable area of the printer is real and not changeable.

    I was under the impression it was a hardware restriction.
    Hi szlamany.

    Yes, I guess you are right. The borderless property can be changed easily enough through the control panel/printers/printer preferences and I assume the printer driver handles that? Do you think there may be a way to emulate that procedure?

    The idea was for me to allow the user to set ALL preferences from my app rather than have to seperately go to the control panel for some of them.

    Any bright ideas anybody?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width