Results 1 to 6 of 6

Thread: Printing a color

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    Printing a color

    I am building a report with some items that are color coded. In each section of the report there is a line that has the word "color" that is to be followed by a short colored line or a small colored circle.

    How is this done?

    Thanks,
    sneakers
    Last edited by sneakers; Nov 29th, 2021 at 08:39 PM.

  2. #2
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Printing a color

    Quote Originally Posted by sneakers View Post
    I am building a report with some items that are color coded.
    You did not write in what format the report is created.
    If the file is in .txt format, then color insertion is not possible.
    If in .doc or .xls formats, then you can.

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Printing a color

    And of course if you are using a reporting tool like Active Reports you can add color, shapes, images to your hearts desire.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    203

    Re: Printing a color

    I'm just printing lines of text on my printer.

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Printing a color

    Windows can provide a device context for a printer to draw into just as you would draw into the screen, though I can't say of the top of my head what the best way to do it in VB6 would be. I can't remember if the Printer object provides a device context. Anyways, you should be able to just set the foreground or text color of the device context and use an API like DrawText to draw coloured text then the printer could print whatever is in the device context.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Printing a color

    Quote Originally Posted by sneakers View Post
    How is this done?
    The following routine shows how:
    Code:
    Sub PrintTextAndCircleTo(oDest As Object, Text As String, Color)
      oDest.Print Text & "  ";
      oDest.ForeColor = Color
        oDest.Print ChrW(8226)
      oDest.ForeColor = vbBlack
    End Sub
    It is up to you, what you pass as the first parameter (when Printing, it should be the VB6-Printer-Object) -
    but below is an example, which uses the above routine on an empty Form:
    Code:
    Private Sub Form_Click()
      Me.Font.Name = "Arial"
      Me.Font.Size = 11
      
      PrintTextAndCircleTo Me, "Color", vbRed
    End Sub
    HTH

    Olaf

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