看 PrintDocument 帮助
不过好像是按打印机区分不是按造 端口区分.
不过好像是按打印机区分不是按造 端口区分.
解决方案 »
- wpf 中用代码可以把arm格式的音频文件转为MP3格式吗?如果可以请贴出代码 谢谢
- Soap 序列化程序不支持序列化一般类型: System.Collections.Generic.List`1[System.Object]。
- 这个程序哪出问题了???
- 视频录制后直接转换成flv
- 如何用递归遍历一个Tree,请高手帮忙
- 想问下那里有C#Telnet协议资料??
- 求C#版的图像高斯模糊算法,模糊半径是个参数,谢!
- 这个"特性"例题为什么不删掉带方括号的那句?
- 有POS机,银联卡接口开发经验的朋友请进
- SINGLETON(单件)模式用C#+ASP.Net怎么实现啊?
- winForm中,如何在dataGrid最左边灰色的那一列上添加CheckBox控件
- 在线等!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11
public class PrintingExample : System.Windows.Forms.Form
{
private System.ComponentModel.Container components;
private System.Windows.Forms.Button printButton;
private Font printFont;
private StreamReader streamToPrint; public PrintingExample() : base()
{
// The Windows Forms Designer requires the following call.
InitializeComponent();
} // The Click event is raised when the user clicks the Print button.
private void printButton_Click(object sender, EventArgs e)
{
try
{
streamToPrint = new StreamReader
("C:\\My Documents\\MyFile.txt");
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler
(this.pd_PrintPage);
pd.Print();
}
finally
{
streamToPrint.Close();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
} // The PrintPage event is raised for each page to be printed.
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null; // Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height /
printFont.GetHeight(ev.Graphics); // Print each line of the file.
while(count < linesPerPage &&
((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count *
printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
count++;
} // If more lines exist, print another page.
if(line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}
// The Windows Forms Designer requires the following procedure.
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.printButton = new System.Windows.Forms.Button(); this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(504, 381);
this.Text = "Print Example"; printButton.ImageAlign =
System.Drawing.ContentAlignment.MiddleLeft;
printButton.Location = new System.Drawing.Point(32, 110);
printButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
printButton.TabIndex = 0;
printButton.Text = "Print the file.";
printButton.Size = new System.Drawing.Size(136, 40);
printButton.Click += new System.EventHandler(printButton_Click); this.Controls.Add(printButton);
} // This is the main entry point for the application.
public static void Main(string[] args)
{
Application.Run(new PrintingExample());
}
}[C++, JScript] 没有可用于 C++ 或 JScript 的示例。若要查看 Visual Basic 或 C# 示例,请单击页左上角的“语言筛选器”按钮 。要求
1、hPort = CreateFile("LPT1"........
2、WriteFile(hPort,"sdfsdfsdfsdf".......