NSDPrintScreen メンバ

キーボードのPrintScreenキー(PrtScrキー)を制御する関数です。


●コンストラクタ

名前 説明
NSDPrintScreen NSDPrintScreenを初期化します。
NSDPrintScreenを初期化します(メッセージボックスの自動制御を指定します)。

●メソッドの一覧

名前 引数 戻り値 説明
Dispose なし なし リソースの解放を行います。
※終了時に必ず呼び出します。
PSKLock ( Form, [String], [Integer], [String], [Boolean] ) Boolean プリントスクリーンキーをロックします。
PSKUnLock なし Boolean プリントスクリーンキーのロックを解除します。
PSKLockOrUnLock ( Form, [String], [Integer], [String], [Boolean] ) Boolean プリントスクリーンキーのロック状態を変更します。
IsPSKLock なし Boolean ロック状態を返します。
PSKSubFormLoad ( Form, [String], [String] ) Boolean サブフォームの指定を行います。
PSKSubFormClosed ( Form ) Boolean サブフォームのクローズ処理から呼び出します。
PSKFormActivated ( Form ) Boolean アクティブフォームをセットします。

●NSDPrintScreenコンストラクタの説明

名前:New

機能:NSDPrintScreenのリソースを割り当てます。

@NSDPrintScreenのリソースを割り当てます。

※インスタンスの生成は、基本Formのコンストラクタの先頭で呼び出します。

構文:Public Sub New( Form )

引数:

名前 引数渡しの方法 説明
Form Form 値渡し(ByVal) 基本のフォームを渡します。

戻り値:なし。

使用例:

使用例@

Module Mdl_Main
    Public ClsPub_NSDPrnScr As NSDPrintScreen = Nothing
End Module

Public Class Form1
    Public Sub New()
        ' 必ず、InitializeComponentより前に呼び出します。
        ClsPub_NSDPrnScr = New NSDPrintScreen(Me)

        ' この呼び出しはデザイナーで必要です。
        InitializeComponent()

        ' InitializeComponent()呼び出しの後で初期化を追加します。

    End Sub
End Class

使用例A

Public Class Form1
    Dim ClsPrv_NSDPrnScr As New NSDPrintScreen(Me)
    
    Private Sub Form1_Load(ByVal sender As Object, _
                           ByVal e As System.EventArgs _
                           ) Handles Me.Load
        :
    End Sub

End Class

 

Aメッセージボックスの自動制御を指定してNSDPrintScreenのリソースを割り当てます。

※インスタンスの生成は、基本Formのコンストラクタの先頭で呼び出します。

構文:Public Sub New( Form, NotAutoMessage )

引数:

名前 引数渡しの方法 説明
Form Form 値渡し(ByVal) 基本のフォームを渡します。
NotAutoMessage Boolean 値渡し(ByVal) メッセージボックス用の自動制御を行わない事を指定します。
True :自動制御を行いません。

PSKLockで表示するメッセージを指定した場合は、PSKSubFormClosedPSKFormActivated関数を各フォームのイベントから呼び出す必要があります。


False:自動制御を行います。

戻り値:なし。

使用例:

使用例@

Module Mdl_Main
    Public ClsPub_NSDPrnScr As NSDPrintScreen = Nothing
End Module

Public Class Form1
    Public Sub New()
        ' 必ず、InitializeComponentより前に呼び出します。
        ClsPub_NSDPrnScr = New NSDPrintScreen(Me, True)

        ' この呼び出しはデザイナーで必要です。
        InitializeComponent()

        ' InitializeComponent()呼び出しの後で初期化を追加します。

    End Sub
End Class

使用例A

Public Class Form1
    Dim ClsPrv_NSDPrnScr As New NSDPrintScreen(Me, True)
    
    Private Sub Form1_Load(ByVal sender As Object, _
                           ByVal e As System.EventArgs _
                           ) Handles Me.Load
        :
    End Sub

End Class

 


●NSDPrintScreenメソッドの説明

名前:Dispose

構文:Public Overridable Sub Dispose() Implements IDisposable.Dispos

機能:リソースの解放を行います。

※終了時に必ず呼び出します。

引数:なし。

戻り値:なし。

使用例:

