How print to IFR port from Windows CE?

I am using Visual Basic CE on an H/PC and want to print a simple report to a printer using the Infra-Red (IFR) port.  

I have already successfully written out a sequential file to a DOS ".txt" file using the FILE control and the "Open" and "LinePrint" commands.  Do I use the same commands with a different "Open" statement to direct the output to a printer instead of a file?  If yes, what is the syntax of the command?

In summary, how do I write/print to a printer using the IFR port? I can print to the printer using the IFR port from within Word, but I want to do it from within Visual Basic CE.

Thanks for your time,
EYoung
eyoungAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
Why not use the Printer Common Dialog box to select the IRF printer, then print using the Printer object?
0
eyoungAuthor Commented:
Erik37,

Sounds like a good idea.  How does it work?  I can't find a Printer Common Dialog box under the Project/Components menu option.  There is a Common Dialog box control for CE, but I can't find any reference to the Printer features.

Also, what is the Printer Object and how do I print using it?

Any help would be appreciated.  All I want to do is to print some lines on a piece of paper.

Thanks,
EYoung
0
Erick37Commented:
The component you are looking for is called the Microsoft Common Dialog Control.

Example from Books Online:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'The following example displays the Print dialog
Private Sub Command1_Click()
    Dim BeginPage, EndPage, NumCopies, i
    ' Set Cancel to True
    CommonDialog1.CancelError = True
    On Error GoTo ErrHandler 'An error is raised if the user presses the cancel button
    ' Display the Print dialog box
    CommonDialog1.ShowPrinter
    ' Get user-selected values from the dialog box
    BeginPage = CommonDialog1.FromPage
    EndPage = CommonDialog1.ToPage
    NumCopies = CommonDialog1.Copies
    For i = 1 To NumCopies
        ' Put code here to send data to the printer
    Next i
    Exit Sub
ErrHandler:
    ' User pressed the Cancel button
    Exit Sub
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another example:

This example prints the formatted text in a RichTextBox control. To try this example, put a RichTextBox control, a CommonDialog control, and a CommandButton control on a form. Paste this code into the Click event of the CommandButton control. Then run the example.
Private Sub Command1_Click()
      CommonDialog1.Flags = cdlPDReturnDC + cdlPDNoPageNums
      If RichTextBox1.SelLength = 0 Then
            CommonDialog1.Flags = CommonDialog1.Flags + cdlPDAllPages
      Else
            CommonDialog1.Flags = CommonDialog1.Flags + cdlPDSelection
      End If
      CommonDialog1.ShowPrinter
      Printer.Print ""
      RichTextBox1.SelPrint CommonDialog1.hDC
End Sub


See also the Printer object in Books Online, especially the PrinterDefault property.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

eyoungAuthor Commented:
Erik37,

Several questions:

1.  You refer to the component Microsoft Common Dialog Control. Do you mean the Microsoft "CE" Common Dialog Control?  Remember, I am using the Visual Basic CE version on an H/PC.

2.  What books online are you refering to?  Sound like a good resource.

3.  There is no "ShowPrinter" method in the CommonDialog1.ShowPrinter properties.  There may be one in standard VB but I don't see one in VB "CE".

4.  Exactly what is the syntax (example) of how to "send data to the printer?

Your example said:
    For i = 1 To NumCopies
        ' Put code here to send data to the printer
    Next i
   
What would the code look like to print "Test Line 1" to the printer?

If you can help me to print something to the printer, I would be very grateful and would double the points.

Many thanks,
EYoung
0
Erick37Commented:
I thought that VBCE had a common dialog, similar to that in VB Win.  It seems the MS VBCE control only supports fonts, colors, but no mention of printer control.

There are companies which sell printing components for CE:

http://www.fieldsoftware.com/PrinterCE.htm
0
eyoungAuthor Commented:
Erick37,

That's the answer.  I downloaded the printer control from Field Software Products and it works just great.

Thank you for your help.

Regards,
Eric Young

PS, how do I give you the points?  Your support has been through comments and not proposed answers?  I'll be out of the office until tomorrow morning.
0
Erick37Commented:
I'm glad it worked out for you.
Microsoft plans to add the Printer Common Dialog to future releases, but for now I suppose the easiest way is to use a third party control.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eyoungAuthor Commented:
Thanks again.  EYoung
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.