印刷

Size: px
Start display at page:

Download "印刷"

Transcription

1 印刷 Windows フォームに於ける印刷のサポート Windows フォームに於ける印刷では 主に ユーザーに依る印刷を可能にする為の PrintDocument コンポーネントと Windows オペレーティングシステムを常用して居るユーザーに見慣れたグラフィカルインターフェイスを提供する為の PrintPreviewDialog コントロール PrintDialog コンポーネント 及び PageSetupDialog コンポーネントが使用される 通常 印刷を行う場合には PrintDocument コンポーネントの新しいインスタンスを作成し PrinterSettings クラスと PageSettings クラスを使用して印刷対象を定義してから Print メソッドを呼び出してドキュメントを実際に印刷する Windows ベースのアプリケーションから印刷を行って居る間 PrintDocument コンポーネントは 印刷中止ダイアログボックスを表示して 印刷が実行中で有る事をユーザーに通知し ユーザーが印刷ジョブをキャンセル出来る様にする 標準の Windows フォーム印刷ジョブを作成する方法 Windows フォームでの印刷の基盤と成るのは PrintDocument コンポーネントで有る 具体的に謂えば PrintPage イベントで有る PrintPage イベントを処理するコードを記述する事に依り 印刷対象と印刷方法を指定出来る 印刷ジョブを作成するには 1. フォームに PrintDocument コンポーネントを追加する 2.PrintPage イベントを処理するコードを記述する 独自の印刷ロジックをコーディングする必要が有る 亦 印刷する対象も指定する必要が有る 次のコード例では 印刷対象と仕て PrintPage イベントハンドラ内で赤い四角形のサンプルグラフィックを作成して居る Private Sub PrintDocument1_PrintPage(ByVal sender As Object, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) _ Handles PrintDocument1.PrintPage e.graphics.fillrectangle(brushes.red, New Rectangle(500, 500, 500, 500)) private void printdocument1_printpage(object sender, System.Drawing.Printing.PrintPageEventArgs e) e.graphics.fillrectangle(brushes.red, new Rectangle(500, 500, 500, 500)); -1-

2 Visual では フォームのコンストラクタに次のコードを挿入してイベントハンドラを登録する this.printdocument1.printpage += new System.Drawing.Printing.PrintPageEventHandler (this.printdocument1_printpage); 亦 BeginPrint イベントと EndPrint イベントに対するコードを記述する事が必要な場合も有る 其の場合 各ページが印刷される度に 印刷する合計ページ数を表す整数がデクリメントされる様にも出来る フォームに PrintDialog コンポーネントを追加すると 明快で効率的なユーザーインターフェイスをユーザーに提供出来る PrintDialog コンポーネントの Document プロパティを設定する事に依り フォーム上で作業中の印刷ドキュメントに関連するプロパティを設定出来る 実行時に PrintDialog のユーザー入力をキャプチャする方法 印刷に関連するオプションはデザイン時に設定出来るが 多くの場合ユーザーの選択に依って 実行時に此等のオプションの変更が必要と成る事が有る PrintDialog コンポーネントと PrintDocument コンポーネントを使用して 文書を印刷するユーザー入力をキャプチャ出来る 印刷オプションをプログラムで変更するには 1. フォームに PrintDialog コンポーネントと PrintDocument コンポーネントを追加する 2.PrintDialog の Document プロパティをフォームに追加した PrintDocument に設定する PrintDialog1.Document = PrintDocument1 printdialog1.document = PrintDocument1; 3.ShowDialog メソッドを使用して PrintDialog コンポーネントを表示する PrintDialog1.ShowDialog( ) printdialog1.showdialog( ); 4. ダイアログボックスでユーザーが選択した内容は PrintDocument コンポーネントの PrinterSettings プロパティにコピーされる Windows フォームでユーザーのコンピュータに接続されたプリンタを選択する方法 ユーザーが既定のプリンタ以外のプリンタを印刷先と仕て選択する事は良く有る PrintDialog コンポーネントを使用すると 現在インストールされて居る複数のプリンタからユーザーが任意のプリンタを選択出来る様に成る PrintDialog コンポーネントを介して PrintDialog コンポーネントの DialogResult が取り込まれ 其れに基づいてプリンタが選択される 次の手順では テキストファイルを既定のプリンタで印刷する様に選択する 其の後で PrintDialog クラスがインスタンス化される -2-

3 プリンタを選択してファイルを印刷するには 1.PrintDialog コンポーネントを使用して 使用するプリンタを選択する 次のコード例では 2 つのイベントが処理される 最初のイベントで有る Button コントロールの Click イベントでは PrintDialog クラスがインスタンス化され ユーザーに依って選択されたプリンタが DialogResult プロパティで取り込まれる 2 番目のイベントで有る PrintDocument コンポーネントの PrintPage イベントでは 指定されたプリンタでサンプルドキュメントが印刷される Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Button1.Click Dim PrintDialog1 As New PrintDialog( ) PrintDialog1.Document = PrintDocument1 Dim result As DialogResult = PrintDialog1.ShowDialog( ) If (result = DialogResult.OK) Then PrintDocument1.Print( ) End If Private Sub PrintDocument1_PrintPage(ByVal sender As Object, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage e.graphics.fillrectangle(brushes.red, New Rectangle(500, 500, 500, 500)) private void button1_click(object sender, System.EventArgs e) PrintDialog printdialog1 = new PrintDialog( ); printdialog1.document = printdocument1; DialogResult result = printdialog1.showdialog( ); if (result == DialogResult.OK) printdocument1.print( ); private void printdocument1_printpage(object sender, System.Drawing.Printing.PrintPageEventArgs e) e.graphics.fillrectangle(brushes.red, new Rectangle(500, 500, 500, 500)); Visual では フォームのコンストラクタに次のコードを挿入してイベントハンドラを登録する this.printdocument1.printpage += new System.Drawing.Printing.PrintPageEventHandler (this.printdocument1_printpage); this.button1.click += new System.EventHandler(this.button1_Click); -3-

4 Windows フォームでグラフィックスを印刷する方法 Windows ベースのアプリケーションでグラフィックスの印刷が必要に成る事は良く有る Graphics クラスは 画面やプリンタ等のデバイスにオブジェクトを描画する手段を提供する グラフィックスを印刷するには 1. フォームに PrintDocument コンポーネントを追加する 2.PrintPage イベントハンドラで PrintPageEventArgs クラスの Graphics プロパティを使用して印刷するグラフィックスの種類をプリンタに指示する 外接する四角形内に青い楕円を作成する為に使用されるイベントハンドラのコード例を次に示す 四角形の位置は点 100, 150 で始まり 寸法は幅 250 高さ 250 で有る Private Sub PrintDocument1_PrintPage(ByVal sender As Object, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) _ Handles PrintDocument1.PrintPage e.graphics.fillellipse(brushes.blue, New Rectangle(100, 150, 250, 250)) private void printdocument1_printpage(object sender, System.Drawing.Printing.PrintPageEventArgs e) e.graphics.fillrectangle(brushes.blue, new Rectangle(100, 150, 250, 250)); Visual では フォームのコンストラクタに次のコードを挿入してイベントハンドラを登録する this.printdocument1.printpage += new System.Drawing.Printing.PrintPageEventHandler (this.printdocument1_printpage); Windows フォームで複数ページのテキストファイルを印刷する方法 Windows ベースのアプリケーションでテキストを印刷するのは 極く一般的な操作で有る Graphics クラスは 画面やプリンタ等のデバイスにオブジェクト ( グラフィックスやテキスト ) を描画するメソッドを提供する TextRenderer の DrawText メソッドでは 印刷はサポートされて居ない 次のコード例に示す様に 印刷する為にテキストを描画するには 常に Graphics の DrawString メソッドを使用する必要が有る テキストを印刷するには 1. フォームに PrintDocument コンポーネントと文字列を追加する Private printdocument1 As New PrintDocument( ) Private stringtoprint As String private PrintDocument printdocument1 = new PrintDocument( ); private string stringtoprint; -4-

5 2. 文書を印刷する場合 DocumentName プロパティを印刷する文書に設定し 前以て追加して有った文字列に文書の内容を読み込む Dim docname As String = "testpage.txt" Dim docpath As String = "c: " printdocument1.documentname = docname Dim stream As New FileStream(docPath + docname, FileMode.Open) Try Dim reader As New StreamReader(stream) Try stringtoprint = reader.readtoend( ) Finally reader.dispose( ) End Try Finally stream.dispose( ) End Try string docname = "testpage.txt"; string docpath "; printdocument1.documentname = docname; using (FileStream stream = new FileStream(docPath + docname, FileMode.Open)) using (StreamReader reader = new StreamReader(stream)) stringtoprint = reader.readtoend( ); 3.PrintPage イベントハンドラで PrintPageEventArgs クラスの Graphics プロパティと文書の内容を使用し 1 ページ当りの行の長さと行数を計算する 各ページの描画後に 其のページが最終ページか何うかを確認し 結果に応じて PrintPageEventArgs の HasMorePages プロパティを設定する HasMorePages が false に成る迄 PrintPage イベントが発生する 亦 PrintPage イベントがイベント処理メソッドに関連付けられて居る事を確認する イベントハンドラを使用して フォームに使用したのと同じフォントで testpage.txt ファイルの内容を印刷するコード例を次に示す Private Sub printdocument1_printpage(byval sender As Object, _ ByVal e As PrintPageEventArgs) Dim charactersonpage As Integer = 0 Dim linesperpage As Integer = 0 ' Sets the value of charactersonpage to the number of characters ' of stringtoprint that will fit within the bounds of the page. e.graphics.measurestring(stringtoprint, Me.Font, e.marginbounds.size, _ StringFormat.GenericTypographic, charactersonpage, linesperpage) ' Draws the string within the bounds of the page e.graphics.drawstring(stringtoprint, Me.Font, Brushes.Black, _ e.marginbounds, StringFormat.GenericTypographic) -5-

6 ' Remove the portion of the string that has been printed. stringtoprint = stringtoprint.substring(charactersonpage) ' Check to see if more pages are to be printed. e.hasmorepages = stringtoprint.length > 0 private void printdocument1_printpage(object sender, PrintPageEventArgs e) int charactersonpage = 0; int linesperpage = 0; // Sets the value of charactersonpage to the number of characters // of stringtoprint that will fit within the bounds of the page. e.graphics.measurestring(stringtoprint, this.font, e.marginbounds.size, StringFormat.GenericTypographic, out charactersonpage, out linesperpage); // Draws the string within the bounds of the page e.graphics.drawstring(stringtoprint, this.font, Brushes.Black, e.marginbounds, StringFormat.GenericTypographic); // Remove the portion of the string that has been printed. stringtoprint = stringtoprint.substring(charactersonpage); // Check to see if more pages are to be printed. e.hasmorepages = (stringtoprint.length > 0); 4.Print メソッドを呼び出す PrintPage イベントが発生する printdocument1.print( ) printdocument1.print( ); 使用例 Imports System Imports System.Drawing Imports System.IO Imports System.Drawing.Printing Imports System.Windows.Forms Public Class Form1 Inherits Form Private printbutton As Button Private printdocument1 As New PrintDocument( ) Private stringtoprint As String Public Sub New( ) Me.printButton = New System.Windows.Forms.Button( ) -6-

7 Me.printButton.Location = New System.Drawing.Point(12, 51) Me.printButton.Size = New System.Drawing.Size(75, 23) Me.printButton.Text = "Print" Me.ClientSize = New System.Drawing.Size(292, 266) Private Sub ReadFile( ) Dim docname As String = "testpage.txt" Dim docpath As String = "c: " printdocument1.documentname = docname Dim stream As New FileStream(docPath + docname, FileMode.Open) Try Dim reader As New StreamReader(stream) Try stringtoprint = reader.readtoend( ) Finally reader.dispose( ) End Try Finally stream.dispose( ) End Try Private Sub printdocument1_printpage(byval sender As Object, _ ByVal e As PrintPageEventArgs) Dim charactersonpage As Integer = 0 Dim linesperpage As Integer = 0 ' Sets the value of charactersonpage to the number of characters ' of stringtoprint that will fit within the bounds of the page. e.graphics.measurestring(stringtoprint, Me.Font, e.marginbounds.size, _ StringFormat.GenericTypographic, charactersonpage, linesperpage) ' Draws the string within the bounds of the page e.graphics.drawstring(stringtoprint, Me.Font, Brushes.Black, _ e.marginbounds, StringFormat.GenericTypographic) ' Remove the portion of the string that has been printed. stringtoprint = stringtoprint.substring(charactersonpage) ' Check to see if more pages are to be printed. e.hasmorepages = stringtoprint.length > 0 Private Sub printbutton_click(byval sender As Object, ByVal e As EventArgs) ReadFile( ) printdocument1.print( ) <STAThread( )> _ Shared Sub Main( ) Application.EnableVisualStyles( ) Application.SetCompatibleTextRenderingDefault(False) -7-

8 Application.Run(New Form1( )) End Class using System; using System.Drawing; using System.IO; using System.Drawing.Printing; using System.Windows.Forms; namespace PrintApp public class Form1 : Form private Button printbutton; private PrintDocument printdocument1 = new PrintDocument( ); private string stringtoprint; public Form1( ) this.printbutton = new System.Windows.Forms.Button( ); this.printbutton.location = new System.Drawing.Point(12, 51); this.printbutton.size = new System.Drawing.Size(75, 23); this.printbutton.text = "Print"; this.printbutton.click += new System.EventHandler(this.printButton_Click); this.clientsize = new System.Drawing.Size(292, 266); this.controls.add(this.printbutton); // Associate the PrintPage event handler with the PrintPage event. printdocument1.printpage += new PrintPageEventHandler(printDocument1_PrintPage); private void ReadFile( ) string docname = "testpage.txt"; string docpath "; printdocument1.documentname = docname; using (FileStream stream = new FileStream(docPath + docname, FileMode.Open)) using (StreamReader reader = new StreamReader(stream)) stringtoprint = reader.readtoend( ); private void printdocument1_printpage(object sender, PrintPageEventArgs e) int charactersonpage = 0; int linesperpage = 0; // Sets the value of charactersonpage to the number of characters // of stringtoprint that will fit within the bounds of the page. e.graphics.measurestring(stringtoprint, this.font, e.marginbounds.size, StringFormat.GenericTypographic, out charactersonpage, out linesperpage); -8-

9 // Draws the string within the bounds of the page e.graphics.drawstring(stringtoprint, this.font, Brushes.Black, e.marginbounds, StringFormat.GenericTypographic); // Remove the portion of the string that has been printed. stringtoprint = stringtoprint.substring(charactersonpage); // Check to see if more pages are to be printed. e.hasmorepages = (stringtoprint.length > 0); private void printbutton_click(object sender, EventArgs e) ReadFile( ); printdocument1.print( ); [STAThread] static void Main( ) Application.EnableVisualStyles( ); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1( )); Windows フォームの印刷ジョブを完了する方法 印刷ジョブを伴うワードプロセッサや其他のアプリケーションでは 多くの場合 印刷ジョブが完了したと謂うメッセージをユーザーに表示するオプションが用意されて居る PrintDocument コンポーネントの EndPrint イベントを処理する事に依って Windows フォームに此の機能を用意出来る 次の手順では PrintDocument コンポーネントの有る Windows ベースのアプリケーションを作成して居る必要が有る 此れは Windows ベースのアプリケーションからの印刷を有効にする標準的な方法で有る 印刷ジョブを完了するには 1.PrintDocument コンポーネントの DocumentName プロパティを設定する PrintDocument1.DocumentName = "MyTextFile" printdocument1.documentname = "MyTextFile"; 2.EndPrint イベントを処理するコードを記述する 次のコード例では ドキュメントの印刷が完了した事を示すメッセージボックスが表示される Private Sub PrintDocument1_EndPrint(ByVal sender As Object, _ ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.EndPrint MessageBox.Show(PrintDocument1.DocumentName + " has finished printing.") -9-

10 private void printdocument1_endprint(object sender, System.Drawing.Printing.PrintEventArgs e) MessageBox.Show(printDocument1.DocumentName + " has finished printing."); Visual では フォームのコンストラクタに次のコードを挿入してイベントハンドラを登録する this.printdocument1.endprint += new System.Drawing.Printing.PrintEventHandler (this.printdocument1_endprint); Windows フォームを印刷する方法 開発プロセスに於いて 多くの場合 Windows フォームのコピーを印刷する必要が有る 現在のフォームのコピーを CopyFromScreen メソッドを使用して印刷する方法を次のコード例に示す 使用例 Imports System Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Printing Public Class Form1 Inherits Form Private WithEvents printbutton As New Button Private WithEvents printdocument1 As New PrintDocument Public Sub New( ) printbutton.text = "Print Form" Me.Controls.Add(printButton) Dim memoryimage As Bitmap Private Sub CaptureScreen( ) Dim mygraphics As Graphics = Me.CreateGraphics( ) Dim s As Size = Me.Size memoryimage = New Bitmap(s.Width, s.height, mygraphics) Dim memorygraphics As Graphics = Graphics.FromImage(memoryImage) memorygraphics.copyfromscreen(me.location.x, Me.Location.Y, 0, 0, s) Private Sub printdocument1_printpage(byval sender As System.Object, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _ printdocument1.printpage e.graphics.drawimage(memoryimage, 0, 0) Private Sub printbutton_click(byval sender As System.Object, ByVal e As _ -10-

11 System.EventArgs) Handles printbutton.click CaptureScreen( ) printdocument1.print( ) Public Shared Sub Main( ) Application.Run(New Form1( )) End Class using System; using System.Windows.Forms; using System.Drawing; using System.Drawing.Printing; public class Form1 : Form private Button printbutton = new Button( ); private PrintDocument printdocument1 = new PrintDocument( ); public Form1( ) printbutton.text = "Print Form"; printbutton.click += new EventHandler(printButton_Click); printdocument1.printpage += new PrintPageEventHandler(printDocument1_PrintPage); this.controls.add(printbutton); void printbutton_click(object sender, EventArgs e) CaptureScreen( ); printdocument1.print( ); Bitmap memoryimage; private void CaptureScreen( ) Graphics mygraphics = this.creategraphics( ); Size s = this.size; memoryimage = new Bitmap(s.Width, s.height, mygraphics); Graphics memorygraphics = Graphics.FromImage(memoryImage); memorygraphics.copyfromscreen(this.location.x, this.location.y, 0, 0, s); private void printdocument1_printpage(system.object sender, System.Drawing.Printing.PrintPageEventArgs e) e.graphics.drawimage(memoryimage, 0, 0); public static void Main( ) Application.Run(new Form1( )); -11-

12 Windows フォームで印刷プレビューを使用して印刷する方法 Windows フォームのプログラミングでは 印刷サービスの他に印刷プレビューを実装する事は一般的で有る アプリケーションに印刷プレビューサービスを追加する簡単な方法は ファイルの印刷に PrintPreviewDialog コントロールと PrintPage イベント処理ロジックを組み合わせて使用する事で有る PrintPreviewDialog コントロールを使用してテキスト文書をプレビューするには 1. フォームに PrintPreviewDialog PrintDocument 及び 2 つの文字列を追加する Private printpreviewdialog1 As New PrintPreviewDialog( ) Private WithEvents printdocument1 As New PrintDocument( ) ' Declare a string to hold the entire document contents. Private documentcontents As String ' Declare a variable to hold the portion of the document that ' is not printed. Private stringtoprint As String private PrintPreviewDialog printpreviewdialog1 = new PrintPreviewDialog( ); private PrintDocument printdocument1 = new PrintDocument( ); // Declare a string to hold the entire document contents. private string documentcontents; // Declare a variable to hold the portion of the document that // is not printed. private string stringtoprint; 2.DocumentName プロパティを印刷する文書に設定し 前以て追加して有った文字列に文書の内容を読み込む Private Sub ReadDocument( ) Dim docname As String = "testpage.txt" Dim docpath As String = "c: " printdocument1.documentname = docname Dim stream As New FileStream(docPath + docname, FileMode.Open) Try Dim reader As New StreamReader(stream) Try documentcontents = reader.readtoend( ) Finally reader.dispose( ) End Try Finally stream.dispose( ) End Try stringtoprint = documentcontents -12-

13 private void ReadDocument( ) string docname = "testpage.txt"; string docpath "; printdocument1.documentname = docname; using (FileStream stream = new FileStream(docPath + docname, FileMode.Open)) using (StreamReader reader = new StreamReader(stream)) documentcontents = reader.readtoend( ); stringtoprint = documentcontents; 3. 文書を印刷する場合と同様に PrintPage イベントハンドラでは PrintPageEventArgs クラスの Graphics プロパティとファイルの内容を使用し 1 ページ当りの行数を計算し 文書の内容を描画する 各ページの描画後に 其のページが最終ページか何うかを確認し 結果に応じて PrintPageEventArgs の HasMorePages プロパティを設定する HasMorePages が false に成る迄 PrintPage イベントが発生する 文書の描画が完了したら 描画対象の文字列をリセットする 亦 PrintPage イベントがイベント処理メソッドに関連付けられて居る事を確認する アプリケーションに印刷機能を実装済みの場合 手順 2 と 3 は完了して居る事も有る イベントハンドラを使用して フォームに使用したのと同じフォントで testpage.txt ファイルを印刷するコード例を次に示す Sub printdocument1_printpage(byval sender As Object, _ ByVal e As PrintPageEventArgs) Handles printdocument1.printpage Dim charactersonpage As Integer = 0 Dim linesperpage As Integer = 0 ' Sets the value of charactersonpage to the number of characters ' of stringtoprint that will fit within the bounds of the page. e.graphics.measurestring(stringtoprint, Me.Font, e.marginbounds.size, _ StringFormat.GenericTypographic, charactersonpage, linesperpage) ' Draws the string within the bounds of the page. e.graphics.drawstring(stringtoprint, Me.Font, Brushes.Black, _ e.marginbounds, StringFormat.GenericTypographic) ' Remove the portion of the string that has been printed. stringtoprint = stringtoprint.substring(charactersonpage) ' Check to see if more pages are to be printed. e.hasmorepages = stringtoprint.length > 0 ' If there are no more pages, reset the string to be printed. If Not e.hasmorepages Then stringtoprint = documentcontents End If -13-

14 void printdocument1_printpage(object sender, PrintPageEventArgs e) int charactersonpage = 0; int linesperpage = 0; // Sets the value of charactersonpage to the number of characters // of stringtoprint that will fit within the bounds of the page. e.graphics.measurestring(stringtoprint, this.font, e.marginbounds.size, StringFormat.GenericTypographic, out charactersonpage, out linesperpage); // Draws the string within the bounds of the page. e.graphics.drawstring(stringtoprint, this.font, Brushes.Black, e.marginbounds, StringFormat.GenericTypographic); // Remove the portion of the string that has been printed. stringtoprint = stringtoprint.substring(charactersonpage); // Check to see if more pages are to be printed. e.hasmorepages = (stringtoprint.length > 0); // If there are no more pages, reset the string to be printed. if (!e.hasmorepages) stringtoprint = documentcontents; 4.PrintPreviewDialog コントロールの Document プロパティをフォームの PrintDocument コンポーネントに設定する printpreviewdialog1.document = printdocument1 printpreviewdialog1.document = printdocument1; 5.PrintPreviewDialog コントロールの ShowDialog メソッドを呼び出す 通常 ボタンの Click イベント処理メソッドから ShowDialog を呼び出す ShowDialog を呼び出すと PrintPage イベントが発生し 出力を PrintPreviewDialog コントロールに描画する ユーザーがダイアログボックスの印刷アイコンをクリックすると PrintPage イベントが再発生し 出力はプレビューダイアログボックスでは無くプリンタに送信される 此れが 手順 3 で描画プロセスの最後に文字列をリセットする理由で有る フォーム上に有るボタンの Click イベント処理メソッドのコード例を次に示す 此のイベント処理メソッドは 文書を読み込んで印刷プレビューダイアログボックスを表示するメソッドを呼び出す Private Sub printpreviewbutton_click(byval sender As Object, _ ByVal e As EventArgs) Handles printpreviewbutton.click ReadDocument( ) printpreviewdialog1.document = printdocument1 printpreviewdialog1.showdialog( ) -14-

15 使用例 private void printpreviewbutton_click(object sender, EventArgs e) ReadDocument( ); printpreviewdialog1.document = printdocument1; printpreviewdialog1.showdialog( ); Imports System Imports System.Drawing Imports System.IO Imports System.Drawing.Printing Imports System.Windows.Forms Class Form1 Inherits Form Private WithEvents printpreviewbutton As Button Private printpreviewdialog1 As New PrintPreviewDialog( ) Private WithEvents printdocument1 As New PrintDocument( ) ' Declare a string to hold the entire document contents. Private documentcontents As String ' Declare a variable to hold the portion of the document that is not printed. Private stringtoprint As String Public Sub New( ) Me.printPreviewButton = New System.Windows.Forms.Button( ) Me.printPreviewButton.Location = New System.Drawing.Point(12, 12) Me.printPreviewButton.Size = New System.Drawing.Size(125, 23) Me.printPreviewButton.Text = "Print Preview" Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.Add(Me.printPreviewButton) Private Sub ReadDocument( ) Dim docname As String = "testpage.txt" Dim docpath As String = "c: " printdocument1.documentname = docname Dim stream As New FileStream(docPath + docname, FileMode.Open) Try Dim reader As New StreamReader(stream) Try documentcontents = reader.readtoend( ) Finally reader.dispose( ) End Try Finally stream.dispose( ) -15-

16 End Try stringtoprint = documentcontents Sub printdocument1_printpage(byval sender As Object, _ ByVal e As PrintPageEventArgs) Handles printdocument1.printpage Dim charactersonpage As Integer = 0 Dim linesperpage As Integer = 0 ' Sets the value of charactersonpage to the number of characters ' of stringtoprint that will fit within the bounds of the page. e.graphics.measurestring(stringtoprint, Me.Font, e.marginbounds.size, _ StringFormat.GenericTypographic, charactersonpage, linesperpage) ' Draws the string within the bounds of the page. e.graphics.drawstring(stringtoprint, Me.Font, Brushes.Black, _ e.marginbounds, StringFormat.GenericTypographic) ' Remove the portion of the string that has been printed. stringtoprint = stringtoprint.substring(charactersonpage) ' Check to see if more pages are to be printed. e.hasmorepages = stringtoprint.length > 0 ' If there are no more pages, reset the string to be printed. If Not e.hasmorepages Then stringtoprint = documentcontents End If Private Sub printpreviewbutton_click(byval sender As Object, _ ByVal e As EventArgs) Handles printpreviewbutton.click ReadDocument( ) printpreviewdialog1.document = printdocument1 printpreviewdialog1.showdialog( ) <STAThread( )> _ Shared Sub Main( ) Application.EnableVisualStyles( ) Application.SetCompatibleTextRenderingDefault(False) Application.Run(New Form1( )) End Class using System; using System.Drawing; using System.IO; using System.Drawing.Printing; using System.Windows.Forms; namespace PrintPreviewApp -16-

17 public partial class Form1 : Form private Button printpreviewbutton; private PrintPreviewDialog printpreviewdialog1 = new PrintPreviewDialog( ); private PrintDocument printdocument1 = new PrintDocument( ); // Declare a string to hold the entire document contents. private string documentcontents; // Declare a variable to hold the portion of the document that is not printed. private string stringtoprint; public Form1( ) this.printpreviewbutton = new System.Windows.Forms.Button( ); this.printpreviewbutton.location = new System.Drawing.Point(12, 12); this.printpreviewbutton.size = new System.Drawing.Size(125, 23); this.printpreviewbutton.text = "Print Preview"; this.printpreviewbutton.click += new System.EventHandler(this.printPreviewButton_Click); this.clientsize = new System.Drawing.Size(292, 266); this.controls.add(this.printpreviewbutton); printdocument1.printpage += new PrintPageEventHandler(printDocument1_PrintPage); private void ReadDocument( ) string docname = "testpage.txt"; string docpath "; printdocument1.documentname = docname; using (FileStream stream = new FileStream(docPath + docname, FileMode.Open)) using (StreamReader reader = new StreamReader(stream)) documentcontents = reader.readtoend( ); stringtoprint = documentcontents; void printdocument1_printpage(object sender, PrintPageEventArgs e) int charactersonpage = 0; int linesperpage = 0; // Sets the value of charactersonpage to the number of characters // of stringtoprint that will fit within the bounds of the page. e.graphics.measurestring(stringtoprint, this.font, e.marginbounds.size, StringFormat.GenericTypographic, out charactersonpage, out linesperpage); // Draws the string within the bounds of the page. e.graphics.drawstring(stringtoprint, this.font, Brushes.Black, e.marginbounds, StringFormat.GenericTypographic); -17-

18 // Remove the portion of the string that has been printed. stringtoprint = stringtoprint.substring(charactersonpage); // Check to see if more pages are to be printed. e.hasmorepages = (stringtoprint.length > 0); // If there are no more pages, reset the string to be printed. if (!e.hasmorepages) stringtoprint = documentcontents; private void printpreviewbutton_click(object sender, EventArgs e) ReadDocument( ); printpreviewdialog1.document = printdocument1; printpreviewdialog1.showdialog( ); [STAThread] static void Main( ) Application.EnableVisualStyles( ); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1( )); -18-

VB.NET解説

VB.NET解説 Visual Basic.NET 印刷編 目次 印刷の概要... 2 印刷の流れ... 2 標準の Windows フォーム印刷ジョブの作成... 3 実行時に於ける Windows フォーム印刷オプションの変更... 3 Windows フォームに於ける接続されたプリンタの選択... 4 Windows フォームでのグラフィックスの印刷... 5 Windows フォームでのテキストの印刷...

More information

グラフィックス

グラフィックス グラフィックス PictureBox の Image プロパティに関する良く有る勘違い PictureBox に画像を表示する方法と仕て PictureBox の Image プロパティを使う方法と Graphics の DrawImage メソッドを使う方法が有るが 此の 2 つの方法を混同し 正しく理解して居ない事が多い様で有る 例えば 下記に列挙する様な状況が 此れに該当する 1.PictureBox

More information

ICONファイルフォーマット

ICONファイルフォーマット グラフィックス 画像フォーマットエンコーダパラメータ 様々なフォーマットで画像を保存 Bitmap クラスを用いる事でビットマップ JPEG GIF PNG 等様々なフォーマットの画像を読み込み操作する事が出来る 更に Bitmap クラスや Graphics コンテナを用いて描画処理等を施したイメージをファイルに保存する事も出来る 此の時 読み込めるフォーマット同様に保存するフォーマットを選択する事が出来る

More information

VB 資料 電脳梁山泊烏賊塾 音声認識 System.Speech の利用 System.Speech に依るディクテーション ( 音声を文字列化 ).NetFramework3.0 以上 (Visual Studio 2010 以降 ) では 標準で System.Speech が用意されて居るの

VB 資料 電脳梁山泊烏賊塾 音声認識 System.Speech の利用 System.Speech に依るディクテーション ( 音声を文字列化 ).NetFramework3.0 以上 (Visual Studio 2010 以降 ) では 標準で System.Speech が用意されて居るの 音声認識 System.Speech の利用 System.Speech に依るディクテーション ( 音声を文字列化 ).NetFramework3.0 以上 (Visual Studio 2010 以降 ) では 標準で System.Speech が用意されて居るので 此れを利用して音声認識を行うサンプルを紹介する 下記の様な Windows フォームアプリケーションを作成する エディタを起動すると

More information

ファイル操作

ファイル操作 ファイル操作 TextFieldParser オブジェクト ストリームの読込と書込 Microsoft.VisualBasic.FileIO 名前空間の TextFieldParser オブジェクトは 構造化テキストファイルの解析に使用するメソッドとプロパティを備えたオブジェクトで有る テキストファイルを TextFieldParser で解析するのは テキストファイルを反復処理するのと同じで有り

More information

プロセス間通信

プロセス間通信 プロセス間通信 プロセス間通信 (SendMessage) プロセス間通信とは 同一コンピューター上で起動して居るアプリケーション間でデータを受け渡し度い事は時々有る Framework には リモート処理 と謂う方法でデータの受け渡しを行なう方法が有る 此処では 此の方法では無く 従来の方法の API を使用したプロセス間通信を紹介する 此の方法は 送信側は API の SendMessage で送り

More information

ファイル監視

ファイル監視 ファイル操作 ファイルやディレクトリの監視 FileSystemWatcher クラス.NET Framework のクラスライブラリには ファイルやディレクトリの作成 変更 削除を監視する為の FileSystemWatcher クラスが System.IO 名前空間に用意されて居る ( 但し Windows 98/Me では利用出来ない ) 此れを利用すると 特定のディレクトリにファイルが作成された

More information

NotifyIconコントロール

NotifyIconコントロール NotifyIcon コントロール システムトレイ ( タスクトレイ ) にアイコンを表示する.NET Framework 2.0 以降の場合は 後述の 2 を観て欲しい Outlook や MSN Messenger 等の様に Windows アプリケーションではシステムトレイ ( タスクトレイ ステータス領域等とも呼ばれる ) にアイコンを表示して アプリケーションの状態を示したり アプリケーションのフォームを表示したりする為のショートカットとして利用する事が出来る.NET

More information

データアダプタ概要

データアダプタ概要 データベース TableAdapter クエリを実行する方法 TableAdapter クエリは アプリケーションがデータベースに対して実行出来る SQL ステートメントやストアドプロシージャで TableAdapter で型指定されたメソッドと仕て公開される TableAdapter クエリは 所有るオブジェクトのメソッドと同様に 関連付けられたメソッドを呼び出す事に依り実行出来る TableAdapter

More information

API 連携方式 外部 DLL の呼び出し宣言 外部 DLL の呼び出し宣言のサンプルコード (Microsoft Visual C#.NET の場合 ) プログラムコードの先頭で using System.Runtime.InteropServices; が必要 クラスの内部に以下のような外部 D

API 連携方式 外部 DLL の呼び出し宣言 外部 DLL の呼び出し宣言のサンプルコード (Microsoft Visual C#.NET の場合 ) プログラムコードの先頭で using System.Runtime.InteropServices; が必要 クラスの内部に以下のような外部 D GS1-128 の描画 DLL について (ver. 2.2) 動作環境など動作環境 WindowsXP Windows Vista Windows7 Windows8/8.1 Windows10 上記 OS について すべて日本語版を対象としております 32bit アプリケーションから呼び出される必要があります 使用条件 プリンタの解像度 300dpi 以上 機能 バーコードの基本幅を 1 ドット単位で指定できる

More information

ListViewコントロール

ListViewコントロール ListView コントロール ListView コントロールへ項目を追加 本稿では.NET Framework の標準コントロールで有る ListView コントロール (System.Windows.Forms 名前空間 ) を活用する為に ListView コントロールにデータを追加する方法を紹介する ListView コントロールは データ項目をアイコン表示や詳細表示等に依り一覧表示する為の物で

More information

GS1-128 の描画 DLL について (ver. 2.3) 動作環境など動作環境 WindowsXP Windows Vista Windows7 Windows8/8.1 Windows10 上記 OS について すべて日本語版を対象としております 32bit アプリケーションから呼び出される

GS1-128 の描画 DLL について (ver. 2.3) 動作環境など動作環境 WindowsXP Windows Vista Windows7 Windows8/8.1 Windows10 上記 OS について すべて日本語版を対象としております 32bit アプリケーションから呼び出される GS1-128 の描画 DLL について (ver. 2.3) 動作環境など動作環境 WindowsXP Windows Vista Windows7 Windows8/8.1 Windows10 上記 OS について すべて日本語版を対象としております 32bit アプリケーションから呼び出される必要があります 使用条件 プリンタの解像度 300dpi 以上 機能 バーコードの基本幅を 1 ドット単位で指定できる

More information

ファイル操作-バイナリファイル

ファイル操作-バイナリファイル ファイル操作 バイナリ ファイルを読み書きする バイナリファイル ( 即ちテキストファイル以外のファイル ) を読み書きするには FileStream クラス (System.IO 名前空間 ) を利用する FileStream クラスはファイル用のストリームをサポートするクラスで有り Stream クラス (System.IO 名前空間 ) の派生クラスの 1 つで有る 基本的には コンストラクタで指定したファイルのストリームに対して

More information

ルーレットプログラム

ルーレットプログラム ルーレットプログラム VB 2005 4 プログラムの概要 カジノの代表的なゲーム ルーレット を作成する 先ず GO! ボタンをクリックすると ルーレット盤上をボールが回転し 一定時間経過すると ボールが止まり 出目を表示するプログラムを作成する 出目を 1~16 大小 偶数奇数の内から予想して 予め設定した持ち点の範囲内で賭け点を決め 賭け点と出目に依り 1 点賭けの場合は 16 倍 其他は 2

More information

ブロック パニック

ブロック パニック ブロックパニック VB 2005 9 プログラムの概要 壁が迫り来る不思議な空間のオリジナルゲーム ブロックパニック を作成する スタートボタンをクリックし上下左右の矢印キーで白猿を移動させる スペースキーを押すと 向いて居る方向の壁が後退する 左右の壁が合わさると ゲームは終了する 一般的に 実用プログラムに比較するとゲームプログラムは 高度なテクニックを要求される事が多い 此処では ゲームプログラムを作成する事に依り

More information

Userコントロール

Userコントロール User コントロール 初めてのユーザーコントロールの作成 作成したクラスは他のプログラムで再利用出来る為 同じコードを何度も繰り返し作成する必要が無い コントロールも 複数のプロジェクトで再利用出来るクラスで有る 同じユーザーインターフェイスを何度も繰り返してデザインすると謂う経験は 恐らく誰でも有る 例えば 姓と名を入力する為の TextBox コントロールを追加した後で 両方を組み合わせてフルネームを作成するコードを追加する等の作業で有る

More information

スライド 1

スライド 1 C# の基本 ~ ファイル読み込み ~ 今回学ぶ事 今回はファイル読み書きに必要 BinaryReader クラスについて記載する ファイル参照ダイアログである OpenFileDialog クラスについても理解を深める また Bitmap クラスを用いた Bitmap ファイルの読み込み方法についても学ぶ フォーム作り まず label picturebox を配置する ツールボックスより左クリックで選択する

More information

ウィンドウ操作 応用

ウィンドウ操作 応用 Win32API 関数 ウィンドウ操作 ウィンドウ名でトップレベルウィンドウ ( 親を持たないウィンドウ ) のハンドルを取得 メモ帳や電卓等のウィンドウ名でトップレベルウィンドウ ( 親を持たないウィンドウ ) のハンドルを取得する方法を 下記に示す Visual Basic Imports System.Runtime.InteropServices Public Class WindowFromWindowName

More information

VB実用⑫ 印刷Ⅱ(Printerオブジェクト)

VB実用⑫ 印刷Ⅱ(Printerオブジェクト) 印刷 Ⅱ VB 2005 2 プログラムの概要 事務処理に於いて 集計結果等を印刷して 確認等を行う事も多い為 ペーパーレスオフィスが推奨される昨今に於いても 矢張り印刷に関する技術は必要で有る Visual Basic から印刷を行う方法は.NET 以降 PrintDocument オブジェクトを使用する方法が標準機能と仕て一般的で有るが Professional 版等では ReportView

More information

スレッド操作 タイマー

スレッド操作 タイマー スレッド操作 タイマー System.Windows.Forms.Timer Windows フォームの Timer は 一定の間隔でイベントを発生させるコンポーネントで有る 此のコンポーネントは Windows フォーム環境で使用する サーバー環境に適したタイマが必要な場合は 後述の System.Timers.Timer を使用する イベントの発生する間隔は ミリ秒単位で Interval プロパティで設定しする

More information

ブロック崩し風テニス

ブロック崩し風テニス ぱっくんフィッシング VB 2005 13 プログラムの概要 パーティゲームとして良く知られた釣りゲームです マウスで釣り糸を操作して 開閉する魚の口に餌を垂らし 魚が餌を咥えると 釣り上げ 籠の中に入れます 直ぐに口を開けて 海に逃れる魚 中々餌を離さず 籠に入らない魚と 色々なバリエーションが楽しめます 一般的に 実用プログラムに比較するとゲームプログラムは 高度なテクニックを要求される事が多い

More information

グラフィックトレーニング 概要.NET のグラフィック描画は どんなことができるのでしょうか? グラフィックオブジェクトやグラフィック環境 概念を理解するためには クラスを使って馴れることが近道です 本 書に記載されているコードをカットアンドペーストして 一つ一つの機能を体験してください 前提 グラ

グラフィックトレーニング 概要.NET のグラフィック描画は どんなことができるのでしょうか? グラフィックオブジェクトやグラフィック環境 概念を理解するためには クラスを使って馴れることが近道です 本 書に記載されているコードをカットアンドペーストして 一つ一つの機能を体験してください 前提 グラ C# & VB 1 グラフィックトレーニング 概要.NET のグラフィック描画は どんなことができるのでしょうか? グラフィックオブジェクトやグラフィック環境 概念を理解するためには クラスを使って馴れることが近道です 本 書に記載されているコードをカットアンドペーストして 一つ一つの機能を体験してください 前提 グラフィックを行うためには Visual Studio の基本操作や C# または VB

More information

正規表現応用

正規表現応用 正規表現 正規表現を使って文字列が或る形式と一致するか調べる 指定された正規表現のパターンと一致する対象が入力文字列内で見付かるか何うかを調べるには Regex クラスの IsMatch メソッドを使用する 此処では IsMatch メソッドを使った例を幾つか紹介する 猶 正規表現のパターンと一致する個所を探し 見付かれば 其の箇所を抽出する方法は 正規表現を使って文字列を検索し 抽出する で紹介して居る

More information

Microsoft Excel操作

Microsoft Excel操作 Microsoft Excel 操作 Excel ファイルにアクセス リフレクションを利用したレイトバインディングで Excel ファイルを操作 Visual Basic なら CreatObject 関数を使用して 暗黙の遅延バインディングを利用する事に依り 簡単にに実現出来る Excel の操作も C# で実現するには 少し面倒臭い事に成る 事前バインディングでも実装する事も出来るが 事前バインディングだと

More information

C#の基本

C#の基本 C# の基本 ~ 開発環境の使い方 ~ C# とは プログラミング言語のひとつであり C C++ Java 等に並ぶ代表的な言語の一つである 容易に GUI( グラフィックやボタンとの連携ができる ) プログラミングが可能である メモリ管理等の煩雑な操作が必要なく 比較的初心者向きの言語である C# の利点 C C++ に比べて メモリ管理が必要ない GUIが作りやすい Javaに比べて コードの制限が少ない

More information

VB実用⑬ 印刷Ⅲ(PrintFormメソッド)

VB実用⑬ 印刷Ⅲ(PrintFormメソッド) 印刷 Ⅳ VB 2005 4 プログラムの概要 事務処理に於いて 集計結果等を印刷して 確認等を行う事も多い為 ペーパーレスオフィスが推奨される昨今に於いても 矢張り印刷に関する技術は必要で有る Visual Basic から印刷を行う方法は.NET 以降 PrintDocument オブジェクトを使用する方法が 標準機能と仕て一般的で有るが Professional 版等では ReportView

More information

Public Class Class4SingleCall Inherits MarshalByRefObject Public Sub New() End Sub Public Function OneProc(ByVal The As A SC) As A SC Dim The As New A SC The.answer = The.index * 2 + 1000 Return The End

More information

クリッピング領域

クリッピング領域 グラフィックス 領域の利用 GDI+ での領域 領域は 出力デバイスのディスプレイ範囲の一部です 単純な領域 ( 単一の四角形 ) と複雑な領域 ( 複数の多角形と閉じた曲線の組み合わせ ) があります 四角形から構築された領域とパスから構築された領域を次の図に示します 領域の使用 領域は クリッピングとヒットテストに使用されることがよくあります クリッピングでは ディスプレイ範囲の特定の領域 (

More information

Visual Basic 資料 電脳梁山泊烏賊塾 コレクション初期化子 コレクション初期化子 初めに.NET 版の Visual Basic では 其れ迄の Visual Basic 6.0 とは異なり 下記の例の様に変数宣言の構文に 初期値を代入する式が書ける様に成った 其の際 1 の様に単一の値

Visual Basic 資料 電脳梁山泊烏賊塾 コレクション初期化子 コレクション初期化子 初めに.NET 版の Visual Basic では 其れ迄の Visual Basic 6.0 とは異なり 下記の例の様に変数宣言の構文に 初期値を代入する式が書ける様に成った 其の際 1 の様に単一の値 コレクション初期化子 コレクション初期化子 初めに.NET 版の Visual Basic では 其れ迄の Visual Basic 6.0 とは異なり 下記の例の様に変数宣言の構文に 初期値を代入する式が書ける様に成った 其の際 1 の様に単一の値 ( 此処では 10) を代入する丈でなく 2 の配列変数の宣言の様に ブレース { } の中にカンマ区切りで初期値のリストを記述し 配列の各要素に初期値を代入出来る様に成った

More information

VB実用⑪ 印刷Ⅰ(プリンタ設定)

VB実用⑪ 印刷Ⅰ(プリンタ設定) 印刷 Ⅰ VB 2005 1 プログラムの概要 事務処理に於いて 集計結果等を印刷して 確認等を行う事も多い為 ペーパーレスオフィスが推奨される昨今に於いても 矢張り印刷に関する技術は必要で有る Visual Basic から印刷を行う方法は.NET 以降 PrintDocument オブジェクトを使用する方法が標準機能と仕て一般的で有るが Professional 版等では ReportView

More information

ハッシュテーブル

ハッシュテーブル ハッシュテーブル ハッシュテーブル ( 連想配列 ) を使う ハッシュテーブルとは キー (key) と値 (value) のペアを保持して居るコレクションで有る 通常の配列がインデックス番号に依り各値 ( 各要素 ) にアクセス出来るのに比べて ハッシュテーブルでは インデックス番号の代わりにキーを用いて 其の各値にアクセスする事が出来る キーと 其のキーから連想される ( 対応付けられて居る )

More information

DAOの利用

DAOの利用 DAO VB2005 で DAO を使用して Excel のデータを取得 Visual Basic 6.0 Dim DB As DAO.Database Dim RS As DAO.Recordset Dim xlfilename As String Dim xlsheetname As String xlfilename = Form1.StatusBar1.Panels(12) & Dir(Form1.StatusBar1.Panels(12)

More information

パラパラ漫画

パラパラ漫画 パラパラ漫画 VB 2005 3 プログラムの概要 10 枚のピクチャーボックスの夫々れに マウスを左クリックしてドラッグする事に依り 連続線を引き 自由な絵を描く 此の場合 マウスを右クリックする事に依り 新たな線を描き始める事が出来る 描画の対象と成る各ピクチャーボックスは 戻るボタン又は 進むボタンをクリックする事に依り 変更する事が出来る 10 枚の絵を描き終われば ( 途中での再生も可 )

More information

1.dll の配置場所配布時はプログラムの実行フォルダーへ配置 2. 開発環境での使用 プロジェクトのプロパティーで [USBPIO.dll] を参照追加してください 開発環境 dll ファイルの場所 VB.Net Express Edition 境プロジェクトのフォルダ \bin\release VB.Netebugビルドの場合プロジェクトのフォルダ \bin\debug VB.Net Releaseビルドの場合プロジェクトのフォルダ

More information

Secure iNetSuite for .NET 4.0Jの新仕様について

Secure iNetSuite for .NET 4.0Jの新仕様について Secure inetsuite for.net 4.0J の新仕様について グレープシティ株式会社 2013 年 8 月初版 メール送受信とファイル転送機能を実現する通信コンポーネント Secure inet Suite の通信モードの仕様が新しくなりました 本資料では従来のバージョンとの違いとメリットをコードを使って詳しく解説します はじめに 2013 年 9 月発売の Secure FTP for.net

More information

構造体

構造体 構造体 Byte 配列 構造体とコピーする方法 構造体とバイト配列の変換を行うには System.Runtime.InteropServices 名前空間をインポートして置くと便利で有る Imports System.Runtime.InteropServices using System.Runtime.InteropServices; 下記の 3 種類の構造体にバイト配列の値を格納した場合に付いて検証する

More information

Visual Studio2008 C# で JAN13 バーコードイメージを作成 xbase 言語をご利用の現場でバーコードの出力が必要なことが多々あります xbase 言語製品によっては 標準でバーコード描画機能が付加されているものもあるようで す C# では バーコードフォントを利用したりバー

Visual Studio2008 C# で JAN13 バーコードイメージを作成 xbase 言語をご利用の現場でバーコードの出力が必要なことが多々あります xbase 言語製品によっては 標準でバーコード描画機能が付加されているものもあるようで す C# では バーコードフォントを利用したりバー Visual Studio2008 C# で JAN13 バーコードイメージを作成 xbase 言語をご利用の現場でバーコードの出力が必要なことが多々あります xbase 言語製品によっては 標準でバーコード描画機能が付加されているものもあるようで す C# では バーコードフォントを利用したりバーコード OCX や バーコード対応レ ポートツールが豊富にありますので それほど困ることは無いと思われます

More information

WebReportCafe

WebReportCafe 1 1. 概要 WebReportCafe for.net では 生成した PDF に VeriSign の不可視電子署名を付加することができます 電子署名を付加する事により 文書の作成者を証明することができ 作成された PDF を改竄することが不可能になります この文書では WebReportCafe for.net で電子署名を付加するために必要な ドキュメントサイン用 Digital ID の取得と必須ファイル作成

More information

VFD256 サンプルプログラム

VFD256 サンプルプログラム VFD256 サンプルプログラム 目次 1 制御プログラム... 1 2.Net 用コントロール Vfd256 の使い方... 11 2.1 表示文字列の設定... 11 2.2 VFD256 書込み前のクリア処理... 11 2.3 書き出しモード... 11 2.4 表示モード... 12 2.5 表示... 13 2.6 クリア... 13 2.7 接続方法 ボーレートの設定... 13 2.8

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション 1 02 グラフゖックで簡単な図形を描く図形描画プログラム 1 今回作成するゕプリケーションの概要 ボタンをクリックすると図形を描くプログラム 行われる動作 [1] ボタンをクリック [2] そのボタンに対する図形を描く これを使用者とコンピュータの関係で描くと [ 使用者 コンピュータ ] ボタンをクリック [ 使用者 コンピュータ ] 図形を描画して見せる 使用者がコンピュータにすること ボタンをクリック

More information

バスケットボール

バスケットボール バスケットボール きょうつうへんすうせんげん 共通の変数を宣言する ひょうじ 1. ソリューションエクスプローラで コードの表示をクリックする つぎひょうじところしたかこにゅうりょく 2. 次のコードが表示されるので 1の所に 下の囲いのコードを入力する Imports System.Runtime.InteropServices Public Class Basketball にゅうりょく 1 ここに入力する!

More information

目次 はじめに... 3 システムの必要条件... 4 ライセンス認証... 4 アクティベーション... 6 開発... 7 手順 1. アプリケーションの作成... 7 手順 2. データソースの作成と代入... 7 手順 3. テンプレートの作成 手順 4. レポートビューアの追加

目次 はじめに... 3 システムの必要条件... 4 ライセンス認証... 4 アクティベーション... 6 開発... 7 手順 1. アプリケーションの作成... 7 手順 2. データソースの作成と代入... 7 手順 3. テンプレートの作成 手順 4. レポートビューアの追加 SharpShooter Reports.Win 基本的な使い方 Last modified on: November 15, 2012 本ドキュメント内のスクリーンショットは英語表記ですが SharpShooter Reports JP( 日本語版 ) では日本語で表示されま す 目次 はじめに... 3 システムの必要条件... 4 ライセンス認証... 4 アクティベーション... 6 開発...

More information

メール送信

メール送信 メール Visual Basic 2005 でのメール送信 1 System.Net.Mail 名前空間の MailMessage クラスと SmtpClient クラスを使用 メール送信機能の有るアプリケーションを作成する必要が有る場合が有る 其処で 此処では メールの送信機能を持つアプリケーション ( 図 1) の作成方法に付いて紹介する 図 1 Visual Basic 6.0 では Microsoft

More information

倉庫番

倉庫番 倉庫番 VB 2005 63 プログラムの概要 其の昔 一世を風靡し世界中に愛好家の居るパズルゲーム 倉庫番 で有る 荷物 ( 蛸 ) を押して ( 引く事は出来ない ) 所定の場所 ( 壺 ) に納める単純明快な物で有る 猶 一度クリアした面は 自由に再度プレイする事が出来るが 新たな面には 前の面をクリアしないと進む事は出来ない 一般的に 実用プログラムに比較するとゲームプログラムは 高度なテクニックを要求される事が多い

More information

Android Layout SDK プログラミング マニュアル

Android Layout SDK プログラミング マニュアル プログラミングマニュアル Version 1.3.0 用 更新履歴 年月日 バージョン 履歴 2014.09.08 1.2.0.0 新規 (Layout Utilities ユーザーズ ガイド ) 2016.08.16 1.3.0.0 モバイル端末用レイアウトで直線部品と矩形部品に対応 モバイル端末用レイアウトファイルを CLFX から XML へ変更 Layout Print Engine から

More information

VB実用⑦ エクセル操作Ⅰ

VB実用⑦ エクセル操作Ⅰ VB でエクセル操作 Ⅰ VB 2005 7 プログラムの概要 事務処理に於いて Microsoft 社のスプレッドシートソフトで有るエクセルは データベースソフトで有るアクセスと共に 業界標準 (De Facto Standard) で有ると謂う事が出来る 此処では 其のエクセルを Visual Basic から操作する方法を 重点的に学ぶ 今回は Visual Basic でエクセルを利用する基本と成るオブジェクト生成と

More information

mySQLの利用

mySQLの利用 MySQL の利用 インストール インストール時に特に注意点は無い 本稿記述時のバージョンは 6.5.4 で有る (2017 年 11 月現在では 6.10.4 で https://dev.mysql.com/downloads/connector/net/6.10.html よりダウンロード出来る ) 参照設定 インストールが終了すれば Visual Studio で参照の設定を行う 参照の設定画面で

More information

3D回転体プログラム

3D回転体プログラム 3D 回転体プログラム VB 2005 4 プログラムの概要 入力画面で マウスを用いて 側面より見た平面図を描きます マウスの左ボタンをクリックする事で連続線を描き 右ボタンをクリックすると新しい線を描く事が出来る 側面図が完成すると 回転の基本角度を設定して 確定ボタンをクリックすると 平面図を立体図に座標変換する 各軸の回転角度を設定して 表示ボタンをクリックすると 立体図が表示される 各軸の回転角度を変更して

More information

グラフィックス 目次

グラフィックス 目次 WPF チュートリアル Microsoft Expression Blend を使用してボタンを作成する 此のチュートリアルでは WPF のカスタマイズされたボタンを Microsoft Expression Blend を使用して作成する手順に付いて説明する Microsoft Expression Blend の具体的な動作は Extensible Application Markup Language(XAML)

More information

画像閲覧プログラム

画像閲覧プログラム 画像閲覧プログラム VB 2005 3 プログラムの概要 連動するドライブリストボックス ディレクトリリストボックス ファイルリストボックスから画像ファイルを選択してクリックします ピクチャーボックスに選択した画像が実物大で表示される 此の時 画像が表示領域より大きい場合は 画像の大きさに応じてスクロールバーが表示される 此のスクロールバーを操作する事に依り 画像全体を見る事が出来る 終了ボタンをクリックすると

More information

TestDesign for Web

TestDesign for Web 発行日 2012/6/21 発行元 株式会社アープ 本書は Web でのテスト自動化における Test Design の一連の操作方法まとめたものです Test Design のメニューの説明やより詳細な使い方については ユーザーズガイド を参照してください 目次 1. はじめに... 1 2. 環境構築... 2 2.1. Selenium のサイトについて... 2 2.2. Selenium

More information

プリンタ印字用 DLL 取扱説明書

プリンタ印字用 DLL 取扱説明書 プリンタ印字用 DLL 取扱説明書 目次 1 はじめに... 1 2 制御プログラム... 2 2.1 制御プログラムの作成方法... 2 3 easyprn.dll の使い方... 11 3.1 easyprn.dll で使用できるコマンド... 11 3.2 バーコード印字方法... 13 3.3 ロゴの印字... 15 1 はじめに プリンタ印字用 DLL ファイル easyprn.dll

More information

パラパラ漫画

パラパラ漫画 パラパラ漫画 C# 2005 3 プログラムの概要 10 枚のピクチャーボックスの夫々れに マウスを左クリックしてドラッグする事に依り 連続線を引き 自由な絵を描く 此の場合 マウスを右クリックする事に依り 新たな線を描き始める事が出来る 描画の対象と成る各ピクチャーボックスは 戻るボタン又は 進むボタンをクリックする事に依り 変更する事が出来る 10 枚の絵を描き終われば ( 途中での再生も可 )

More information

WebBrowserコントロール

WebBrowserコントロール WebBrowser コントロール Windows アプリケーションで Web ページを表示.NET Framework 2.0 では HTML 等の Web ページを Windows フォーム上に表示する為の WebBrowser コントロール (System.Windows.Forms 名前空間 ) が新たに追加されて居り 非常に手軽に Web ページの表示が出来る様に成って居る (.NET Framework

More information

C#の基本2 ~プログラムの制御構造~

C#の基本2 ~プログラムの制御構造~ C# の基本 2 ~ プログラムの制御構造 ~ 今回学ぶ事 プログラムの制御構造としての単岐選択処理 (If 文 ) 前判定繰り返し処理(for 文 ) について説明を行う また 整数型 (int 型 ) 等の組み込み型や配列型についても解説を行う 今回作るプログラム 入れた文字の平均 分散 標準偏差を表示するプログラム このプログラムでは calc ボタンを押すと計算を行う (value は整数に限る

More information

Windows Layout SDK プログラミング マニュアル

Windows Layout SDK プログラミング マニュアル プログラミングマニュアル Version 1.4.0 用 更新履歴 年月日バージョン履歴 2017.09.29 1.4.0.0 新規 - 2 - CITIZEN SYSTEMS JAPAN ご注意 1. 本書の内容の一部 または全部を無断で転載することは 固くお断りいたします 2. 本書の内容については 事前の予告なしに変更することがあります 3. 本書の内容については万全を期して作成いたしましたが

More information

3軸加速度センサーモジュール MM-2860 書込み済みマイコンプログラム通信コマンド概要

3軸加速度センサーモジュール MM-2860 書込み済みマイコンプログラム通信コマンド概要 アプリケーションノートミニマイコン評価カード CT-298 3 軸加速度センサーモジュール MM-2860 書込み済みマイコンプログラム通信コマンド概要 1. 概要 CT-298 DIP SF9S08C 3 MM-2860 HC9S08QG8-XYZ2_v1.1 PC PC PC HC9S08QG8-XYZ2_v1.1 CodeWorrior http://www.freescale.co.jp/products/8bit/9s08qg.html

More information

テキストファイルの入出力1

テキストファイルの入出力1 テキストファイルの入出力 1 0. 今回の目的前回までは 2 回にわたって繰り返しについて学んできました 今回からテキストファイルの入出力について学ぶことにします 1. テキストファイルへの出力 1.1 テキストファイルについてテキストファイルとは コンピュータで扱うことが出来るファイルの中で最も基本的なファイルであり どの様な OS でもサポートされているファイル形式です Windows においては

More information

3D回転体プログラム

3D回転体プログラム 3D 回転体プログラム C# 2005 4 プログラムの概要 入力画面で マウスを用いて 側面より見た平面図を描きます マウスの左ボタンをクリックする事で連続線を描き 右ボタンをクリックすると新しい線を描く事が出来る 側面図が完成すると 回転の基本角度を設定して 確定ボタンをクリックすると 平面図を立体図に座標変換する 各軸の回転角度を設定して 表示ボタンをクリックすると 立体図が表示される 各軸の回転角度を変更して

More information

エクセル詳細 アドイン

エクセル詳細 アドイン Microsoft Excel 詳細 アドイン Excel アドインの作成 Excel アドインを作成するには ブックを作成し コード ユーザー設定ツールバー 及び メニュー項目を追加して Excel アドインファイルとして保存する 1. 新しいブックを作成してコードを追加し ユーザー設定ツールバー 又は メニューバーを作成する 2.[ ファイル ] メニューの [ プロパティ ] をクリックする

More information

ドライブは安全運転で in 滋賀♪

ドライブは安全運転で in 滋賀♪ 烏賊セーバー VB 2005 71 プログラムの概要 可愛い烏賊が 画面を泳ぐスクリーンセーバーで有る 烏賊の数 背景 ( 黒一色かデスクトップ画面 ) を設定する事が出来る 背景が 黒一色の場合は 単に烏賊が 左右から現れては 反対側に泳いで行く丈だが デスクトップ画面の場合は 徐々に背景が烏賊の形に塗り潰されて行く スクリーンセーバーの本来の目的は ディスプレイの焼き付きを防止する事で有るが 現在では

More information

平成 29 年度卒業研究 初心者のためのゲームプログラミング用 教材の開発 函館工業高等専門学校生産システム工学科情報コース 5 年 25 番細見政央指導教員東海林智也

平成 29 年度卒業研究 初心者のためのゲームプログラミング用 教材の開発 函館工業高等専門学校生産システム工学科情報コース 5 年 25 番細見政央指導教員東海林智也 平成 29 年度卒業研究 初心者のためのゲームプログラミング用 教材の開発 函館工業高等専門学校生産システム工学科情報コース 5 年 25 番細見政央指導教員東海林智也 目次 第 1 章英文アブストラクト第 2 章研究目的第 3 章研究背景第 4 章開発環境第 5 章開発した 2D ゲーム制作ライブラリの概要第 6 章ライブラリの使用方法第 7 章まとめと今後の課題参考文献 1 第 1 章英文アブストラクト

More information

Microsoft Word - VB.doc

Microsoft Word - VB.doc 第 1 章 初めてのプログラミング 本章では カウントアップというボタンを押すと表示されている値が1ずつ増加し カウントダウンというボタンを押すと表示されている値が1ずつ減少する簡単な機能のプログラムを作り これを通して Visual Basic.NET によるプログラム開発の概要を学んでいきます 1.1 起動とプロジェクトの新規作成 Visual Studio.NET の起動とプロジェクトの新規作成の方法を

More information

VB実用Ⅲ⑩ フリーデータベースⅡ

VB実用Ⅲ⑩ フリーデータベースⅡ MySQL の利用 MySQL の ODBC(MyODBC) テキストでは MySQL Connector/ODBC(mysql-connector-odbc-3.51.14-win32.msi) をインストールした場合に付いて解説して居るが 此処では MyODBC(MyODBC-3.51.10-x86-win-32bit.msi) をインストールし myodbc-3.51.06-conv_ujis.zip

More information

CashDrawer ライブラリ API 仕様書 2014/07/09 CashDrawer ライブラリ API 仕様書 Rev / 10

CashDrawer ライブラリ API 仕様書 2014/07/09 CashDrawer ライブラリ API 仕様書 Rev / 10 2014/07/09 CashDrawer ライブラリ API 仕様書 Rev. 00.0.04 1 / 10 目次 1. ファイル構成... 3 2. 環境 3 2.1. 動作環境 OS... 3 2.2. コンパイル時の注意点... 3 2.3. USB ドライバ... 3 3. 関数一覧... 4 3.1. USB 接続確認処理 (CD_checkConnect CD_checkConnect)

More information

PYTHON 資料 電脳梁山泊烏賊塾 PYTHON 入門 関数とメソッド 関数とメソッド Python には関数 (function) とメソッド (method) が有る モジュール内に def で定義されて居る物が関数 クラス内に def で定義されて居る物がメソッドに成る ( 正確にはクラスが

PYTHON 資料 電脳梁山泊烏賊塾 PYTHON 入門 関数とメソッド 関数とメソッド Python には関数 (function) とメソッド (method) が有る モジュール内に def で定義されて居る物が関数 クラス内に def で定義されて居る物がメソッドに成る ( 正確にはクラスが PYTHON 入門 関数とメソッド 関数とメソッド Python には関数 (function) とメソッド (method) が有る モジュール内に def で定義されて居る物が関数 クラス内に def で定義されて居る物がメソッドに成る ( 正確にはクラスがインスタンス化されてからメソッドに成る ) # 関数 def test_func(): print('call test_func') #

More information

かべうちテニス

かべうちテニス かべうちテニス ときみぎうご スタートボタンをクリックした時 ボールを右に動かす がめん 1. デザイン画面で スタートボタン をダブルクリックする つぎひょうじしたかこにゅうりょく 2. 次のコードが表示されるので 下の囲いのコードを入力する Private Sub btnstart_click(byval sender As As System.EventArgs) Handles btnstart.click

More information

(Microsoft Word \203v\203\215\203O\203\211\203~\203\223\203O)

(Microsoft Word \203v\203\215\203O\203\211\203~\203\223\203O) 21113 Visual Basic を利用したフリーソフト開発 要旨 各自でフリーソフトを作成 インターネット上に公開することを目的とし Visual Basic2008 2010 を使い簡単なアプリの作成に成功した 1. 目的情報化が進んだ現代において 社会に出ていくためにはパソコンの一つや二つ 軽く扱えなければならない さらに 資源の乏しい日本においては今後 情報技術の発展することが望ましいと考える

More information

A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3,

A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 40 2 1. 2 2. 52 3. A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2 4. 13 5. 6. 7. 8. 9. 13 10. 11. 12. 1 VC++ VC++ Visual C++ Professional 2010 Visual C++ 2010 express Windows whist 2 OK] 3 Form1 size 800, 500

More information

プログラミング基礎I(再)

プログラミング基礎I(再) 山元進 クラスとは クラスの宣言 オブジェクトの作成 クラスのメンバー フィールド 変数 配列 メソッド メソッドとは メソッドの引数 戻り値 変数の型を拡張したもの 例えば車のデータベース 車のメーカー 車種 登録番号などのデータ データベースの操作 ( 新規データのボタンなど ) プログラムで使う部品の仕様書 そのクラスのオブジェクトを作ると初めて部品になる 継承 などの仕組みにより カスタマイズが安全

More information