Public Class Form1
    Dim ClsPrv_NSDPrnScr As New NSDPrintScreen(Me)

    ' FormのLoad処理。
    Private Sub Form1_Load( ByVal sender As System.Object, _
                            ByVal e As System.EventArgs _
                          ) Handles MyBase.Load
        Try
            :
        Catch ex As Exception
        Finally
        End Try
    End Sub

    ' FormのClose処理。
    Private Sub Form1_FormClosing( ByVal sender As Object, _
                                   ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                 ) Handles Me.FormClosing
        Try
            ' 解放します。
            ClsPrv_NSDPrnScr.Dispose()
            ClsPrv_NSDPrnScr = Nothing
        Catch ex As Exception
        Finally
        End Try
    End Sub
End Class

 

名前:PSKLock

構文:Public Function PSKLock( Form, [Msg], [HotKeyStartNo], [MsgTitle], [FormForeground] ) As Boolean

機能:プリントスクリーンキーをロックします。

引数:

名前 引数渡しの方法 説明
Form Form 値渡し(ByVal) フォームを渡します。
[Msg] String 値渡し(ByVal) PrintScreenキーが押されたときに表示するメッセージを渡します。(既定値:Nothing)
※メッセージボックスを表示しない場合は、Nothingを指定します。
[HotKeyStartNo] Integer 値渡し(ByVal) ホットキーの開始番号を指定します。(既定値:0)
[MsgTitle] String 値渡し(ByVal) メッセージボックスのタイトルを渡します。(既定値:Nothing)
※Nothingの場合は、Assemblyの名前になります。
[FormForeground] Boolean 値渡し(ByVal) メッセージボックスを表示する時に、フォアグランドにするかを指定します。
True :フォアグランドにします。(既定値)
False:フォアグラウンドにしません。

戻り値:Boolean

戻り値の説明:

True:成功 False:失敗

使用例:

Public Class Form1
    Dim ClsPrv_NSDPrnScr As New NSDPrintScreen(Me)
    Dim BlnCls_PrtScrLock As Boolean    ' True :PrintScreenロック。
                                        ' False:PrintScreenアンロック。

    ' FormのLoad処理。
    Private Sub Form1_Load( ByVal sender As System.Object, _
                            ByVal e As System.EventArgs _
                          ) Handles MyBase.Load
        Try
                :
            ' 現在のロック状態を取得します。
            BlnCls_PrtScrLock = ClsPrv_NSDPrnScr.IsPSKLock()
                :
        Catch ex As Exception
        Finally
        End Try
    End Sub

    ' FormのClose処理。
    Private Sub Form1_FormClosing( ByVal sender As Object, _
                                   ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                 ) Handles Me.FormClosing
        Try
            ' 解放します。
            ClsPrv_NSDPrnScr.Dispose()
            ClsPrv_NSDPrnScr = Nothing
        Catch ex As Exception
        Finally
        End Try
    End Sub

    ' PrintScreenキーのロックまたはロック解除処理。
    Private Sub Button1_Click( ByVal sender As System.Object, _
                               ByVal e As System.EventArgs _
                             ) Handles Button1.Click

        Select Case BlnCls_PrtScrLock
            Case True
                ' PrintScreenキーのロックを解除します。
                ClsPrv_NSDPrnScr.PSKUnLock()
            Case False
                ' PrintScreenキーをロックします。
                ClsPrv_NSDPrnScr.PSKLock(Me, "PrintScreenキーはロックされています。")
        End Select
        ' ロック状態をセットします。
        BlnCls_PrtScrLock = Not BlnCls_PrtScrLock
    End Sub
End Class

 

名前:PSKUnLock

構文:Public Function PSKUnLock() As Boolean

機能:プリントスクリーンキーのロックを解除します。

引数:なし。

戻り値:Boolean

戻り値の説明:

True:成功 False:失敗

使用例:

