Option Strict Off
Option Explicit On
'------------------------------------ 2024/04/01 ------------------------------------
Public Class frmDlgIconList

#Region "宣言"
    Private mMe_gmDlgID As Integer = 0
    Private mNew実行中 As Boolean = True
    Private mLoading As Boolean
    '--------------------------------------
    Private Const cListMax As Short = 400
    Private Const cListColX As Short = 20
    Private Const cSpaceLRTBXY As Short = 6
    Private Const cListItemWDHT As Short = 32
    Private Const cListSpaceXY As Short = 4
    Private Const cMsMoveChkPixel As Short = 5
    Private Const gcBOX_KeyDown As Integer = 697852
    Private Const gcBOX_KeyUp As Integer = 238975
    Private Const gcPropGet As Short = 11258
    Private Const gcPropLet As Integer = 394587
    '--------------------------------------
    Private BoxICO As New 五clsIconShowBox
    Private mPct座標ズレX As Integer = 0, mPct座標ズレY As Integer = 0
    '--------------------------------------
    Private mLists(cListMax) As RECT
    Private mListsChkBox(cListMax) As RECT
    Private mListCur As Integer
    Private mファイル名配列(cListMax) As String
    Private m選択ファイル名 As String
    '--------------------------------------
    Private mアイコンファイルフォルダ履歴 As String = ""
    '**************************************************************************************************************************************
    Private WithEvents イベントgAppEventMaker As 五clsEventMaker
    '**************************************************************************************************************************************
#End Region

#Region "zzAppIniFileOp"
    Private Function zzAppIniFileOp(ByVal Load_0_QueryUnload_1_Resize_2_DoIniSave_3 As Long) As Boolean
        '読出し時に　INI ファイルが存在しない場合は　False　を返します。
        If gggAppIniFile Is Nothing Then Return False
        Return gggAppIniFile.aaAppIniFileOp_フォームサイズと位置だけ_共通処理(Load_0_QueryUnload_1_Resize_2_DoIniSave_3, Me, "-" & Me.Text)
    End Function
#End Region

