Option Strict Off
Option Explicit On
Imports System.Windows.Forms
Imports System.Drawing
'------------------------------------ 2024/04/10 ------------------------------------
Public Class clsButtonsPaco

#Region "宣言"
    Private WithEvents ooDlgFontColor As frmDlgBtnsFontColor
    Event BtnMouseDown(ByRef wTipTextDoClose As Boolean, ByVal Index As Integer, ByVal BtnText As String) '2023/12/21 add
    Event BtnClick(ByVal Index As Integer, ByVal BtnText As String)
    Event StaticStateChanged(ByVal Index As Integer, ByVal BtnText As String, ByVal UpFalse_DownTrue As Boolean, ByVal OnColorChgFromDlg As Boolean)
    '2023/10/28------------------------------------------------------------------
    Event StaticBtnClickInDownState(ByVal Index As Integer, ByVal BtnText As String)
    Event ReSizeEnd(ByVal Left As Integer, ByVal Top As Integer, ByVal Width As Integer, ByVal Height As Integer)
    Event VibleChanged(ByVal NewVisible As Boolean)
    Event EnabledChanged(ByVal NewEnabled As Boolean)
    Event CellVisibleChanged(ByVal VisiblesStr As String)
    Event CellVisibleByIndexChanged(ByVal Index As Integer, ByVal NewVisible As Boolean)
    Event CellEnabledChanged(ByVal EnabledsStr As String)
    Event CellEnabledByIndexChanged(ByVal Index As Integer, ByVal NewEnabled As Boolean)
    Event CellTextByIndexChanged(ByVal Index As Integer, ByVal NewText As String)
    Event IMEmodeColorを設定してください(ByRef wTextBox As TextBox)
    Event セルカスタムカラーを設定してください(ByVal Index As Integer)
    Event ユーザー定義ボタンの選択がマウス異動で変更されました(ByVal rUserCont As Control, ByVal rText As String)
    Event ユーザー定義ボタンの設定mTipTextを表示してよろしいですか(ByRef wVisibleOK As Boolean)

    Private mName As String = ""
    Private Structure btndt
        Dim text As String
        Dim rcag As Rectangle
        Dim updn As Boolean  'up=False, dn=true
        Dim CellEnabled As Boolean
        Dim CellVisible As Boolean
        Dim UB As Integer 'カスタムカラーのデーター　-1　ではグループの色
        Dim UF As Integer 'カスタムカラーのデーター　-1　ではグループの色
        Dim DB As Integer 'カスタムカラーのデーター　-1　ではグループの色
        Dim DF As Integer 'カスタムカラーのデーター　-1　ではグループの色
    End Structure
    Private WithEvents mPct As PictureBox = Nothing
    Private mDTmax As Integer = 0 : Private mDT(mDTmax) As btndt
    Private mAllWD, mAllHT, mKOX, mKOY As Integer
    Public Const CutStr As String = "|,.|"
    Public Const cボタンテキストMax As Integer = 260
    Private WithEvents mTipText As TextBox = Nothing
    Private WithEvents mbtnOK As Button = Nothing
    Private mTipStr As String = ""
    Private mTipIndex As Integer = 0
    Private mLblCurText As Label
    Private mLblCurTextStr As String = ""
#End Region

#Region "基本"
    Friend ReadOnly Property Name() As String
        Get
            Return mName
        End Get
    End Property
    Friend ReadOnly Property ControlBase() As Control
        Get
            Return mPct
        End Get
    End Property
    Friend Function PropertysRW(ByVal Open0_Save1 As Integer, ByVal dstr As String) As String
        Const cut As String = ":", cccut As String = "*"
        Try
            Dim w As String = "", a, m, n, b As Integer, s As String
            If Open0_Save1 = 0 Then
                Dim wAry() As String = {""}
                m = Ⅹ文をカットして配列にする(dstr, cut, wAry)
                If m >= 7 Then
                    Call ooDlgColorFont_フォント名とサイズと色を設定してください(wAry(1), Val(wAry(2)), CBool(wAry(3)), Val(wAry(4)), Val(wAry(5)), Val(wAry(6)), Val(wAry(7)))
                    '-------------------------------------------------------------------------------------------------
                    For a = 1 To mDTmax 'Ini ファイルが保存されていれば、デフォルトで設定されている CellColorEx カラーはすべて無効にする。
                        gggint = Me.CellColorExGetSet(1, a, -1, -1, -1, -1, False)
                    Next
                    '-------------------------------------------------------------------------------------------------
                    Dim sss() As String = {""} : Dim c2, c3, c4, c5 As Integer
                    For a = 8 To m
                        n = Ⅹ文をカットして配列にする(wAry(a), cccut, sss)
                        If n = 5 Then
                            b = Val(sss(1))
                            If b > 0 And b <= mDTmax Then
                                mCellColorSetEnabled = True : c2 = Val(sss(2)) : c3 = Val(sss(3)) : c4 = Val(sss(4)) : c5 = Val(sss(5))
                                gggint = Me.CellColorExGetSet(1, b, c2, c3, c4, c5, False)
                            End If
                        ElseIf a > 8 And n = 2 Then '2023/11/01 もし省略記号の場合は、1番目のカラーをコピーする
                            b = Val(sss(1))
                            If b > 1 And b <= mDTmax Then
                                gggint = Me.CellColorExGetSet(1, b, c2, c3, c4, c5, False)
                            End If
                        End If
                    Next
                End If
            Else
                Dim FontName As String = "", FontSizeIdx_0_4 As Integer, FontBold As Boolean, BackColorUP As Integer, ForeColorUP As Integer, BackColorDN As Integer, ForeColorDN As Integer
                Call ooDlgColorFont_フォント名とサイズと色のデーターをください(FontName, FontSizeIdx_0_4, FontBold, BackColorUP, ForeColorUP, BackColorDN, ForeColorDN)
                w = FontName & cut & CStr(FontSizeIdx_0_4) & cut & CStr(FontBold) & cut & CStr(BackColorUP) & cut & CStr(ForeColorUP) & cut & CStr(BackColorDN) & cut & CStr(ForeColorDN) & cut
                For a = 1 To mDTmax
                    With mDT(a)
                        If .UB <> -1 Then
                            If a = 1 Then
                                s = CStr(a) & cccut & CStr(.UB) & cccut & CStr(.UF) & cccut & CStr(.DB) & cccut & CStr(.DF) & cccut
                            Else
                                If mDT(1).UB = mDT(a).UB And mDT(1).UF = mDT(a).UF And mDT(1).DB = mDT(a).DB And mDT(1).DF = mDT(a).DF Then
                                    s = CStr(a) & cccut & "◇" & cccut
                                Else
                                    s = CStr(a) & cccut & CStr(.UB) & cccut & CStr(.UF) & cccut & CStr(.DB) & cccut & CStr(.DF) & cccut
                                End If
                            End If
                            w = w & s & cut
                        End If
                    End With
                Next
            End If
            Return w
        Catch ex As Exception
            MsgBox("ERROR in PropertysRW()" & vbCrLf & ex.ToString)
            Return ""
        End Try
    End Function
    Public Property Parent() As Control
        Get
            Return mPct.Parent
        End Get
        Set(ByVal value As Control)
            mPct.Parent = value
        End Set
    End Property
    '***************************************************************************************
    Friend Function Make(ByVal rName As String, ByVal rParentCont As Control, ByVal rUseTipText As Boolean, ByVal rUpdn0_Stac1 As Integer, _
                    ByVal rLeft As Integer, ByVal rTop As Integer, ByVal rAllWD As Integer, ByVal rAllHT As Integer, _
                    ByVal rXko As Integer, ByVal rYko As Integer, ByVal rSpaSize As Single, _
                    Optional ByVal rTexts As String = "", Optional ByVal rFontSizePercent As Integer = 50) As Boolean
        If mPct Is Nothing Then Return False
        If rParentCont Is Nothing Then Return False
        mName = rName
        mDrawEnable = False
        mPct.Parent = rParentCont
        mUpdn0_Stac1 = IIf(rUpdn0_Stac1 = 0, 0, 1)
        mKOX = Ⅹ数値範囲Int(1, 50, rXko)
        mKOY = Ⅹ数値範囲Int(1, 50, rYko)
        SpaceHilitu = rSpaSize
        mDTmax = mKOX * mKOY
        ReDim mDT(mDTmax)
        For a As Integer = 1 To mDTmax : With mDT(a) : .CellEnabled = True : .CellVisible = True : .updn = False : .UB = -1 : .UF = -1 : .DB = -1 : .DF = -1 : End With : Next
        AllButtonText = rTexts
        Enabled = True
        Visible = True
        mFontSizePercent = Ⅹ数値範囲Int(30, 70, rFontSizePercent) '2023/10/14 必要　既定のフォントサイズを初期決定する
        '--------------------------------------------------------------------------
        With mLblCurText
            .AutoSize = False
            .BorderStyle = BorderStyle.Fixed3D
            .BackColor = Color.MidnightBlue
            .ForeColor = Color.White
            .Visible = False
            .TextAlign = ContentAlignment.MiddleLeft
            .AutoEllipsis = True
        End With
        '--------------------------------------------------------------------------
        If rUseTipText Then
            mTipText = New TextBox
            With mTipText
                .Parent = mPct : .Visible = False : .MaxLength = cボタンテキストMax : .ImeMode = ImeMode.Off : .WordWrap = False : .HideSelection = False
                .Multiline = True
            End With
            mbtnOK = New Button
            With mbtnOK
                .Text = "OK" : .Parent = mPct.Parent : .Visible = False : .AutoEllipsis = True
            End With
        End If
        '--------------------------------------------------------------------------
        'mDrawEnable = True '親コントロールが決定すべし。
        '--------------------------------------------------------------------------
        Return PostSizeChange(rLeft, rTop, rAllWD, rAllHT)
    End Function
    Friend Function PostChange(ByVal rLeft As Integer, ByVal rTop As Integer) As Boolean
        Return PostSizeChange(rLeft, rTop, mAllWD + mSpaSizeCurXY, mAllHT + mSpaSizeCurXY)
    End Function
    Friend Function SizeChange(ByVal rWidth As Integer, ByVal rHeight As Integer) As Boolean
        Return PostSizeChange(mPct.Left, mPct.Top, rWidth, rHeight)
    End Function
    Friend Function PostSizeChange(ByVal rLeft As Integer, ByVal rTop As Integer, ByVal rAllWD As Integer, ByVal rAllHT As Integer) As Boolean
        Dim WD As Integer = Ⅹ数値範囲Int(10, 4000, rAllWD) : Dim pX As Integer = Ⅹ数値範囲Int(10, 1000, WD \ mKOX)
        Dim HT As Integer = Ⅹ数値範囲Int(10, 2000, rAllHT) : Dim pY As Integer = Ⅹ数値範囲Int(10, 500, HT \ mKOY)
        Dim sp As Integer = Math.Min(pX, pY) * mSpaSize
        Dim a, c, x, y As Integer
        For a = 1 To mDTmax
            c = a - 1 : y = c \ mKOX : x = c - (y * mKOX)
            With mDT(a).rcag
                .X = x * pX : .Y = y * pY : .Width = pX - sp : .Height = pY - sp
            End With
        Next
        mAllWD = mKOX * pX - sp : mAllHT = mKOY * pY - sp : mSpaSizeCurXY = sp
        If Not ⅩImage_新規作成_再作成(mPct.Image, mAllWD, mAllHT) Then Return False
        mPct.SetBounds(Ⅹ数値範囲Int(0, 3900, rLeft), Ⅹ数値範囲Int(0, 1900, rTop), mAllWD, mAllHT, BoundsSpecified.All)
        FontSizePercent = FontSizePercent '2023/10/14 必要　既定のフォントサイズを決定する
        RaiseEvent ReSizeEnd(mPct.Left, mPct.Top, mAllWD, mAllHT)
        Return True
    End Function
    Friend Function SizeZoom(ByVal rLeftZoom As Single, ByVal rTopZoom As Single, ByVal rAllWDZoom As Single, ByVal rAllHTZoom As Single) As Boolean
        Dim rLeft As Integer = Ⅹ数値範囲Int(0, 3900, mPct.Left * rLeftZoom)
        Dim rTop As Integer = Ⅹ数値範囲Int(0, 1900, mPct.Top * rTopZoom)
        Dim rAllWD As Integer = Ⅹ数値範囲Int(10, 4000, (mAllWD + mSpaSizeCurXY) * rAllWDZoom)
        Dim rAllHT As Integer = Ⅹ数値範囲Int(10, 2000, (mAllHT + mSpaSizeCurXY) * rAllHTZoom)
        Return PostSizeChange(rLeft, rTop, rAllWD, rAllHT)
    End Function
    Friend Function BtnsTextAllSet(ByVal AllText As String, ByVal CellTextLen As Integer) As Integer
        If AllText = "" Or CellTextLen < 1 Then Return 0
        Dim c As Integer = 0 : Dim s As String
        For a As Integer = 1 To Len(AllText) Step CellTextLen
            c = c + 1
            s = Mid(AllText, a, CellTextLen)
            If mDoTrimText Then s = Trim(s)
            mDT(c).text = s
            If c = mDTmax Then Exit For
        Next
        gggbol = Draw(0)
        Return c
    End Function
    '***************************************************************************************
    Friend Function SizeGet_Cell(ByVal AddPctPostXY As Boolean, ByVal Index As Integer, Optional ByRef wLeft As Integer = 0, Optional ByRef wTop As Integer = 0, Optional ByRef wRight As Integer = 0, Optional ByRef wBottom As Integer = 0) As Boolean
        If Index < 1 Or Index > mDTmax Then Return False
        Dim addx As Integer = IIf(AddPctPostXY, mPct.Left, 0)
        Dim addy As Integer = IIf(AddPctPostXY, mPct.Top, 0)
        With mDT(Index).rcag
            wLeft = addx + .Left : wTop = addy + .Top : wRight = addx + .Right : wBottom = addy + .Bottom
        End With
        Return True
    End Function
    Friend Function Draw(ByVal rIndex As Integer) As Boolean
        If Not mDrawEnable Then Return False
        If mPct Is Nothing Then Return False
        If mPct.Image Is Nothing Then Return False
        If rIndex < 0 Or rIndex > mDTmax Then Return False
        If Not mPct.Visible Then Return False
        '----------------------------------------------
        Dim stt As Integer = IIf(rIndex = 0, 1, rIndex) : Dim stp As Integer = IIf(rIndex = 0, mDTmax, rIndex)
        Dim g As Graphics = Graphics.FromImage(mPct.Image)
        If g Is Nothing Then Return False
        Try
            '***********************************************
            Dim sFormat As New StringFormat()
            sFormat.Alignment = StringAlignment.Center
            sFormat.LineAlignment = StringAlignment.Center
            sFormat.FormatFlags = StringFormatFlags.NoWrap
            '***********************************************
            If rIndex = 0 Then gggbol = ⅩPictureBox_Cls(mPct)
            '***********************************************
            Dim rcg As Rectangle
            Dim hh As Integer = mDT(1).rcag.Height * mTextVposOffSetPercent / 100
            '***********************************************
            Dim brs As New SolidBrush(Color.Black) : Dim brsf As New SolidBrush(Color.Black)
            For a As Integer = stt To stp
                With mDT(a)
                    If .CellVisible = False Then
                        If stt = stp Then 'only 1 btn draw
                            brs.Color = mPct.BackColor
                            If Not brs Is Nothing Then
                                With .rcag : g.FillRectangle(brs, .Left, .Top, .Width, .Height) : End With
                            End If
                        End If
                    Else
                        Dim UP背, UP字, DN背, DN字 As Color
                        If .UB = -1 Then
                            UP背 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, mUP背))
                            UP字 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, mUP字))
                            DN背 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, mDN背))
                            DN字 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, mDN字))
                        Else
                            UP背 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, .UB))
                            UP字 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, .UF))
                            DN背 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, .DB))
                            DN字 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, .DF))
                        End If
                        '2023/10/19 change ***************************************************************************
                        '普通のボタンでもクリック時の色変化は、色設定コマンドで、任意に指定できる。
                        'If mUpdn0_Stac1 = 0 Then '普通のボタン
                        '    DN背 = UP背
                        '    DN字 = UP字
                        'Else 'スタティックボタン
                        '    DN背 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, mDN背))
                        '    DN字 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(mEnabled And .CellEnabled, mDN字))
                        'End If
                        '2023/10/19 change ***************************************************************************
                        brs.Color = IIf(.updn, DN背, UP背)
                        If Not brs Is Nothing Then
                            With .rcag : g.FillRectangle(brs, .Left, .Top, .Width, .Height) : End With
                        End If
                        If .text <> "" Then
                            brsf.Color = IIf(.updn, DN字, UP字)
                            rcg = .rcag : rcg.Offset(0, hh)
                            If .updn Then
                                rcg.Offset(1, 1)
                            End If
                            g.DrawString(.text, mPct.Font, brsf, rcg, sFormat)
                        End If
                        '***********************************************
                        gggbol = zzDrawFrame(g, .rcag, .updn, UP背, DN背)
                        '***********************************************
                    End If
                End With
            Next
            If Not brs Is Nothing Then brs.Dispose()
            If Not brsf Is Nothing Then brsf.Dispose()
            g.Dispose()
            mPct.Refresh()
            'qqqqq("clsButtonsPaco.Draw() out  Name = " & Name & " rIndex = " & CStr(rIndex))
            '***********************************************
            gggbol = zzTipTextPostSizeSet()
            '***********************************************
            Return True
        Catch ex As Exception
            If Not g Is Nothing Then g.Dispose()
            Return False
        End Try
    End Function
    Private Function zzDrawFrame(ByVal g As Graphics, ByVal rcg As Rectangle, ByVal updn As Boolean, ByVal UP背 As Color, ByVal DN背 As Color) As Boolean
        If g Is Nothing Then Return False
        Dim pen1 As Pen = New Pen(Ⅹ色HalfColor(FrameColor, Not mEnabled), 1)
        g.DrawRectangle(pen1, rcg.Left, rcg.Top, rcg.Width - 1, rcg.Height - 1)
        pen1.Dispose()
        Dim rg As Rectangle = rcg : rg.Inflate(-1, -1)
        If updn = False Then
            Dim pen明 As Pen = New Pen(Ⅹ色HalfColor(UP背, True)) : Dim pen暗 As Pen = New Pen(Ⅹ色HalfColor(UP背, False))
            With rg
                g.DrawLine(pen明, .Left, .Top, .Right - 1, .Top) : g.DrawLine(pen明, .Left, .Top, .Left, .Bottom - 1)
                g.DrawLine(pen暗, .Right - 1, .Top + 1, .Right - 1, .Bottom - 1) : g.DrawLine(pen暗, .Left + 1, .Bottom - 1, .Right - 1, .Bottom - 1)
            End With
            pen明.Dispose() : pen暗.Dispose()
        Else
            Dim pen明 As Pen = New Pen(Ⅹ色HalfColor(DN背, True)) : Dim pen暗 As Pen = New Pen(Ⅹ色HalfColor(DN背, False))
            With rg
                g.DrawLine(pen暗, .Left, .Top, .Right - 1, .Top) : g.DrawLine(pen暗, .Left, .Top, .Left, .Bottom - 1)
                g.DrawLine(pen明, .Right - 1, .Top + 1, .Right - 1, .Bottom - 1) : g.DrawLine(pen明, .Left + 1, .Bottom - 1, .Right - 1, .Bottom - 1)
            End With
            pen明.Dispose() : pen暗.Dispose()
        End If
        Return True
    End Function
    '***************************************************************************************
    Private mUpdn0_Stac1 As Integer = 0
    Property Updn0_Stac1() As Integer
        Get
            Return mUpdn0_Stac1
        End Get
        Set(ByVal value As Integer)
            If mUpdn0_Stac1 = value Then Return
            mUpdn0_Stac1 = IIf(value = 0, 0, 1)
            If mUpdn0_Stac1 = 0 Then gggbol = zzPushOneDownOthersUp(0) 'All up
            gggbol = Draw(0)
        End Set
    End Property
    Private mDrawEnable As Boolean = True
    Property DrawEnable() As Boolean
        Get
            Return mDrawEnable
        End Get
        Set(ByVal value As Boolean)
            mDrawEnable = value
        End Set
    End Property
    Friend Function ParentBackColorChanged(ByVal ParentCont As Control) As Boolean
        mPct.BackColor = ParentCont.BackColor
        Return Draw(0)
    End Function
    Friend Function FontNewSet_Use_SysDlg() As Boolean
        Dim RET As Boolean = False
        Dim Dlg As FontDialog = New FontDialog
        Dim b As DialogResult = Dlg.ShowDialog()
        If (b = Windows.Forms.DialogResult.OK) Then
            With Dlg.Font
                gggbol = FontGetSet(1, .Name, 0, .Bold)
            End With
            RET = True
        End If
        Dlg.Dispose()
        Return RET
    End Function
    Friend Function FontColorSetDlgShow(ByVal rOwner As Form, Optional ByVal rDlgText As String = "", Optional ByVal rShowPosX As Integer = 0, Optional ByVal rShowPosY As Integer = 0) As Boolean
        Dim RET As Boolean = False
        ooDlgFontColor = New frmDlgBtnsFontColor
        gggbol = ooDlgFontColor.aaダイアログ_色とフォント設定_Show1(rOwner, rDlgText, rShowPosX, rShowPosY)
        ooDlgFontColor.Dispose()
        Return RET
    End Function
    Friend Function LblCurTextShowHide(ByVal ShowHide As Boolean, ByVal Left As Integer, ByVal Top As Integer, ByVal Width As Integer, ByVal Height As Integer) As Boolean
        With mLblCurText
            .Parent = mPct.Parent
            .Visible = ShowHide
            If ShowHide Then
                .SetBounds(Left, Top, Width, Height, BoundsSpecified.All)
                .Font = mPct.Font
                .Text = ""
                .BringToFront()
            End If
        End With
    End Function
#End Region

#Region "プロパティ"
    '***************************************************************************************
    Private mBtnTipTextUse As Boolean = False
    Property BtnTipTextUse() As Boolean
        Get
            Return mBtnTipTextUse
        End Get
        Set(ByVal value As Boolean)
            If mBtnTipTextUse = value Then Return
            mBtnTipTextUse = value
        End Set
    End Property
    Property DropTextEnabled() As Boolean
        Get
            Return mPct.AllowDrop
        End Get
        Set(ByVal value As Boolean)
            If mPct.AllowDrop = value Then Return
            mPct.AllowDrop = value
        End Set
    End Property
    ReadOnly Property CellCount() As Integer
        Get
            Return mDTmax
        End Get
    End Property
    ReadOnly Property CellLeftByIndex(ByVal Index As Integer) As Integer
        Get
            If Index > 0 And Index <= mDTmax Then Return mDT(Index).rcag.Left
            Return 0
        End Get
    End Property
    ReadOnly Property CellTopByIndex(ByVal Index As Integer) As Integer
        Get
            If Index > 0 And Index <= mDTmax Then Return mDT(Index).rcag.Top
            Return 0
        End Get
    End Property
    ReadOnly Property CellRightByIndex(ByVal Index As Integer) As Integer
        Get
            If Index > 0 And Index <= mDTmax Then Return mDT(Index).rcag.Right
            Return 0
        End Get
    End Property
    ReadOnly Property CellBottomByIndex(ByVal Index As Integer) As Integer
        Get
            If Index > 0 And Index <= mDTmax Then Return mDT(Index).rcag.Bottom
            Return 0
        End Get
    End Property
    ReadOnly Property CellWidth() As Integer
        Get
            Return mDT(1).rcag.Width
        End Get
    End Property
    ReadOnly Property CellHeight() As Integer
        Get
            Return mDT(1).rcag.Height
        End Get
    End Property
    Property Width() As Integer
        Get
            Return mAllWD
        End Get
        Set(ByVal value As Integer)
            If mAllWD = value Then Return
            gggbol = PostSizeChange(mPct.Left, mPct.Top, value + mSpaSizeCurXY, mAllHT + mSpaSizeCurXY)
        End Set
    End Property
    Property Height() As Integer
        Get
            Return mAllHT
        End Get
        Set(ByVal value As Integer)
            If mAllHT = value Then Return
            gggbol = PostSizeChange(mPct.Left, mPct.Top, mAllWD + mSpaSizeCurXY, value + mSpaSizeCurXY)
        End Set
    End Property
    Property Left() As Integer
        Get
            Return mPct.Left
        End Get
        Set(ByVal value As Integer)
            If mPct.Left = value Then Return
            mPct.Left = value
        End Set
    End Property
    Property Top() As Integer
        Get
            Return mPct.Top
        End Get
        Set(ByVal value As Integer)
            If mPct.Top = value Then Return
            mPct.Top = value
        End Set
    End Property
    Private mSpaSize As Single = 0.1 : Dim mSpaSizeCurXY As Integer = 10 'rSpaSize= 0.0 to 1.0
    Property SpaceHilitu() As Single
        Get
            Return mSpaSize
        End Get
        Set(ByVal value As Single)
            If mSpaSize = value Then Return
            mSpaSize = Ⅹ数値範囲Sng(0, 0.5, value)
            If mDrawEnable Then
                gggbol = PostSizeChange(mPct.Left, mPct.Top, mAllWD + mSpaSizeCurXY, mAllHT + mSpaSizeCurXY)
            End If
        End Set
    End Property
    '***************************************************************************************
    Dim mDoTrimText As Boolean = False
    Property DoTrimText() As Boolean
        Get
            Return mDoTrimText
        End Get
        Set(ByVal value As Boolean)
            If mDoTrimText = value Then Return
            mDoTrimText = value
        End Set
    End Property
    Dim mButtonPushOnlyOneSelect As Boolean = True
    Property ButtonPushOnlyOneSelect() As Boolean
        Get
            Return mButtonPushOnlyOneSelect
        End Get
        Set(ByVal value As Boolean)
            If mButtonPushOnlyOneSelect = value Then Return
            mButtonPushOnlyOneSelect = value
            If mButtonPushOnlyOneSelect Then
                For a As Integer = 1 To mDTmax
                    If mDT(a).updn = True Then
                        gggbol = zzPushOneDownOthersUp(a)
                        Exit For
                    End If
                Next
            End If
            gggbol = Draw(0)
        End Set
    End Property
    Private Function zzPushOneDownOthersUp(ByVal OneDown As Integer) As Boolean
        Dim bol As Boolean
        For a As Integer = 1 To mDTmax
            bol = (mDT(a).updn = True)
            mDT(a).updn = (a = OneDown)
            If bol Then
                gggbol = Draw(a)
            End If
        Next
        mCurBtn = OneDown '2023/10/28 new
    End Function
    Property AllButtonText() As String
        Get
            Dim w As String = "" : Dim c As String = CutStr
            For a As Integer = 1 To mDTmax
                w = w & mDT(a).text & c
            Next
            Return w
        End Get
        Set(ByVal value As String)
            If mDTmax = 0 Then Return
            For a As Integer = 1 To mDTmax : mDT(a).text = "" : Next
            If InStr(value, CutStr) = 0 Then Return
            Dim wAry() As String = {""}
            Dim m As Integer = Ⅹ文をカットして配列にする(value, CutStr, wAry)
            For a As Integer = 1 To mDTmax
                If a <= m Then mDT(a).text = IIf(mDoTrimText, Trim(wAry(a)), wAry(a))
            Next
            If m > 0 Then gggbol = Draw(0)
        End Set
    End Property
    Property CellButtonText(ByVal index As Integer) As String
        Get
            If mDTmax = 0 Or index < 1 Or index > mDTmax Then Return ""
            Return mDT(index).text
        End Get
        Set(ByVal value As String)
            If mDTmax = 0 Or index < 1 Or index > mDTmax Then Return
            Dim s As String = ⅩVBStrLeft(value, cボタンテキストMax)
            If mDoTrimText Then s = Trim(s)
            If mDT(index).text = s Then Return
            mDT(index).text = s
            gggbol = Draw(index)
        End Set
    End Property
    Property ButtonPushUpDown(ByVal index As Integer) As Boolean
        Get
            If mDTmax = 0 Or index < 1 Or index > mDTmax Then Return False
            Return mDT(index).updn
        End Get
        Set(ByVal value As Boolean)
            If mDTmax = 0 Or index < 1 Or index > mDTmax Then Return
            If mIsMoseEvent = False Then
                If mDT(index).updn = value Then Return
            End If
            mDT(index).updn = value
            If value Then
                If ButtonPushOnlyOneSelect Then
                    gggbol = zzPushOneDownOthersUp(index)
                End If
            End If
            gggbol = Draw(index)
            RaiseEvent StaticStateChanged(index, mDT(index).text, value, False)
        End Set
    End Property
    '***************************************************************************************
    Friend Function ColorsAllSetByInteger(ByVal UP背 As Integer, ByVal UP字 As Integer, ByVal DN背 As Integer, ByVal DN字 As Integer) As Boolean
        mUP背 = UP背 : mUP字 = UP字 : mDN背 = DN背 : mDN字 = DN字
        Return True
    End Function
    Private mUP背 As Integer = &HC0C0C0&
    Property BackColorUP() As Color
        Get
            Return ColorTranslator.FromWin32(mUP背)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mUP背 = c Then Return
            mUP背 = c : gggbol = Draw(0)
        End Set
    End Property
    Private mUP字 As Integer = &H0&
    Property ForeColorUP() As Color
        Get
            Return ColorTranslator.FromWin32(mUP字)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mUP字 = c Then Return
            mUP字 = c : gggbol = Draw(0)
        End Set
    End Property
    Private mDN背 As Integer = &HC0C0C0&
    Property BackColorDN() As Color
        Get
            Return ColorTranslator.FromWin32(mDN背)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mDN背 = c Then Return
            mDN背 = c : gggbol = Draw(0)
        End Set
    End Property
    Private mDN字 As Integer = &H0&
    Property ForeColorDN() As Color
        Get
            Return ColorTranslator.FromWin32(mDN字)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mDN字 = c Then Return
            mDN字 = c : gggbol = Draw(0)
        End Set
    End Property
    Private mFrameColor As Integer = &H0&
    Property FrameColor() As Color
        Get
            Return ColorTranslator.FromWin32(mFrameColor)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mFrameColor = c Then Return
            mFrameColor = c : gggbol = Draw(0)
        End Set
    End Property
    '***************************************************************************************
    Dim mCellColorSetEnabled As Boolean = False
    Property CellColorSetEnabled() As Boolean
        Get
            Return mCellColorSetEnabled
        End Get
        Set(ByVal value As Boolean)
            If mCellColorSetEnabled = value Then Return
            mCellColorSetEnabled = value
        End Set
    End Property
    Friend Function ColorsAllGet(ByRef UB As Integer, ByRef UF As Integer, ByRef DB As Integer, ByRef DF As Integer) As Boolean
        UB = mUP背
        UF = mUP字
        DB = mDN背
        DF = mDN字
    End Function
    Friend Function ColorsAllSet(ByRef UB As Integer, ByRef UF As Integer, ByRef DB As Integer, ByRef DF As Integer, ByVal DoDraw As Boolean) As Boolean
        mUP背 = UB
        mUP字 = UF
        mDN背 = DB
        mDN字 = DF
        If DoDraw Then gggbol = Draw(0)
    End Function
    Friend Function CellColorExGetSet(ByVal Get0_Set1 As Integer, ByVal index As Integer, ByRef UB As Integer, ByRef UF As Integer, ByRef DB As Integer, ByRef DF As Integer, ByVal DoDraw As Boolean) As Boolean
        If mDTmax = 0 Then Return False
        If index < 1 Or index > mDTmax Then Return False
        If Not mCellColorSetEnabled Then Return False
        If UB = -1 Then
            With mDT(index)
                .UB = -1 : .UF = -1 : .DB = -1 : .DF = -1
            End With
        Else
            With mDT(index)
                Dim b As Boolean = (Get0_Set1 = 1)
                If b Then .UB = Ⅹ数値範囲Int(0, &HFFFFFF, UB) Else UB = .UB
                If b Then .UF = Ⅹ数値範囲Int(0, &HFFFFFF, UF) Else UF = .UF
                If b Then .DB = Ⅹ数値範囲Int(0, &HFFFFFF, DB) Else DB = .DB
                If b Then .DF = Ⅹ数値範囲Int(0, &HFFFFFF, DF) Else DF = .DF
            End With
        End If
        If Get0_Set1 = 1 Then
            If DoDraw Then gggbol = Draw(index)
        End If
    End Function
    '***************************************************************************************
    Private mEnabled As Boolean = True
    Property Enabled() As Boolean
        Get
            Return mEnabled
        End Get
        Set(ByVal value As Boolean)
            If mEnabled = value Then Return
            mEnabled = value : gggbol = Draw(0)
            RaiseEvent EnabledChanged(value)
        End Set
    End Property
    Property CellEnabled() As String
        Get
            Dim w As String = New String("1", mDTmax)
            For a As Integer = 1 To mDTmax
                If Not mDT(a).CellEnabled Then Mid(w, a, 1) = "0"
            Next
            Return w
        End Get
        Set(ByVal value As String)
            Dim chg As Boolean = False : Dim b As Boolean
            For a As Integer = 1 To Math.Min(mDTmax, Len(value))
                With mDT(a)
                    b = .CellEnabled
                    .CellEnabled = IIf(Mid(value, a, 1) = "0", False, True)
                    If b <> .CellEnabled Then chg = True
                End With
            Next
            If chg Then
                gggbol = Draw(0)
                Dim s As String = CellEnabled
                RaiseEvent CellEnabledChanged(s)
            End If
        End Set
    End Property
    Property CellEnabledByIndex(ByVal Index As Integer) As Boolean
        Get
            If Index > 0 And Index <= mDTmax Then Return mDT(Index).CellEnabled Else Return False
        End Get
        Set(ByVal value As Boolean)
            If Index > 0 And Index <= mDTmax Then
                If mDT(Index).CellEnabled = value Then Return
                mDT(Index).CellEnabled = value
                gggbol = Draw(Index)
                RaiseEvent CellEnabledByIndexChanged(Index, value)
            End If
        End Set
    End Property
    Property Visible() As Boolean
        Get
            Return mPct.Visible
        End Get
        Set(ByVal value As Boolean)
            If mPct.Visible = value Then Return
            mPct.Visible = value : gggbol = Draw(0)
            RaiseEvent VibleChanged(value)
        End Set
    End Property
    Property CellVisible() As String
        Get
            Dim w As String = New String("1", mDTmax)
            For a As Integer = 1 To mDTmax
                If Not mDT(a).CellVisible Then Mid(w, a, 1) = "0"
            Next
            Return w
        End Get
        Set(ByVal value As String)
            Dim chg As Boolean = False : Dim b As Boolean
            For a As Integer = 1 To Math.Min(mDTmax, Len(value))
                With mDT(a)
                    b = .CellVisible
                    .CellVisible = IIf(Mid(value, a, 1) = "0", False, True)
                    If b <> .CellVisible Then chg = True
                End With
            Next
            If chg Then
                gggbol = Draw(0)
                Dim s As String = CellVisible
                RaiseEvent CellVisibleChanged(s)
            End If
        End Set
    End Property
    Property CellVisibleByIndex(ByVal Index As Integer) As Boolean
        Get
            If Index > 0 And Index <= mDTmax Then Return mDT(Index).CellVisible Else Return False
        End Get
        Set(ByVal value As Boolean)
            If Index > 0 And Index <= mDTmax Then
                If mDT(Index).CellVisible = value Then Return
                mDT(Index).CellVisible = value
                gggbol = Draw(Index)
                RaiseEvent CellVisibleByIndexChanged(Index, value)
            End If
        End Set
    End Property
    '***************************************************************************************
    Private mFontSizePercent As Integer = 80 'スタート時に規定フォントを設定するために、この呼び出しが必須なので、わざとエラーサイズを規定値にしている。
    Property FontSizePercent() As Integer
        Get
            Return mFontSizePercent
        End Get
        Set(ByVal value As Integer)
            mFontSizePercent = Math.Max(30, Math.Min(70, value))  '2023/10/14 この値が変更されなくても、ボタンサイズが変わればフォントサイズも変わる。   'If mFontSizePercent = value Then Return
            gggbol = FontGetSet(1, "", 0, (mPct.Font.Bold))
            'qqqqq(CStr(mFontSizePercent))
        End Set
    End Property
    Private Function zzFontSizePercent_to_0_4(ByVal SizeToIndex_0_IndexToSize_1 As Integer, ByVal SizeOrIndex As Integer) As Integer
        Dim p As Single = 1.15
        Dim base As Single = 35  'base = 30 ...
        Dim p0 As Integer = base * (p ^ 1), p1 As Integer = base * (p ^ 2), p2 As Integer = base * (p ^ 3), p3 As Integer = base * (p ^ 4), p4 As Integer = base * (p ^ 5)
        Select Case SizeToIndex_0_IndexToSize_1
            Case 0
                Select Case SizeOrIndex
                    Case Is > p3 : Return 4
                    Case Is > p2 : Return 3
                    Case Is > p1 : Return 2
                    Case Is > p0 : Return 1
                    Case Else : Return 0
                End Select
            Case Else
                Select Case SizeOrIndex
                    Case 4 : Return p4
                    Case 3 : Return p3
                    Case 2 : Return p2
                    Case 1 : Return p1
                    Case Else : Return p0
                End Select
        End Select
    End Function
    Private mTextVposOffSetPercent As Integer = 8
    Property TextVposOffSetPercent() As Integer
        Get
            Return mTextVposOffSetPercent
        End Get
        Set(ByVal value As Integer)
            If mTextVposOffSetPercent = value Then Return
            mTextVposOffSetPercent = Math.Max(0, Math.Min(20, value))
            gggbol = Draw(0)
            ''2023/10/14 OK *************************************************
            'qqqqq("*******" & CStr(mTextVposOffSetPercent))
            ''2023/10/14 OK *************************************************
        End Set
    End Property
    Friend Function FontGetSet(ByVal Get0_Set1 As Integer, ByVal rwFontName As String, ByVal rwFontSize As Single, ByVal rwBold As Boolean) As Boolean
        Try
            With mPct.Font
                Select Case Get0_Set1
                    Case 0 'get
                        rwFontName = .Name : rwFontSize = .Size : rwBold = .Bold
                    Case Else 'set
                        If rwFontName = "" Then rwFontName = mPct.Font.Name
                        Dim FS As FontStyle = IIf(rwBold, FontStyle.Bold, FontStyle.Regular) Or .Italic Or .Underline
                        Dim wdht As Integer = Math.Min(mDT(1).rcag.Width, mDT(1).rcag.Height)
                        Dim fsz As Single = IIf(rwFontSize = 0, wdht * mFontSizePercent / 100, rwFontSize)
                        gggbol = Ⅹコントロールフォント変更(mPct, rwFontName, Math.Max(8, Math.Min(64, fsz)), FS)
                        gggbol = Draw(0)
                End Select
            End With
            Return True
        Catch ex As Exception
            MsgBox(ex.ToString) : Return False
        End Try
    End Function
    '***************************************************************************************
#End Region

#Region "CellStateSetON_OnlyStaticType   Call From OutSide"
    Friend Function CellStateSetON_OnlyStaticType(ByVal OnIndex As Integer, ByVal DoDraw As Boolean) As Integer
        If Not mPct.Visible Then Return 0
        If Updn0_Stac1 <> 1 Then Return 0
        If OnIndex < 1 Or OnIndex > mDTmax Then Return 0
        If mDT(OnIndex).updn = True Then Return OnIndex
        '-----------------------------------------------------
        Dim drawary(mDTmax) As Boolean : For a As Integer = 0 To mDTmax : drawary(a) = False : Next
        '-----------------------------------------------------
        mDT(OnIndex).updn = True : drawary(OnIndex) = True
        If ButtonPushOnlyOneSelect Then 'Others Set Up
            For a As Integer = 1 To mDTmax
                If a <> OnIndex And mDT(a).updn Then
                    mDT(a).updn = False : drawary(a) = True
                End If
            Next
        End If
        If DoDraw Then
            For a As Integer = 1 To mDTmax
                If drawary(a) Then
                    gggbol = Draw(a)
                End If
            Next
        End If
    End Function
#End Region

#Region "マウスイベント"
    Private mCurBtn As Integer = 0
    Private mIsMoseEvent As Boolean = False
    Private Sub mPct_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles mPct.DragOver
        gggbol = ⅩOLEDragDropテキストイベントANSI(2, mPct, e, "", 0, 0)
    End Sub
    Private Sub mPct_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles mPct.DragDrop
        Dim wTextANSI As String = "", wDrpX_inControl As Integer, wDrpY_inControl As Integer
        If ⅩOLEDragDropテキストイベントANSI(3, mPct, e, wTextANSI, wDrpX_inControl, wDrpY_inControl) Then
            Dim sss As String = ⅩVBStrLeft(wTextANSI, cボタンテキストMax)
            Dim cap As String = ⅩStrChgOldStrNewStr(sss, vbCrLf, "~")
            Dim a As Integer = zzGetIndex(wDrpX_inControl, wDrpY_inControl)
            If a = 0 Then Return
            RaiseEvent CellTextByIndexChanged(a, cap)
            'イベントが処理されなかった場合は、ここで処理する
            If CellButtonText(a) <> cap Then CellButtonText(a) = cap
            'qqqqq(CStr(a) & "  " & mDT(a).text & "  " & cap)
        End If
    End Sub
    Private Sub mPct_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles mPct.MouseDown
        'If ButtonPushOnlyOneSelect Then qqqqq("mPct_MouseDown-1")
        If Not mPct.Visible Then Return
        If Not mEnabled Then Return
        '-------------------------------------------
        If (Not mCellColorSetEnabled) And (Not mBtnTipTextUse) And e.Button = MouseButtons.Right Then
            gggbol = Ⅹマウスイベント検査2023(gcoMsDown, e)
            Return
        End If
        '-------------------------------------------
        Dim x As Integer = e.X : Dim y As Integer = e.Y
        Dim a As Integer
        '-------------------------------------------
        If mTipText IsNot Nothing Then
            If mTipText.Visible Then
                Call mTipText_LostFocus(Nothing, Nothing)
                Return
            End If
            If mBtnTipTextUse And e.Button = MouseButtons.Right Then
                Dim wVisibleOK As Boolean = False
                RaiseEvent ユーザー定義ボタンの設定mTipTextを表示してよろしいですか(wVisibleOK)
                If Not wVisibleOK Then
                    mTipText.Visible = False
                    Return
                End If
            End If
        End If
        '-------------------------------------------
        mTipIndex = 0 : mTipStr = ""
        If mBtnTipTextUse And e.Button = MouseButtons.Right Then
            a = zzGetIndex(x, y)
            If a = 0 Then Return
            With mDT(a)
                If Not .CellVisible Then Return
                Dim rc As Rectangle = .rcag
                With mTipText
                    .Font = mPct.Font
                    mTipIndex = a
                    mTipStr = mDT(a).text
                    .Text = mTipStr : .SelectionStart = 0 : .SelectionLength = Len(.Text)
                    .Visible = True
                    gggbol = zzTipTextPostSizeSet()
                    .Focus()
                    RaiseEvent IMEmodeColorを設定してください(mTipText)
                End With
            End With
            Return
        End If
        '-------------------------------------------
        'If ButtonPushOnlyOneSelect Then qqqqq("mPct_MouseDown-3")
        '-------------------------------------------
        If e.Button <> MouseButtons.Left Then Return
        If mUpdn0_Stac1 = 0 Then
            mCurBtn = 0
        End If
        a = zzGetIndex(x, y)
        If a = 0 Then Return
        With mDT(a)
            If .CellEnabled And .CellVisible Then
                If mUpdn0_Stac1 = 1 Then
                    '2023/12/21 add
                    If ButtonPushOnlyOneSelect Then
                        Dim wTipTextDoClose As Boolean = False
                        If a > 0 Then
                            RaiseEvent BtnMouseDown(wTipTextDoClose, a, mDT(a).text)
                        End If
                    End If
                    If .updn = True Then
                        If a = mCurBtn And mButtonPushOnlyOneSelect Then
                            '2023/10/28 ボタングループで、スタテックで、自身へのクリックでは、ダウンは可能だが、アップは他のクリックでのみ可能
                            'ダウン時にクリックがあった場合は、特別なメッセージを出す。
                            '辞書モードで、クリアのために必要
                            Dim s As String = .text
                            RaiseEvent StaticBtnClickInDownState(a, s)
                            Return
                        End If
                        mCurBtn = 0 : .updn = False : gggbol = Draw(a)
                        mIsMoseEvent = True : ButtonPushUpDown(a) = False : mIsMoseEvent = False
                        Return
                    End If
                End If
                .updn = True : mCurBtn = a : gggbol = Draw(mCurBtn)
                Return
            End If
        End With
    End Sub
    Private Sub mPct_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles mPct.MouseUp
        If Not mPct.Visible Then Return
        If Not mEnabled Then Return
        '-------------------------------------------
        If (Not mCellColorSetEnabled) And (Not mBtnTipTextUse) And e.Button = MouseButtons.Right Then
            If Ⅹマウスイベント検査2023(gcoMsUp, e) Then
                If e.Button = MouseButtons.Right Then
                    RaiseEvent BtnClick(0, vbCrLf)  '改行を出力
                End If
            End If
            Return
        End If
        '-------------------------------------------
        If e.Button = MouseButtons.Right Then
            If mBtnTipTextUse Then
                Return
            ElseIf mCellColorSetEnabled Then
                Dim index As Integer = zzGetIndex(e.X, e.Y)
                If index > 0 Then RaiseEvent セルカスタムカラーを設定してください(index)
            End If
            Return
        End If
        If e.Button <> MouseButtons.Left Then Return
        If mCurBtn = 0 Then Return
        If mUpdn0_Stac1 = 1 Then
            If mButtonPushOnlyOneSelect Then
                gggbol = zzPushOneDownOthersUp(mCurBtn)
            End If
            If mDT(mCurBtn).updn = True Then
                mIsMoseEvent = True : ButtonPushUpDown(mCurBtn) = True : mIsMoseEvent = False
                Return
            End If
        Else
            mDT(mCurBtn).updn = False
            gggbol = Draw(mCurBtn)
            Dim index As Integer = mCurBtn
            mCurBtn = 0
            RaiseEvent BtnClick(index, mDT(index).text)
        End If
    End Sub
    Private Function zzTipTextPostSizeSet() As Boolean
        If mTipText Is Nothing Then Return False
        If Not mTipText.Visible Then Return False
        If mTipIndex > 0 Then
            With mDT(mTipIndex).rcag
                mTipText.Font = mPct.Font
                Dim w As Integer = mDT(mDTmax).rcag.Right - .Left
                mTipText.SetBounds(.Left, .Top, w, .Height, BoundsSpecified.All)
                '---------------------------------------------------
                mbtnOK.Parent = mPct.Parent
                mbtnOK.Font = mPct.Font
                mbtnOK.SetBounds(mPct.Left + .Left - .Width - mSpaSizeCurXY + 1, mPct.Top + .Top + 1, .Width - 1, .Height - 1, BoundsSpecified.All)
                mbtnOK.Visible = True
                mbtnOK.BringToFront()
                '---------------------------------------------------
            End With
        End If
        Return True
    End Function
    Private Sub mTipText_ImeModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles mTipText.ImeModeChanged
        RaiseEvent IMEmodeColorを設定してください(mTipText)
    End Sub
    Private Sub mTipText_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles mTipText.TextChanged
        '2023/10/26 -----------------------------------------------------------
        'mTipStr = ⅩVBStrLeft(mTipText.Text, cボタンテキストMax)
        mTipStr = ⅩStrChgOldStrNewStr(ⅩVBStrLeft(mTipText.Text, cボタンテキストMax), vbCrLf, "~")
        '2023/10/26 -----------------------------------------------------------
        If mLblCurText.Visible Then
            mLblCurText.Text = mTipStr
        End If
        'qqqqq(mTipStr)
    End Sub
    Friend Function Do_TipText_Hide_IF() As Boolean
        '2023/12/12 new
        If mTipText Is Nothing Then Return False
        If mTipText.Visible Then
            mTipIndex = 0
            Call mTipText_LostFocus(Nothing, Nothing)
        End If
    End Function
    Private Sub mTipText_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles mTipText.LostFocus
        'qqqqq("mTipText_LostFocus")
        mbtnOK.Visible = False
        mTipText.Visible = False
        If mTipIndex > 0 And mTipStr <> "" Then
            RaiseEvent CellTextByIndexChanged(mTipIndex, mTipStr)
            'イベントが処理されなかった場合は、ここで処理する
            If CellButtonText(mTipIndex) <> mTipStr Then CellButtonText(mTipIndex) = mTipStr
            'qqqqq(CStr(mTipIndex) & "  " & mDT(mTipIndex).text & "  " & mTipStr)
            'gggbol = Ⅹマウスポイントを_Rectangle_の位置へ(1, mPct, mDT(mTipIndex).rcag)
        End If
        mTipIndex = 0 : mTipStr = ""
    End Sub
    Private Sub mbtnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mbtnOK.Click
        Call mTipText_LostFocus(Nothing, Nothing)
    End Sub
    Private Sub mPct_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles mPct.GotFocus
        If mTipText Is Nothing Then Return
        If mTipText.Visible Then mTipText.Visible = False
    End Sub
    Private Sub mPct_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles mPct.MouseMove
        If Not mLblCurText.Visible Then
            Return
        End If
        If mTipText.Visible Then Return
        Static a, x, y As Integer
        x = e.X : y = e.Y
        a = zzGetIndex(x, y)
        If a = 0 Then Return
        If mLblCurTextStr <> mDT(a).text Then
            mLblCurTextStr = mDT(a).text
            With mLblCurText
                If .Visible Then
                    .Text = mLblCurTextStr : .Refresh()
                    'qqqqq("mPct_MouseMove  " & mLblCurTextStr & "  " & CStr(e.X) & ", " & CStr(e.Y))
                    RaiseEvent ユーザー定義ボタンの選択がマウス異動で変更されました(mPct, mLblCurTextStr)
                End If
            End With
        End If
    End Sub
    Private Sub mPct_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles mPct.MouseLeave
        With mLblCurText
            If .Visible Then
                mLblCurTextStr = "" : .Text = mLblCurTextStr : .Refresh()
                'qqqqq("mPct_MouseLeave  ")
            End If
        End With
    End Sub
    Private Function zzGetIndex(ByVal x As Integer, ByVal y As Integer) As Integer
        For a As Integer = 1 To mDTmax
            If mDT(a).rcag.Contains(x, y) Then Return a
        Next
        Return 0
    End Function

#End Region

#Region "New / Finalize"
    Public Sub New()
        mPct = New PictureBox
        mLblCurText = New Label
    End Sub
    Protected Overrides Sub Finalize()
        Try
            If mbtnOK IsNot Nothing Then mbtnOK.Dispose()
            If mTipText IsNot Nothing Then mTipText.Dispose()
            If mPct.Image IsNot Nothing Then mPct.Image.Dispose()
            If mPct IsNot Nothing Then mPct.Dispose()
        Catch ex As Exception
        End Try
        MyBase.Finalize()
    End Sub
#End Region

#Region "Event from ooDlgFontColor (frmDlgBtnsFontColor)"
    Friend Sub ooDlgColorFont_フォント名とサイズと色のデーターをください(ByRef wFontName As String, ByRef wFontSizeIdx_0_4 As Integer, ByRef wFontBold As Boolean, ByRef wBackColorUP As Integer, ByRef wForeColorUP As Integer, ByRef wBackColorDN As Integer, ByRef wForeColorDN As Integer) Handles ooDlgFontColor.フォント名とサイズと色のデーターをください
        wFontName = mPct.Font.Name
        wFontSizeIdx_0_4 = zzFontSizePercent_to_0_4(0, mFontSizePercent)  'mFontSizePercent = 30 to 60 --> 0 to 4   30 35 40 50 60 
        wFontBold = mPct.Font.Bold
        wBackColorUP = mUP背
        wForeColorUP = mUP字
        wBackColorDN = mDN背
        wForeColorDN = mDN字
    End Sub
    Friend Sub ooDlgColorFont_フォント名とサイズと色を設定してください(ByVal rFontName As String, ByVal rFontSizeIdx_0_4 As Integer, ByRef rFontBold As Boolean, ByVal rBackColorUP As Integer, ByVal rForeColorUP As Integer, ByVal rBackColorDN As Integer, ByVal rForeColorDN As Integer) Handles ooDlgFontColor.フォント名とサイズと色を設定してください
        mUP背 = rBackColorUP
        mUP字 = rForeColorUP
        mDN背 = rBackColorDN
        mDN字 = rForeColorDN
        mFontSizePercent = zzFontSizePercent_to_0_4(1, rFontSizeIdx_0_4) 'mFontSizePercent = 30 to 60 --> 0 to 4   30 35 40 50 60 
        gggbol = FontGetSet(1, rFontName, 0, rFontBold)
    End Sub
#End Region


End Class