Public Class Form1
    Dim ClsPrv_NSDPrnScr As New NSDPrintScreen(Me)
    Dim BlnCls_PrtScrLock As Boolean    ' True :PrintScreenロック。
                                        ' False:PrintScreenアンロック。

    ' FormのLoad処理。
    Private Sub Form1_Load( ByVal sender As System.Object, _
                            ByVal e As System.EventArgs _
                          ) Handles MyBase.Load
        Try
                :
            ' 現在のロック状態を取得します。
            BlnCls_PrtScrLock = ClsPrv_NSDPrnScr.IsPSKLock()
                :
        Catch ex As Exception
        Finally
        End Try
    End Sub

    ' FormのClose処理。
    Private Sub Form1_FormClosing( ByVal sender As Object, _
                                   ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                 ) Handles Me.FormClosing
        Try
            ' 解放します。
            ClsPrv_NSDPrnScr.Dispose()
            ClsPrv_NSDPrnScr = Nothing
        Catch ex As Exception
        Finally
        End Try
    End Sub

    ' PrintScreenキーのロックまたはロック解除処理。
    Private Sub Button1_Click( ByVal sender As System.Object, _
                               ByVal e As System.EventArgs _
                             ) Handles Button1.Click

        Select Case BlnCls_PrtScrLock
            Case True
                ' PrintScreenキーのロックを解除します。
                ClsPrv_NSDPrnScr.PSKUnLock()
            Case False
                ' PrintScreenキーをロックします。
                ClsPrv_NSDPrnScr.PSKLock(Me, "PrintScreenキーはロックされています。")
        End Select
        ' ロック状態をセットします。
        BlnCls_PrtScrLock = Not BlnCls_PrtScrLock
    End Sub
End Class

 

名前:PSKLockOrUnLock

構文:Public Function PSKLockOrUnLock( Form, [Msg], [HotKeyStartNo], [MsgTitle], [FormForeground] ) As Boolean

機能:プリントスクリーンキーのロック状態を変更します。

ロック状態の場合は、ロックを解除します。
ロック解除状態の場合は、ロックを行います。
引数は、ロック状態にする場合に使用します。

引数:

名前 引数渡しの方法 説明
Form Form 値渡し(ByVal) フォームを渡します。
[Msg] String 値渡し(ByVal) PrintScreenキーが押されたときに表示するメッセージを渡します。(既定値:Nothing)
※メッセージボックスを表示しない場合は、Nothingを指定します。
[HotKeyStartNo] Integer 値渡し(ByVal) ホットキーの開始番号を指定します。(既定値:0)
[MsgTitle] String 値渡し(ByVal) メッセージボックスのタイトルを渡します。(既定値:Nothing)
※Nothingの場合は、Assemblyの名前になります。
[FormForeground] Boolean 値渡し(ByVal) メッセージボックスを表示する時に、フォアグランドにするかを指定します。
True :フォアグランドにします。(既定値)
False:フォアグラウンドにしません。

戻り値:Boolean

戻り値の説明:

現在のロック状態を返します。
True :ロック状態。
False:ロック解除状態。

使用例:

Public Class Form1
    Dim ClsPrv_NSDPrnScr As New NSDPrintScreen(Me)
    Dim BlnCls_PrtScrLock As Boolean    ' True :PrintScreenロック。
                                        ' False:PrintScreenアンロック。

    ' FormのLoad処理。
    Private Sub Form1_Load( ByVal sender As System.Object, _
                            ByVal e As System.EventArgs _
                          ) Handles MyBase.Load
        Try
                :
            ' 現在のロック状態を取得します。
            BlnCls_PrtScrLock = ClsPrv_NSDPrnScr.IsPSKLock()
                :
        Catch ex As Exception
        Finally
        End Try
    End Sub

    ' FormのClose処理。
    Private Sub Form1_FormClosing( ByVal sender As Object, _
                                   ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                 ) Handles Me.FormClosing
        Try
            ' 解放します。
            ClsPrv_NSDPrnScr.Dispose()
            ClsPrv_NSDPrnScr = Nothing
        Catch ex As Exception
        Finally
        End Try
    End Sub

    ' PrintScreenキーのロックまたはロック解除処理。
    Private Sub Button1_Click( ByVal sender As System.Object, _
                               ByVal e As System.EventArgs _
                             ) Handles Button1.Click
        BlnCls_PrtScrLock = ClsPrv_NSDPrnScr.PSKLockOrUnLock(Me, _
                                "PrintScreenキーはロックされています。")
    End Sub
End Class

 

名前:IsPSKLock

構文:Public Function IsPSKLock() As Boolean

機能:ロック状態を返します。

引数:なし。

戻り値:Boolean

戻り値の説明:

True:ロック状態 False:ロック解除状態

使用例:

Public Class Form1
    Dim ClsPrv_NSDPrnScr As New NSDPrintScreen(Me)
    Dim BlnCls_PrtScrLock As Boolean    ' True :PrintScreenロック。
                                        ' False:PrintScreenアンロック。

    ' FormのClose処理。
    Private Sub Form1_FormClosing( ByVal sender As Object, _
                                   ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                 ) Handles Me.FormClosing
        Try
            ' 解放します。
            ClsPrv_NSDPrnScr.Dispose()
            ClsPrv_NSDPrnScr = Nothing
        Catch ex As Exception
        Finally
        End Try
    End Sub

    ' 現在のロック状態を取得します。
    Private Sub Button1_Click( ByVal sender As System.Object, _
                               ByVal e As System.EventArgs _
                             ) Handles Button1.Click
        ' 現在のロック状態を取得します。
        BlnCls_PrtScrLock = ClsPrv_NSDPrnScr.IsPSKLock()
    End Sub
End Class

 

名前:PSKSubFormLoad

構文:Public Function PSKSubFormLoad( Form, [Msg], [MsgTitle] ) As Boolean

機能:サブフォームの指定を行います。

Loadイベントから呼び出します。
PSKLockまたは、PSKLockOrUnLockでロック状態になっているときのみ、メッセージ、フォームを保持します。

引数:

名前 引数渡しの方法 説明
Form Form 参照渡し(ByRef) サブフォームを渡します。
[Msg] String 値渡し(ByVal) PrintScreenキーが押されたときに表示するメッセージを渡します。(既定値:Nothing)
※Nothingの場合は、1階層上のメッセージ内容が表示されます。
[MsgTitle] String 値渡し(ByVal) メッセージボックスのタイトルを渡します。(既定値:Nothing)
※Nothingの場合は、1階層上のタイトルが表示されます。

戻り値:Boolean

戻り値の説明:

True:成功 False:失敗

使用例:

Module Mdl_Main
    Public ClsPub_NSDPrnScr As NSDPrintScreen = Nothing
End Module

Public Class Form1
    Public Sub New()
        ' 必ず、InitializeComponentより前に呼び出します。
        ClsPub_NSDPrnScr = New NSDPrintScreen(Me)

        ' この呼び出しはデザイナーで必要です。
        InitializeComponent()                                                                                 

        ' InitializeComponent()呼び出しの後で初期化を追加します。

    End Sub

    ' FormのClose処理。
    Private Sub Form1_FormClosing( ByVal sender As Object, _
                                   ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                 ) Handles Me.FormClosing
        Try
            ' 解放します。
            ClsPub_NSDPrnScr.Dispose()
            ClsPub_NSDPrnScr = Nothing
        Catch ex As Exception
        Finally
        End Try
    End Sub
End Class

Public Class Form2
    ' サブフォームのLoad処理。
    Private Sub Form2_Load( ByVal sender As System.Object, _
                            ByVal e As System.EventArgs _
                          ) Handles MyBase.Load
        ClsPub_NSDPrnScr.PSKSubFormLoad(Me, _
                          Me.Text & "を表示" & _
                          "PrintScreenキーはロックされています。", _
                          Me.Text)
    End Sub
End Class

 

名前:PSKSubFormClosed

構文:Public Function PSKSubFormClosed( Form ) As Boolean

機能:サブフォームのクローズ処理から呼び出します。

PSKSubFormLoadを記述したフォームのClosedに必ず記述します。
NSDPrintScreenクラスのSub Newの第二引数をTrueで指定したときのみ記述します。

引数:

名前 引数渡しの方法 説明
Form Form 参照渡し(ByRef) サブフォームを渡します。

戻り値:Boolean

戻り値の説明:

True:成功 False:失敗

使用例:

Module Mdl_Main
    Public ClsPub_NSDPrnScr As NSDPrintScreen = Nothing
End Module

Public Class Form1
    Public Sub New()
        ' 必ず、InitializeComponentより前に呼び出します。
        ClsPub_NSDPrnScr = New NSDPrintScreen(Me, True)

        ' この呼び出しはデザイナーで必要です。
        InitializeComponent()

        ' InitializeComponent()呼び出しの後で初期化を追加します。

    End Sub

    ' FormのActivated処理。
    Private Sub Form1_Activated( ByVal sender As Object, _
                                 ByVal e As System.EventArgs _
                               ) Handles MyBase.Activated
        ' アクティブフォームをセットします。
        ClsPub_NSDPrnScr.PSKFormActivated(Me)
    End Sub

    ' FormのClose処理。
    Private Sub Form1_FormClosing( ByVal sender As Object, _
                                   ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                 ) Handles Me.FormClosing
        Try
            ' 解放します。
            ClsPub_NSDPrnScr.Dispose()
            ClsPub_NSDPrnScr = Nothing
        Catch ex As Exception
        Finally
        End Try
    End Sub
End Class

Public Class Form2
    ' FormのLoad処理。
    Private Sub Form2_Load( ByVal sender As System.Object, _
                            ByVal e As System.EventArgs _
                          ) Handles MyBase.Load
        ClsPub_NSDPrnScr.PSKSubFormLoad(Me, _
                          Me.Text & "を表示" & _
                          "PrintScreenキーはロックされています。", _
                          Me.Text)
    End Sub

    ' FormのActivated処理。
    Private Sub Form2_Activated( ByVal sender As Object, _
                                 ByVal e As System.EventArgs _
                               ) Handles MyBase.Activated
        ' アクティブフォームをセットします。
        ClsPub_NSDPrnScr.PSKFormActivated(Me)
    End Sub

    ' FormのClose処理。
    Private Sub Form2_Closed( ByVal sender As Object, _
                              ByVal e As System.EventArgs _
                            ) Handles MyBase.Closed
        ClsPub_NSDPrnScr.PSKSubFormClosed(Me)
    End Sub
End Class

 

名前:PSKFormActivated

構文:Public Function PSKFormActivated( Form ) As Boolean

機能:アクティブフォームをセットします。

NSDPrintScreenクラスのSub Newの第二引数をTrueで指定したときのみActivatedイベントから呼び出します。
フォームのActivatedに必ず記述します。

引数:

名前 引数渡しの方法 説明
Form Form 値渡し(ByVal) フォームを渡します。

戻り値:Boolean

戻り値の説明:

True:成功 False:失敗

使用例:

Module Mdl_Main
    Public ClsPub_NSDPrnScr As NSDPrintScreen = Nothing
End Module

Public Class Form1
    Public Sub New()
        ' 必ず、InitializeComponentより前に呼び出します。
        ClsPub_NSDPrnScr = New NSDPrintScreen(Me)

        ' この呼び出しはデザイナーで必要です。
        InitializeComponent()

        ' InitializeComponent()呼び出しの後で初期化を追加します。

    End Sub

    ' FormのActivated処理。
    Private Sub Form1_Activated( ByVal sender As Object, _
                                 ByVal e As System.EventArgs _
                               ) Handles MyBase.Activated
        ' アクティブフォームをセットします。
        ClsPub_NSDPrnScr.PSKFormActivated(Me)
    End Sub

    ' FormのClose処理。
    Private Sub Form1_FormClosing( ByVal sender As Object, _
                                   ByVal e As System.Windows.Forms.FormClosingEventArgs _
                                 ) Handles Me.FormClosing
        Try
            ' 解放します。
            ClsPub_NSDPrnScr.Dispose()
            ClsPub_NSDPrnScr = Nothing
        Catch ex As Exception
        Finally
        End Try
    End Sub
End Class

Public Class Form2
    ' FormのLoad処理。
    Private Sub Form2_Load( ByVal sender As System.Object, _
                            ByVal e As System.EventArgs _
                          ) Handles MyBase.Load
        ClsPub_NSDPrnScr.PSKSubFormLoad(Me, _
                          Me.Text & "を表示" & _
                          "PrintScreenキーはロックされています。", _
                          Me.Text)
    End Sub

    ' FormのActivated処理。
    Private Sub Form2_Activated( ByVal sender As Object, _
                                 ByVal e As System.EventArgs _
                               ) Handles MyBase.Activated
        ' アクティブフォームをセットします。
        ClsPub_NSDPrnScr.PSKFormActivated(Me)
    End Sub

    ' FormのClose処理。
    Private Sub Form2_Closed( ByVal sender As Object, _
                              ByVal e As System.EventArgs _
                            ) Handles MyBase.Closed
        ClsPub_NSDPrnScr.PSKSubFormClosed(Me)
    End Sub
End Class

Copyright (C) 2011 Nihon System Developer Corp. All Rights Reserved.