#Region "Form イベント"
    Public Sub New()
        If gmFlagアイコン設定Dlg_Load_Is_TMP = True Then
            gmFlagアイコン設定Dlg_Load_Is_TMP = False
            Return
        End If
        '-----------------------------------------
        mNew実行中 = True
        ' この呼び出しは、Windows フォーム デザイナで必要です。
        InitializeComponent()
        ' InitializeComponent() 呼び出しの後で初期化を追加します。
    End Sub
    Friend Function aaダイアログShow1(ByVal rOwner As Form, ByVal rMe_gmDlgID As Integer, ByVal rMe_Text As String) As Boolean
        mMe_gmDlgID = rMe_gmDlgID
        mNew実行中 = False
        mLoading = True
        イベントgAppEventMaker = gAppEventMaker
        '**********************************************************************************************************
        'アプリスタート時の　ooウロウロ As New 五clsUrouroPoipoi --> aa文字データー基本配列の設定() から呼び出しているが、
        'そこでは　ダイアログはすぐに　DisPose　されるので、、
        '再度の呼び出しが必要
        Dim tmp_mListMax As Integer
        gggbol = aaアイコンリストデーター初期設定(tmp_mListMax, mLists)
        '**********************************************************************************************************
        '--------------------------------------
        Call frmMain.aaアイコンリスト画像操作(2, pctREF)
        '--------------------------------------
        With pctREF
            mPct座標ズレX = .Left + ((.Width - .ClientRectangle.Width) \ 2)
            mPct座標ズレY = .Top + ((.Height - .ClientRectangle.Height) \ 2)
        End With
        '--------------------------------------
        gggbol = ⅩImage_新規作成_再作成(picoCur.Image, 50, 50)
        '--------------------------------------
        With pbak
            Dim 座標ズレX As Integer = .Left + ((.Width - .ClientRectangle.Width) \ 2)
            Dim 座標ズレY As Integer = .Top + ((.Height - .ClientRectangle.Height) \ 2)
            Call BoxICO.StartSizeSeting(pbak, pico, scr, cListItemWDHT, cListItemWDHT, cListSpaceXY, 座標ズレX, 座標ズレY)
        End With
        gggbol = ⅩImageClear(pico.Image, pico.BackColor) '2024/03/23 エラー修正
        '--------------------------------------
        gggbol = ⅩImage_新規作成_再作成(pctDrag.Image, 50, 50)
        With pctREF
            Dim n As Integer = cSpaceLRTBXY + (cListItemWDHT + cListSpaceXY) * cListColX + cSpaceLRTBXY - cListSpaceXY + (.Width - .ClientRectangle.Width)
            .SetBounds(.Left, .Top, n, n)
        End With
        mListCur = 0
        mLoading = False
        btnアプリの規定に戻す.Enabled = True
        btn設定を有効にして閉じる.Enabled = False
        gggbol = zzMousEventsFlagsClear()
        '--------------------------------------
        If Not zzAppIniFileOp(0) Then gggint = ⅩFormMove(gcoフォームをスクリーン中心に移動, Me) 'INI ファイルが存在しない場合に、このフォームを画面のセンターに表示するコード。
        gggbol = イベントgAppEventMaker.MakeEventフォームの表示消去(mMe_gmDlgID, True)
        gggbol = ⅩForm_OwnerSet_IconSet_TextSet(Me, rMe_Text, frmMain)
        Me.ShowDialog()
    End Function
    Private Sub frmDlgIconList_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing
        gggbol = イベントgAppEventMaker.MakeEventフォームの表示消去(mMe_gmDlgID, False)
        gggint = zzAppIniFileOp(2)
        gggint = zzAppIniFileOp(1)
    End Sub
    Friend Function aaアイコンリストデーター初期設定(ByRef wListMax As Integer, ByRef wLists() As RECT) As Boolean
        Dim xx, yy, n, a, b, c As Integer
        wListMax = cListMax : ReDim wLists(wListMax)
        '------------------------
        n = cListItemWDHT + cListSpaceXY
        c = cListSpaceXY \ 2
        For a = 0 To cListMax - 1
            xx = cSpaceLRTBXY + (a Mod cListColX) * n
            yy = cSpaceLRTBXY + (a \ cListColX) * n
            b = a + 1
            Call SetRect(mLists(b), xx, yy, xx + cListItemWDHT, yy + cListItemWDHT)
            Call CopyRect(wLists(b), mLists(b))
            '------------------------------------------
            Call CopyRect(mListsChkBox(b), mLists(b))
            gggbol = InflateRect(mListsChkBox(b), c, c)
        Next
        '------------------------
        '2018/01/04  使用しないが、共有クラスが必要とする場合があるので、ダミーを設定しておく。
        For a = 0 To cListMax
            mファイル名配列(a) = "*"
        Next
        m選択ファイル名 = ""
    End Function
#End Region

#Region "コントロール イベント"
    Private Sub btn新しくファイルを選択_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn新しくファイルを選択.Click
        Try
            '複数のファイルを開く
            Dim FD As New 五clsFileDlgPathMenu : Dim wPath As String = "" : Dim wFullNames() As String = {""}
            If FD.ファイルダイアログ表示してファイルを選択(2, "複数のアイコンファイルを読出し　　■■　選択ファイル群の数は、空きリストの数以下にしてください。■■", "アイコンファイル (*.ico)|*.ico|実行ファイル (*.exe)|*.exe", mアイコンファイルフォルダ履歴, wPath, wFullNames) Then
                Me.Cursor = Cursors.WaitCursor
                '0ベースの配列を 1からの配列に変換
                Dim max As Integer = Ⅹ文配列をゼロベースから壱ベースにする(wFullNames)
                '-----------------------------------------------------------------------
                gggbol = zListNewSetDoEvent(wPath, wFullNames)
                Me.Cursor = Cursors.Default
            End If
        Catch
            MsgBox("btn新しくファイルを選択_Click() " & vbCrLf & ErrorToString())
        End Try
    End Sub
    Private Sub btnWinIcon_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWinIcon.Click
        Dim p As String = ⅩSysFolderSystem()
        Dim f() As String = {""} : ReDim f(1) : f(1) = "Shell32.dll"
        Me.Cursor = Cursors.WaitCursor
        gggbol = zListNewSetDoEvent(p, f)
        Me.Cursor = Cursors.Default
    End Sub
    Private Function zListNewSetDoEvent(ByRef p As String, ByRef f() As String) As Boolean
        Try
            Dim oldCount As Integer
            oldCount = BoxICO.IconsShow(Me, pctREF.Image, p, f, pbak, pico, scr, lbl)
            If ListCount() > 0 Then CurListIndex = 1
            Return True
        Catch ex As Exception
            MsgBox("ERROR in zListNewSetDoEvent()" & gggCR2 & ex.ToString)
            Return False
        End Try
    End Function
    Private Sub scr_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles scr.Scroll
        Select Case e.Type
            Case System.Windows.Forms.ScrollEventType.EndScroll
                scr_Change(e.NewValue)
        End Select
    End Sub
    Private Sub scr_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles scr.ValueChanged
        Call BoxICO.Event_VscbarChange(pico, picoCur, scr)
        Call scr_Change_pctCurSet()
    End Sub
    Private Sub scr_Change(ByVal newScrollValue As Integer)
        Call BoxICO.Event_VscbarChange(pico, picoCur, scr)
        Call scr_Change_pctCurSet()
    End Sub
    Private Sub scr_Change_pctCurSet()
        picoCur.Top = pico.Top + BoxICO.aa_mpico_picoCur_Y_Offset()
        With pbak
            Dim n As Integer = (.Height - .ClientRectangle.Height) \ 2
            Dim y1 As Integer = pbak.Top + n
            Dim y2 As Integer = pbak.Bottom - n
            With picoCur
                Dim v As Boolean = .Visible
                .Visible = (v And .Top >= y1 And .Bottom <= y2)
            End With
        End With
    End Sub
    Private Sub btnアプリの規定に戻す_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnアプリの規定に戻す.Click
        Dim msg As String = "現在の変更されているアイコンリストを" & gggCR2 & "このアプリの既定のリストに戻しますか？"
        If Not ⅩMsgBox_Yes_TRUE_No_FALSE("アプリの規定のアイコンリストに戻す", msg) Then Return
        Call frmMain.aaアイコンリスト画像操作(5, pctREF)
        btnアプリの規定に戻す.Enabled = False
        btn設定を有効にして閉じる.Enabled = False
    End Sub
    Private Sub btn設定を有効にして閉じる_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn設定を有効にして閉じる.Click
        Call frmMain.aaアイコンリスト画像操作(3, pctREF)
        Me.Close()
    End Sub
    Private Sub btnキャンセル_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnキャンセル.Click
        Me.Close()
    End Sub
#End Region

#Region "プロパティ"
    Public ReadOnly Property ListCount() As Integer
        '有効なリストの数　　読み出し専用。
        Get
            Return BoxICO.ItemCount
        End Get
    End Property
    Public Property CurListIndex() As Integer
        '選択されているアイコン／イメージのリストインデックス。　実行時にのみ使用可能。保存しない。
        Get
            Return CurListIndexOp(gcPropGet)
        End Get
        Set(ByVal Value As Integer)
            Call CurListIndexOp(gcPropLet, Value)
        End Set
    End Property
    Private Function CurListIndexOp(ByRef op As Integer, Optional ByRef v As Integer = 0) As Integer
        Try
            Select Case op
                Case gcPropGet
                    Return BoxICO.CurListIndex(Nothing, Nothing, Nothing)
                Case gcPropLet
                    If v < 0 Or v > ListCount() Then Exit Function 'ここで nnn の正当性をチェックする。
                    Dim Old As Integer = CurListIndex()
                    BoxICO.CurListIndex(pico, picoCur, lbl) = v
                    picoCur.Visible = (CurListIndex > 0)
                    Return v
            End Select
        Catch ex As Exception
            MsgBox(ErrorToString())
            Return 0
        End Try
    End Function
    Public Function IconLabelCurrent() As String
        '選択されているアイコンのラベル文字列、あるいはユーザー設定文字列
        Return BoxICO.FileLabelGetSet(1, "", lbl)
    End Function
    Public Function FileFromIconLabelCurrent(ByRef wIconIndex As Integer) As String
        '選択されているアイコンのラベル文字列から、アイコンのファイル名とアイコンインデックスを返す。
        Return ⅩIconFileNameIndexConv(2, IconLabelCurrent, wIconIndex)
    End Function
#End Region

#Region "ドラッグドロップ　と　コピー移動"
    Private Function zzアイコンを追加するために最後尾を外す() As Boolean
        If (CurListIndex > 0 Or mListCur > 0) And mListDropPos > 0 Then
            Dim g As Graphics = Graphics.FromImage(pctREF.Image)
            If g IsNot Nothing Then
                Dim 田 As Rectangle
                For a As Integer = cListMax To mListDropPos + 1 Step -1
                    田.X = mLists(a).lll
                    田.Y = mLists(a).ttt
                    田.Width = cListItemWDHT
                    田.Height = cListItemWDHT
                    g.DrawImage(pctREF.Image, 田, mLists(a - 1).lll, mLists(a - 1).ttt, cListItemWDHT, cListItemWDHT, GraphicsUnit.Pixel)
                Next
                g.Dispose()
                Return True
            End If
        End If
        Return False
    End Function
    Private Function zzアイコンを現在位置にコピー(ByVal pct As PictureBox) As Boolean
        If (CurListIndex > 0 Or mListCur > 0) And mListDropPos > 0 Then
            gggbol = ⅩImage_Image_Copy(pctREF.Image, pct.Image, mLists(mListDropPos).lll, mLists(mListDropPos).ttt, cListItemWDHT, cListItemWDHT, 5, 5, -1, -1)
            Return True
        End If
        Return False
    End Function
    Private Sub pctREF_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pctREF.MouseDown
        Dim wIsMoveDownToUp As Boolean
        '2024/03/24 エラーの訂正**************************************************
        gggbol = zzMousEventsFlagsClear() 'PopMenuが表示されても、コード実行はストップしないで、フラッグ設定がクリアされてしまう。
        '2024/03/24 エラーの訂正**************************************************
        gggbol = Ⅹマウスイベント検査2022(gcoMsDown, e.Button, e.X, e.Y, 3, 3, 3, 3, wIsMoveDownToUp)
        Dim cxxx As Integer = e.X : Dim cyyy As Integer = e.Y
        For a As Integer = 1 To cListMax
            If ⅩRect内にXY座標がある(cxxx, cyyy, mListsChkBox(a)) Then
                mListCur = a
                Exit For
            End If
        Next
        If mListCur < 1 Then
            pctDrag.Visible = False
        Else
            pctDrag.Visible = True
            Dim xxx As Integer = mPct座標ズレX + mLists(mListCur).lll
            Dim yyy As Integer = mPct座標ズレY + mLists(mListCur).ttt
            With mLists(mListCur)
                pctDrag.SetBounds(xxx - 5, yyy - 5, .rrr - .lll + 10, .bbb - .ttt + 10, BoundsSpecified.All)
                gggbol = ⅩImage_Image_Copy(pctDrag.Image, pctREF.Image, 4, 4, cListItemWDHT + 2, cListItemWDHT + 2, .lll - 1, .ttt - 1, -1, -1)
            End With
        End If
    End Sub
    Private Sub pctREF_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pctREF.MouseMove
        Dim wIsMoveDownToUp As Boolean
        gggbol = Ⅹマウスイベント検査2022(gcoMsMove, e.Button, e.X, e.Y, 3, 3, 3, 3, wIsMoveDownToUp)
    End Sub
    Private Sub pctREF_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pctREF.MouseUp
        Dim wIsMoveDownToUp As Boolean
        gggbol = Ⅹマウスイベント検査2022(gcoMsUp, e.Button, e.X, e.Y, 3, 3, 3, 3, wIsMoveDownToUp)
    End Sub
    Private Sub pctDrag_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pctDrag.MouseDown
        gggbol = zzPctDragIcoCur_COM(1, False, pctDrag, sender, e)
    End Sub
    Private Sub pctDrag_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pctDrag.MouseMove
        gggbol = zzPctDragIcoCur_COM(2, False, pctDrag, sender, e)
    End Sub
    Private Sub pctDrag_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pctDrag.MouseUp
        gggbol = zzPctDragIcoCur_COM(3, False, pctDrag, sender, e)
    End Sub
    Private Sub popdragこの位置にアイコンを移動_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles popdragこの位置にアイコンを移動.Click
        Call popdragポップメニュー処理_COM(1)
    End Sub
    Private Sub popdragこの位置のアイコンを置き換える_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles popdragこの位置のアイコンを置き換える.Click
        Call popdragポップメニュー処理_COM(2)
    End Sub
    Private Sub popdragこの位置にアイコンを追加して最後のアイテムを破棄_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles popdragこの位置にアイコンを追加して最後のアイテムを破棄.Click
        Call popdragポップメニュー処理_COM(3)
    End Sub
    Private Sub popdragキャンセル_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles popdragキャンセル.Click
        Call popdragポップメニュー処理_COM(4)
    End Sub
    Private Sub popdragポップメニュー処理_COM(ByVal index As Integer)
        Select Case index
            Case 1 'popdragこの位置にアイコンを移動_Click
                If mListCur > 0 And mListDropPos > 0 And mListCur <> mListDropPos Then
                    Dim updown As Integer = IIf(mListDropPos > mListCur, 1, -1)
                    Dim stt As Integer = mListCur
                    Dim stp As Integer = mListDropPos - updown
                    Dim g As Graphics = Graphics.FromImage(pctREF.Image)
                    If g IsNot Nothing Then
                        Dim 田 As Rectangle
                        For a As Integer = stt To stp Step updown
                            田.X = mLists(a).lll : 田.Y = mLists(a).ttt : 田.Width = cListItemWDHT : 田.Height = cListItemWDHT
                            g.DrawImage(pctREF.Image, 田, mLists(a + updown).lll, mLists(a + updown).ttt, cListItemWDHT, cListItemWDHT, GraphicsUnit.Pixel)
                        Next
                        g.Dispose()
                    End If
                End If
            Case 2 'popdragこの位置のアイコンを置き換える_Click
                'OK OK no op
            Case 3 'popdragこの位置にアイコンを追加して最後のアイテムを破棄_Click
                gggbol = zzアイコンを追加するために最後尾を外す()
            Case Else 'popdragキャンセル_Click
                'OK OK no op
        End Select
        Select Case index
            Case 1, 2, 3
                zzアイコンを現在位置にコピー(pctDrag)
                btn設定を有効にして閉じる.Enabled = True
                btnアプリの規定に戻す.Enabled = True
        End Select
        pctDrag.Visible = False
        '2024/03/24 エラーの訂正**************************************************
        gggbol = zzMousEventsFlagsClear() 'PopMenuが表示されても、コード実行はストップしないで、フラッグ設定がクリアされてしまう。
        '2024/03/24 エラーの訂正**************************************************
    End Sub
    Private Sub PopMenupctDrag_Closed(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripDropDownClosedEventArgs) Handles PopMenupctDrag.Closed
        pctDrag.Visible = False
    End Sub
    '■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
    Private Sub pico_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pico.MouseDown
        '2024/03/24 エラーの訂正**************************************************
        gggbol = zzMousEventsFlagsClear() 'PopMenuが表示されても、コード実行はストップしないで、フラッグ設定がクリアされてしまう。
        '2024/03/24 エラーの訂正**************************************************
        Dim wIsMoveDownToUp As Boolean
        gggbol = Ⅹマウスイベント検査2022(gcoMsDown, e.Button, e.X, e.Y, 3, 3, 3, 3, wIsMoveDownToUp)
        CurListIndex = BoxICO.HitTest(e.X, e.Y)
        If CurListIndex > 0 Then
        End If
    End Sub
    Private Sub pico_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pico.MouseMove
        Dim wIsMoveDownToUp As Boolean
        gggbol = Ⅹマウスイベント検査2022(gcoMsMove, e.Button, e.X, e.Y, 3, 3, 3, 3, wIsMoveDownToUp)
    End Sub
    Private Sub pico_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pico.MouseUp
        Dim wIsMoveDownToUp As Boolean
        gggbol = Ⅹマウスイベント検査2022(gcoMsUp, e.Button, e.X, e.Y, 3, 3, 3, 3, wIsMoveDownToUp)
    End Sub
    Private Sub picoCur_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picoCur.MouseDown
        gggbol = zzPctDragIcoCur_COM(1, True, picoCur, sender, e)
    End Sub
    Private Sub picoCur_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picoCur.MouseMove
        gggbol = zzPctDragIcoCur_COM(2, True, picoCur, sender, e)
    End Sub
    Private Sub picoCur_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picoCur.MouseUp
        gggbol = zzPctDragIcoCur_COM(3, True, picoCur, sender, e)
    End Sub
    Private Sub popicoこの位置のアイコンを置き換える_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles popicoこの位置のアイコンを置き換える.Click
        Call popicoポップメニュー処理_COM(1)
    End Sub
    Private Sub popicoこの位置にアイコンを追加して最後のアイテムを破棄_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles popicoこの位置にアイコンを追加して最後のアイテムを破棄.Click
        Call popicoポップメニュー処理_COM(2)
    End Sub
    Private Sub popicoキャンセル_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles popicoキャンセル.Click
        Call popicoポップメニュー処理_COM(3)
    End Sub
    Private Sub popicoポップメニュー処理_COM(ByVal index As Integer)
        'qqqqq(CStr(CurListIndex) & "    " & CStr(mListCur))
        Select Case index
            Case 1 'popicoこの位置のアイコンを置き換える_Click
                'OK OK no op
            Case 2 'popicoこの位置にアイコンを追加して最後のアイテムを破棄_Click
                gggbol = zzアイコンを追加するために最後尾を外す()
            Case Else 'popicoキャンセル_Click
                'OK OK no op
        End Select
        Select Case index
            Case 1, 2
                gggbol = zzアイコンを現在位置にコピー(picoCur)
                btn設定を有効にして閉じる.Enabled = True
                btnアプリの規定に戻す.Enabled = True
        End Select
        picoCur.Visible = False
        '2024/03/24 エラーの訂正**************************************************
        gggbol = zzMousEventsFlagsClear() 'PopMenuが表示されても、コード実行はストップしないで、フラッグ設定がクリアされてしまう。
        '2024/03/24 エラーの訂正**************************************************
    End Sub
    Private Sub PopMenupicoCur_Closed(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripDropDownClosedEventArgs) Handles PopMenupicoCur.Closed
        picoCur.Visible = False
    End Sub
    '■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
    Private mXXX, mYYY As Integer
    Private mDown As Boolean = False
    Private mDownX As Integer = -1, mDownY As Integer = -1
    Private mP As New Point(0, 0)
    Private mPP As New Point(0, 0)
    Private mListDropPos As Integer = 0
    Private Function zzPctDragIcoCur_COM(ByVal op As Integer, ByVal ISpicoCur As Boolean, ByVal pct As PictureBox, ByVal sender As Object, ByVal e As MouseEventArgs) As Boolean
        Dim RET As Boolean = True
        mListDropPos = 0
        Select Case op
            Case 1
                Dim wIsMoveDownToUp As Boolean
                mXXX = e.X : mYYY = e.Y
                gggbol = Ⅹマウスイベント検査2022(gcoMsDown, e.Button, mXXX, mYYY, 3, 3, 3, 3, wIsMoveDownToUp)
                mP.X = mXXX : mP.Y = mYYY : mPP = Me.PointToScreen(mP)
                mDown = True : mDownX = mPP.X : mDownY = mPP.Y
                pct.BringToFront()
            Case 2
                If mDown Then
                    mXXX = e.X : mYYY = e.Y
                    mP.X = mXXX : mP.Y = mYYY : mPP = Me.PointToScreen(mP)
                    pct.SetBounds(pct.Left + mPP.X - mDownX, pct.Top + mPP.Y - mDownY, 0, 0, BoundsSpecified.Location)
                End If
            Case 3
                Try
                    If mDown Then
                        Dim HITIDX As Integer = 0
                        Dim rc As RECT, n As Integer, pctREFleft, pctREFtop As Integer
                        With pctREF
                            n = (.Width - .ClientRectangle.Width) \ 2
                            pctREFleft = .Left + n
                            pctREFtop = .Top + n
                            gggbol = SetRect(rc, pctREFleft, pctREFtop, .Right - n, .Bottom - n)
                        End With
                        Dim cx, cy As Integer
                        gggbol = ⅩControlCenterXY(pct, cx, cy)
                        If ⅩRect内にXY座標がある(cx, cy, rc) Then
                            Dim cxxx As Integer = cx - pctREF.Left - n
                            Dim cyyy As Integer = cy - pctREF.Top - n
                            For a As Integer = 1 To cListMax
                                If ⅩRect内にXY座標がある(cxxx, cyyy, mListsChkBox(a)) Then
                                    HITIDX = a
                                    Exit For
                                End If
                            Next
                            If HITIDX > 0 Then
                                mListDropPos = HITIDX
                                Dim c As Integer = cListSpaceXY \ 2 + 1
                                pct.SetBounds(pctREFleft + mListsChkBox(HITIDX).lll - c, pctREFtop + mListsChkBox(HITIDX).ttt - c, 0, 0, BoundsSpecified.Location)
                                gggbol = ⅩControlCenterXY(pct, cx, cy)
                                If ISpicoCur Then
                                    PopMenupicoCur.Show(Me, cx, cy) '2024/03/24 PopMenuが表示されても、コード実行はストップしない
                                    'qqqqq("Icons from File ")
                                Else
                                    If HITIDX <> mListCur Then PopMenupctDrag.Show(Me, cx, cy) '2024/03/24 PopMenuが表示されても、コード実行はストップしない
                                    'qqqqq("Icons List 400")
                                End If
                                'qqqqq("HITIDX = " & CStr(HITIDX))
                            Else
                                pct.Visible = False
                            End If
                        Else
                            pct.Visible = False
                        End If
                    End If
                Catch ex As Exception
                    RET = False
                    MsgBox("ERROR in picoCur_pctDrag_MouseUp() " & vbCrLf & ex.ToString)
                End Try
                '2024/03/24 エラーの訂正**************************************************
                'PopMenuが表示されても、コード実行はストップしないでここに来るので、ここでは　MouseEventsフラッグのクリアは禁止。
                '2024/03/24 エラーの訂正**************************************************
        End Select
        Return RET
    End Function
    '■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
    Function zzMousEventsFlagsClear() As Boolean
        '2024/03/24 エラーの訂正**************************************************
        'PopMenuが表示されても、コード実行はストップしないで、フラッグ設定がクリアされてしまう。
        mDown = False : mDownX = -1 : mDownY = -1 : mListCur = 0  'pctREF MoseEvent
        CurListIndex = 0                                          'pico   MoseEvent
        '2024/03/24 エラーの訂正**************************************************
        Return True
    End Function
#End Region

End Class


