たじけん氏のブログにインスパイアされて、久しぶりにプログラミングしてみた。こんな感じ⇒「MessageBoxMaker」 まあどこにでもあるようなプログラムだけど。
たじけん氏のブログにあるような画像を作ろうと思ったら、以下の手順。
- 「MessageBoxMaker」を起動
- 各箇所を適当に入力・設定
- 「作成」ボタンを押す
- メッセージボックスが出てくるので、内容を確認
- 「Alt」キーを押しながら「PrintScreen」キーを押す
- MicrosoftPhotoEditor(あるいはペイント等)を起動
- 「新しいイメージとして貼り付け」あるいは「新規作成」⇒「貼り付け」
- 「名前を付けて保存」
で、例えばこんな感じ⇒
この画像を作るところまでプログラム内で扱いたいな~って思ってたんだけど、少し時間がかかりそうな気がしたので、とりあえずできたところまで公開してみた。誰かわかる人、教えて下さい。
プログラム自体は全然たいしたことはしてなくて、この前インストールしたフリー版のVisualBasic.NET2005ExpressEditionを使ってみたかっただけ。
とりあえず使ってみた印象としては、予想以上にVB6とは違うけど、予想以上に使いやすいかも、という感じ。IDEがとても重くなっているんだけど、その分いろいろ手助けしてくれてる。VB6⇒VB2005への乗り換え、本気で考えてみようかな~。
今回のコードはこんな感じ。適当に作りすぎ?
-----
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Button1(作成ボタン)を押した際の挙動
Dim buttonType As MessageBoxButtons 'Buttonタイプ格納
Dim iconType As MessageBoxIcon 'Iconタイプ格納
'Iconタイプを判別
Dim Items As String = ComboBox1.SelectedItem
'Iconタイプの決定
Select Case Items
Case "-"
iconType = MessageBoxIcon.None
Case "Asterisk"
iconType = MessageBoxIcon.Asterisk
Case "Error"
iconType = MessageBoxIcon.Error
Case "Exclamation"
iconType = MessageBoxIcon.Exclamation
Case "Hand"
iconType = MessageBoxIcon.Hand
Case "Information"
iconType = MessageBoxIcon.Information
Case "Question"
iconType = MessageBoxIcon.Question
Case "Stop"
iconType = MessageBoxIcon.Stop
Case "Warning"
iconType = MessageBoxIcon.Warning
Case Else
iconType = MessageBoxIcon.None
End Select
'ボタンタイプの判別
Dim buttons As String = ComboBox2.SelectedItem
'ボタンタイプの決定
Select Case buttons
Case "AbortRetryIgnore"
buttonType = MessageBoxButtons.AbortRetryIgnore
Case "OK"
buttonType = MessageBoxButtons.OK
Case "OKCancel"
buttonType = MessageBoxButtons.OKCancel
Case "RetryCancel"
buttonType = MessageBoxButtons.RetryCancel
Case "YesNo"
buttonType = MessageBoxButtons.YesNo
Case "YesNoCancel"
buttonType = MessageBoxButtons.YesNoCancel
Case Else
MessageBox.Show(Me, "ボタンタイプを選択してから再度「作成」ボタンを押してください")
Exit Sub
End Select
MessageBox.Show(Me, TextBox2.Text, TextBox1.Text, buttonType, iconType)
End Sub
End Class
-----
アイコンタイプのAsteriskとInformation、ErrorとHandとStop、ExcalmationとWarningが同じように見えるんだけど・・・違いがよくわからない。
最近のコメント