⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winapp.htm

📁 非常实用的条形码制作工具
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML dir=ltr>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<title>Writing Windows Applications</title>
</HEAD>
<BODY>
<h2>Writing Windows Applications</h2>

<h4>COMPONENT SELECTION</h4>
<p>
For native Windows applications, you can choose either the <a href="barcodeClass.htm">Barcode</a> 
component or <a href="barcodeControlClass.htm">BarcodeControl</a>.
</p>
<p>
<a href="barcodeClass.htm">Barcode</a> is a System.ComponentModel.Component
and can be used easily anywhere in your code. It does not have a user 
interface at design time or at run time.
</p>
<p>
<a href="barcodeControlClass.htm">BarcodeControl</a> is a System.Windows.Forms.Control
and can be used in Control containers, like a Windows Form. It has a user interface that
simply displays a barcode. At design time, the barcode changes as you select the control
properties. If need be, you may choose to hide the control at run time. 
BarcodeControl is implemented as a wrappper around Barcode.
</P>

<h4>USING THE COMPONENTS</h4>
<p>
Both <a href="barcodeClass.htm">Barcode</a> and <a href="barcodeControlClass.htm">BarcodeControl</a> 
expose the same set of properties and methods. So both are used the same way once initialized. 
If you did not add Barcode to your Form at design time, you can 
create an instance of it at run time by calling one of its <a href="barcodeConstructor.htm">constructors</a>.
</p>

<p>
Once you have an instance of either Barcode or 
BarcodeControl, you can set the barcode type 
using the <a href="barcodeType.htm">BarcodeType</a> property. Then you can set the 
barcode <a href="barcodeData.htm">Data</a>. That's it for the essentials. You could further
set other properties like, color, rotation, styles, etc.
</p>
<p>
The next thing you would do is actually draw the barcode using the <a href="barcodeDraw1.htm">Draw</a> method, 
to a Graphics object representing the screen or a printer. You may also call the 
<a href="barcodeMakeImage.htm">MakeImage</a> or 
<a href="barcodeSaveImage.htm">SaveImage</a> to directly generate an image in any of
of the .Net supported image formats like GIF, JPEG, PNG, BMP, etc.

</p>
<h4>EXAMPLE</h4>

The Barcode .Net related code below is minimal and highlighted in bold.

First add a <a href="barcodeClass.htm">Barcode</a> or <a href="barcodeControlClass.htm">BarcodeControl</a> named <i>barcode1</i>
to a Windows Form. Then add the following event handler. A barcode
will be displayed on your form.

<pre>
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);
    // unit of measure is LOENGLISH or 0.01 inch:
    RectangleF rect = new RectangleF(40.0f, 80.0f, 180.0f, 60.0f);
    <b>barcode1.Draw(e.Graphics, rect, GraphicsUnit.Inch, 0.01f,
        BarcodeDrawFlags.PaintWholeRect, null);</b>
}
</pre>

You can also print a barcode on your printer. Add a button named 
<i>PrintButton</i> to your form and then add the following
two event handlers to your form code. Then clicking the button
will send a barcode to your printer.

<pre>
private void pd_PrintPage(object sender, PrintPageEventArgs e) 
{
    // unit of measure is LOENGLISH or 0.01 inch:
    RectangleF rect = new RectangleF(40.0f, 80.0f, 180.0f, 60.0f);
    <b>barcode1.Draw(e.Graphics, rect, GraphicsUnit.Inch, 0.01f, 0, null);</b>
    e.HasMorePages = false;
}

private void ButtonPrint_Click(object sender, System.EventArgs e)
{
    PrintDocument pd = new PrintDocument();
    pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);

    PrintDialog dlg = new PrintDialog() ;
    dlg.Document = pd;
    DialogResult result = dlg.ShowDialog();

    if (result == DialogResult.OK) 
    {
        pd.Print();
    }
}
</pre>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -