NXとは関係なく、ダイアログ部分は普通にVBのフォームを作って処理を書いています。
ダイアログ(フォーム)を作る
普通にVB2005 Express Editionを起動して
メニューの[ファイル]
→[新しいプロジェクト]
→[Windowsアプリケーション]
デフォルトのフォームにボタンなどを追加して以下のようにします。
画像はあらかじめ作っておいた以下の画像をPictureBoxで指定しています。
以上でフォーム部分は終了です。
処理を書く
これも普通にVBで書きました。
ページの幅により改行されているかもしれませんが、そのままコピペできると思います。
呼びや頭、穴寸法などの詳細はコードに埋め込んだボルトや穴の寸法表を見てください。
Private dsArray() As Single = {1.6, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 30, 36, 48, 56, 64} ' 呼び
Private dkArray() As Single = {3, 3, 5.5, 7, 8.5, 10, 13, 16, 18, 24, 30, 36, 45, 54, 72, 84, 96} ' 頭径
Private hkArray() As Single = {1.6, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 30, 36, 48, 56, 64} ' 頭高
Private hdsArray() As Single = {1.8, 2.4, 3.4, 4.5, 5.5, 6.6, 9, 11, 13.5, 17.5, 22, 26, 33, 39, 52, 62, 70} ' 逃がし穴径
Private hdkArray() As Single = {3.5, 4.4, 6.5, 8, 10, 11, 15, 18, 20, 26, 33, 40, 50, 58, 78, 0, 0} ' 座グリ穴径
Private hdtArray() As Single = {1.25, 1.6, 2.5, 3.3, 4.2, 5, 6.75, 8.5, 10.25, 14, 17.5, 21, 26.5, 32, 43, 50.5, 58} ' 下穴径
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sngTmp As Single
' -----呼びリストに追加
For Each sngTmp In dsArray '
ComboBox1.Items.Add("M" & CStr(sngTmp))
Next
' -----初期値
ComboBox1.SelectedIndex = 0
TextBox1.Text = 10
End Sub
' -----cancel
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
' -----OK
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Short
Dim ichk As Short
i = Me.ComboBox1.SelectedIndex
ichk = Me.CheckBox1.Checked ' checked=-1
Me.Close()
End Sub
End Class
通常のVBであればこれで完成なのですが、今回はジャーナルです。
ジャーナルは(多分)1本のソースに全てを書かなければいけないので、通常のVBでは触らないフォームを定義しているコードを探します。今作ったVBのプロジェクトフォルダにあるファイルを順番に見ていったところ、Form1.Designer.vbファイルがそれらしい記述でした。
Partial Class Form1
Inherits System.Windows.Forms.Form
'フォームがコンポーネントの一覧をクリーンアップするために dispose をオーバーライドします。
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Windows フォーム デザイナで必要です。
Private components As System.ComponentModel.IContainer
'メモ: 以下のプロシージャは Windows フォーム デザイナで必要です。
'Windows フォーム デザイナを使用して変更できます。
'コード エディタを使って変更しないでください。
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Label3 = New System.Windows.Forms.Label
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.CheckBox1 = New System.Windows.Forms.CheckBox
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.FormattingEnabled = True
Me.ComboBox1.Location = New System.Drawing.Point(81, 25)
Me.ComboBox1.Margin = New System.Windows.Forms.Padding(4)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(71, 23)
Me.ComboBox1.TabIndex = 0
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(12, 28)
Me.Label1.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(39, 15)
Me.Label1.TabIndex = 1
Me.Label1.Text = "呼び"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(82, 55)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(71, 22)
Me.TextBox1.TabIndex = 3
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(12, 58)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(63, 15)
Me.Label2.TabIndex = 4
Me.Label2.Text = "長さ(L)"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(12, 193)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(70, 23)
Me.Button1.TabIndex = 5
Me.Button1.Text = "OK"
Me.Button1.UseVisualStyleBackColor = True
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(88, 193)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(70, 23)
Me.Button2.TabIndex = 6
Me.Button2.Text = "Cancel"
Me.Button2.UseVisualStyleBackColor = True
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(188, 197)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(295, 15)
Me.Label3.TabIndex = 7
Me.Label3.Text = "独断によりL1=L/2、L2=Lとしています。"
'
'PictureBox1
'
Me.PictureBox1.Image = Global.NXGateCrtBolt.My.Resources.Resources.hcb21
Me.PictureBox1.Location = New System.Drawing.Point(159, 12)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(327, 176)
Me.PictureBox1.TabIndex = 2
Me.PictureBox1.TabStop = False
'
'CheckBox1
'
Me.CheckBox1.AutoSize = True
Me.CheckBox1.Location = New System.Drawing.Point(15, 83)
Me.CheckBox1.Name = "CheckBox1"
Me.CheckBox1.Size = New System.Drawing.Size(90, 19)
Me.CheckBox1.TabIndex = 9
Me.CheckBox1.Text = "穴も作る"
Me.CheckBox1.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(504, 230)
Me.Controls.Add(Me.CheckBox1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.ComboBox1)
Me.Font = New System.Drawing.Font("MS ゴシック", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
Me.Margin = New System.Windows.Forms.Padding(4)
Me.Name = "Form1"
Me.Text = "ボルトの作成"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
End Class
この二つのファイルをジャーナルに組み込んでいきます。
0 件のコメント:
コメントを投稿