Option Strict Off
Option Explicit On
Imports System.Windows.Forms
Imports System.Drawing
'------------------------------------ 2024/03/23 ------------------------------------
Public Class clsButtons
#Region "宣言"
    Public Shared mBrsBack As New SolidBrush(Color.White)
    Public Shared mBrsBtn(cColorMax * 8) As SolidBrush
    Public Shared mPen枠 As New Pen(Color.Black, 1)
    Public Shared mPen明 As New Pen(Color.White, 1)
    Public Shared mPen暗 As New Pen(Color.Gray, 1)
    '------------------------------------------------------------
    Private WithEvents mfrmDlgColorSet As frmDlgColorSet
    '------------------------------------------------------------
    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 BtnStaticClick(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 rUserCont As Control, ByVal rText As String)
    '------------------------------------------------------------
    Private mName As String = "clsButtons..."
    Private mPct As PictureBox = Nothing
    '------------------------------------------------------------
    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 CellColorIdx As Integer  'mColors(1 - 10) のインデックス　　mColors(1)　はグループの色
    End Structure
    Private mDTmax As Integer = 0 : Private mDT(mDTmax) As btndt
    Private Structure btncolor
        Dim UB As Integer 'カスタムカラーのデーター　mColors(1)　はグループの色   mColors(1 - 10)
        Dim UF As Integer 'カスタムカラーのデーター　mColors(1)　はグループの色
        Dim DB As Integer 'カスタムカラーのデーター　mColors(1)　はグループの色
        Dim DF As Integer 'カスタムカラーのデーター　mColors(1)　はグループの色
    End Structure
    Private Const cColorMax As Integer = 10 : Private mColors(cColorMax) As btncolor
    '------------------------------------------------------------
    Private mMouseDN As Boolean = False
    Private mVisble As Boolean
    Private mLEFT, mTOP, mRIGHT, mBOTTOM, mAllWD, mAllHT, mColumn, mRow As Integer
    Public Const CutStr As String = "|,.|"
    Public Const cボタンテキストMax As Integer = 500
#End Region

#Region "基本"
    Friend Function aafボタンデーターの設定変更(ByVal Read0_Write1_MsDn10_MsMv11_MsUp12 As Integer, ByRef d As BtnCellDatas) As Boolean
        Select Case Read0_Write1_MsDn10_MsMv11_MsUp12
            Case 0
                With d
                    .mChanged = False
                    .Name = mName
                    .rcagAll = Rectangle.FromLTRB(Me.Left, Me.Top, Me.Right, Me.Bottom)
                    ReDim .Cell(Me.CellCount)
                    For a As Integer = 1 To Me.CellCount
                        With .Cell(a)
                            .text = mDT(a).text
                            .rcag = mDT(a).rcag
                            .updn = mDT(a).updn
                            .CellEnabled = mDT(a).CellEnabled
                            .CellVisible = mDT(a).CellVisible
                            .CellColorIdx = mDT(a).CellColorIdx  'mColors(1 - 10) のインデックス　　mColors(1)　はグループの色
                        End With
                    Next
                End With
                Return True
            Case 1 'Chg Chk
                With d
                    .mChanged = False
                    For a As Integer = 1 To Me.CellCount
                        If .Cell(a).text <> mDT(a).text Then
                            .mChanged = True : Return True
                        End If
                    Next
                End With
                Return False
            Case 2 'Chg Data New Set
                With d
                    .mChanged = False
                    For a As Integer = 1 To Me.CellCount
                        With .Cell(a)
                            If .text <> mDT(a).text Then
                                mDT(a).text = .text
                                mDT(a).updn = .updn
                                mDT(a).CellEnabled = .CellEnabled
                                mDT(a).CellVisible = .CellVisible
                                mDT(a).CellColorIdx = .CellColorIdx
                                d.mChanged = True
                            End If
                        End With
                    Next
                    Return .mChanged
                End With
            Case Else
                Return False
        End Select
    End Function

    Friend Function aafボタンの色データーの設定(ByVal mColors_CellColorIdx_Str As String, ByVal arymax As Integer, Optional ByVal cut As String = ":", Optional ByVal cccut As String = "*") As Boolean
        'Const cut As String = ":", cccut As String = "*",  
        'arymax = 14
        Dim wAry() As String = {""}
        Dim m As Integer = Ⅹ文をカットして配列にする(mColors_CellColorIdx_Str, cut, wAry)
        If m <> arymax Then Return False
        Dim sss() As String = {""}
        For a As Integer = 3 To 3 + cColorMax - 1  'wAry(3,4,5,6,7,8,9,10,11,12)
            If 5 = Ⅹ文をカットして配列にする(wAry(a), cccut, sss) Then
                With mColors(a - 2)
                    'Val(sss(1)) = mColors() index
                    .UB = Math.Min(&HFFFFFF&, Math.Max(-1, Val(sss(2))))
                    .UF = Math.Min(&HFFFFFF&, Math.Max(-1, Val(sss(3))))
                    .DB = Math.Min(&HFFFFFF&, Math.Max(-1, Val(sss(4))))
                    .DF = Math.Min(&HFFFFFF&, Math.Max(-1, Val(sss(5))))
                End With
            End If
        Next
        If mDTmax = Ⅹ文をカットして配列にする(wAry(14), cccut, sss) Then  '14
            For a As Integer = 1 To mDTmax
                mDT(a).CellColorIdx = Math.Min(cColorMax, Math.Max(1, Val(sss(a))))
            Next
        End If
        Return True
    End Function
    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 As Integer, s As String
            If Open0_Save1 = 0 Then
                gggbol = aafボタンの色データーの設定(dstr, 14, cut, cccut)
            Else
                w = mName & cut     '1
                w = w & "mColors(10)data□□□" & cut    '2
                For a = 1 To cColorMax
                    With mColors(a)
                        s = CStr(a) & cccut & CStr(.UB) & cccut & CStr(.UF) & cccut & CStr(.DB) & cccut & CStr(.DF) & cccut
                    End With
                    w = w & s & cut   '3,4,5,6,7,8,9,10,11,12,
                Next
                s = "mDT(" & CStr(mDTmax) & ").CellColorIdx□□□" & cut    '13
                For a = 1 To mDTmax
                    With mDT(a)
                        s = s & CStr(.CellColorIdx) & cccut
                    End With
                Next
                w = w & s & cut  '14
            End If
            Return w
        Catch ex As Exception
            MsgBox("ERROR in PropertysRW()" & vbCrLf & ex.ToString)
            Return ""
        End Try
    End Function
    '***************************************************************************************
    Friend Function PostSizeChangeByPich(ByVal rLeft As Integer, ByVal rTop As Integer, ByVal rPichX As Integer, ByVal rPichY As Integer, ByVal rフォントサイズを決定する As Boolean) As Boolean
        Dim pX As Integer = rPichX : Dim pY As Integer = rPichY : Dim sp As Integer = Math.Min(pX, pY) * SpaceHilitu
        Dim wd As Integer = pX - sp : Dim ht As Integer = pY - sp
        mLEFT = rLeft : mTOP = rTop
        Dim a, c, x, y As Integer
        For a = 1 To mDTmax
            c = a - 1 : y = c \ mColumn : x = c - (y * mColumn)
            With mDT(a).rcag
                .X = mLEFT + x * pX : .Y = mTOP + y * pY : .Width = wd : .Height = ht
            End With
        Next
        mAllWD = mColumn * pX - sp : mAllHT = mRow * pY - sp : mRIGHT = mLEFT + mAllWD : mBOTTOM = mTOP + mAllHT : SpaceCurValXY = sp

        If rフォントサイズを決定する Then FontSizePercent = FontSizePercent '2023/10/14 必要　既定のフォントサイズを決定する

        'qqqqq(mName & ", 左 = " & CStr(mLEFT) & ", 上 = " & CStr(mTOP) & ", 右 = " & CStr(mRIGHT) & ", 下 = " & CStr(mBOTTOM))

        RaiseEvent ReSizeEnd(mPct.Left, mPct.Top, mAllWD, mAllHT)

        Return True
    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 BtnsText改行コードGetSet(ByVal rGet0_Set1 As Integer, ByVal rCurCellIndex As Integer, ByVal r改行コード文字CellIndex As Integer, ByVal r改行コード文字 As String) As String
        Static s改行コード文字 As String = "" : Static sCellIndexS() As Integer = {0, 0, 0, 0, 0, 0} : Dim a, m As Integer
        m = UBound(sCellIndexS)
        If rGet0_Set1 = 0 Then
            If (rCurCellIndex < 1 Or rCurCellIndex > mDTmax) Then Return ""
            For a = 1 To m
                If sCellIndexS(a) = rCurCellIndex Then
                    If CellButtonText(rCurCellIndex) = s改行コード文字 Then Return vbCrLf
                End If
            Next
            Return ""
        Else
            If r改行コード文字 = "" Then Return ""
            s改行コード文字 = r改行コード文字
            CellButtonText(r改行コード文字CellIndex) = r改行コード文字
            For a = 1 To m
                If sCellIndexS(a) = r改行コード文字CellIndex Then Return r改行コード文字
            Next
            If a > m Then
                For a = 1 To m
                    If sCellIndexS(a) = 0 Then
                        sCellIndexS(a) = r改行コード文字CellIndex
                        Return r改行コード文字
                    End If
                Next
            End If
            Return ""
        End If
    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 Not mPct.Visible Then Return False
        If mPct.Image Is Nothing Then Return False
        If rIndex < 0 Or rIndex > mDTmax Then Return False
        ''----------------------------------------------
        'qqqqq(Me.mName & ".Draw()  - IN")
        ''--------------------------------------------------
        Dim g As Graphics = Graphics.FromImage(mPct.Image)
        If g Is Nothing Then Return False
        Try
            '***********************************************
            If rIndex = 0 Then
                gggbol = ⅩPictureBox_Cls(mPct, mLEFT, mTOP, mAllWD, mAllHT, BackColorMain)
            End If
            '***********************************************
            mBrsBack.Color = mPct.BackColor
            If mBrsBtn(1) Is Nothing Then
                For a As Integer = 1 To UBound(mBrsBtn)
                    mBrsBtn(a) = New SolidBrush(Color.White)
                    'qqqqq("mBrsBtn(" & CStr(a) & ") = New SolidBrush(Color.White)")
                Next
            End If
            Dim brmadechk(cColorMax) As Boolean
            For a As Integer = 1 To cColorMax
                brmadechk(a) = False
            Next
            Dim n As Integer, p As Integer, ccchk As Integer
            Dim stt As Integer = IIf(rIndex = 0, 1, rIndex)
            Dim stp As Integer = IIf(rIndex = 0, mDTmax, rIndex)
            For a As Integer = stt To stp
                n = Math.Max(1, Math.Min(cColorMax, mDT(a).CellColorIdx))
                If brmadechk(n) Then
                    ccchk = ccchk + 1
                    'qqqqq("OK Made " & CStr(n) & "  " & CStr(ccchk))
                Else
                    If mColors(n).UB < 0 Then
                        qqqqq("mColors(n).UB < 0")
                    Else
                        brmadechk(n) = True
                        p = (8 * n) - 8
                        p += 1 : mBrsBtn(p).Color = ⅩColor_from_INT(mColors(n).UB)
                        p += 1 : mBrsBtn(p).Color = ⅩColor_from_INT(mColors(n).UF)
                        p += 1 : mBrsBtn(p).Color = ⅩColor_from_INT(mColors(n).DB)
                        p += 1 : mBrsBtn(p).Color = ⅩColor_from_INT(mColors(n).DF)
                        p += 1 : mBrsBtn(p).Color = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(False, mColors(n).UB))
                        p += 1 : mBrsBtn(p).Color = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(False, mColors(n).UF))
                        p += 1 : mBrsBtn(p).Color = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(False, mColors(n).DB))
                        p += 1 : mBrsBtn(p).Color = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(False, mColors(n).DF))
                    End If
                End If
            Next
            '***********************************************
            Dim sFormat As New StringFormat()
            sFormat.Alignment = StringAlignment.Center
            sFormat.LineAlignment = StringAlignment.Center
            sFormat.FormatFlags = StringFormatFlags.NoWrap
            '***********************************************
            Dim rcg As Rectangle
            Dim hh As Integer = mDT(1).rcag.Height * mTextVposOffSetPercent / 100
            Dim brCUR As SolidBrush, enCUR As Boolean
            For a As Integer = stt To stp
                With mDT(a)
                    If .CellVisible = False Or Me.Visible = False Then
                        If stt = stp Then 'only 1 btn draw
                            With .rcag : g.FillRectangle(mBrsBack, .Left, .Top, .Width, .Height) : End With
                        End If
                    Else
                        n = mDT(a).CellColorIdx
                        p = (8 * n) - 8
                        enCUR = mEnabled And .CellEnabled
                        ''@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                        'If a = 1 Then qqqqq("CellIDX = " & CStr(a) & ": enCUR = " & CStr(enCUR))
                        ''@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                        If Not .updn Then
                            If enCUR Then brCUR = mBrsBtn(p + 1) Else brCUR = mBrsBtn(p + 5)
                        Else
                            If enCUR Then brCUR = mBrsBtn(p + 3) Else brCUR = mBrsBtn(p + 7)
                        End If
                        If brCUR IsNot Nothing Then
                            With .rcag : g.FillRectangle(brCUR, .Left, .Top, .Width, .Height) : End With
                        End If
                        If .text <> "" Then
                            If Not .updn Then
                                If enCUR Then brCUR = mBrsBtn(p + 2) Else brCUR = mBrsBtn(p + 6)
                            Else
                                If enCUR Then brCUR = mBrsBtn(p + 4) Else brCUR = mBrsBtn(p + 8)
                            End If
                            rcg = .rcag : rcg.Offset(0, hh)
                            If .updn Then
                                rcg.Offset(1, 1)
                            End If
                            If brCUR IsNot Nothing Then g.DrawString(.text, mPct.Font, brCUR, rcg, sFormat)
                        End If
                        '***********************************************
                        Dim UP背, DN背 As Color
                        UP背 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(enCUR, mColors(n).UB))
                        DN背 = ⅩColor_from_INT(Ⅹ色をぼかすOnEnabledOff(enCUR, mColors(n).DB))
                        gggbol = zzDrawFrame(g, .rcag, .updn, UP背, DN背)
                        '***********************************************
                    End If
                End With
            Next
            g.Dispose()
            ''----------------------------------------------
            'qqqqq(Me.mName & ".Draw()  - OUT")
            ''--------------------------------------------------
            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
        mPen枠.Color = Ⅹ色HalfColor(FrameColor, Not mEnabled)
        g.DrawRectangle(mPen枠, rcg.Left, rcg.Top, rcg.Width - 1, rcg.Height - 1)
        Dim rg As Rectangle = rcg : rg.Inflate(-1, -1)
        If updn = False Then
            mPen明.Color = Ⅹ色HalfColor(UP背, True)
            mPen暗.Color = Ⅹ色HalfColor(UP背, False)
            With rg
                g.DrawLine(mPen明, .Left, .Top, .Right - 1, .Top) : g.DrawLine(mPen明, .Left, .Top, .Left, .Bottom - 1)
                g.DrawLine(mPen暗, .Right - 1, .Top + 1, .Right - 1, .Bottom - 1) : g.DrawLine(mPen暗, .Left + 1, .Bottom - 1, .Right - 1, .Bottom - 1)
            End With
        Else
            mPen明.Color = Ⅹ色HalfColor(DN背, True)
            mPen暗.Color = Ⅹ色HalfColor(DN背, False)
            With rg
                g.DrawLine(mPen暗, .Left, .Top, .Right - 1, .Top) : g.DrawLine(mPen暗, .Left, .Top, .Left, .Bottom - 1)
                g.DrawLine(mPen明, .Right - 1, .Top + 1, .Right - 1, .Bottom - 1) : g.DrawLine(mPen明, .Left + 1, .Bottom - 1, .Right - 1, .Bottom - 1)
            End With
        End If
        Return True
    End Function
    '***************************************************************************************
    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 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
#End Region

#Region "プロパティ"
    '***************************************************************************************
    Private mBtnIsUserText As Boolean = False
    Property BtnIsUserText() As Boolean
        Get
            Return mBtnIsUserText
        End Get
        Set(ByVal value As Boolean)
            If mBtnIsUserText = value Then Return
            mBtnIsUserText = 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

    Friend Function CellIndex_By_CellText(ByVal rCellText As String) As Integer
        For a As Integer = 1 To mDTmax
            If mDT(a).text = rCellText Then Return a
        Next
        Return 0
    End Function

    Friend Function CellIndex_By_Column_Row_Base1(ByVal rColumnIndex_Base1 As Integer, ByVal rRowIndex_Base1 As Integer) As Integer
        Dim n As Integer = rColumnIndex_Base1 * rRowIndex_Base1
        If n < 1 Or n > mDTmax Then Return 0
        Return ((rRowIndex_Base1 - 1) * mColumn) + rColumnIndex_Base1
    End Function
    ReadOnly Property CellCountColumn() As Integer
        Get
            Return mColumn
        End Get
    End Property
    ReadOnly Property CellCountRow() As Integer
        Get
            Return mRow
        End Get
    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
        End Set
    End Property
    Property Height() As Integer
        Get
            Return mAllHT
        End Get
        Set(ByVal value As Integer)
            If mAllHT = value Then Return
        End Set
    End Property
    Property Left() As Integer
        Get
            Return mLEFT
        End Get
        Set(ByVal value As Integer)
            If mLEFT = value Then Return
            mLEFT = value
        End Set
    End Property
    Property Top() As Integer
        Get
            Return mTOP
        End Get
        Set(ByVal value As Integer)
            If mTOP = value Then Return
            mTOP = value
        End Set
    End Property
    ReadOnly Property Right() As Integer
        Get
            Return mLEFT + mAllWD
        End Get
    End Property
    ReadOnly Property Bottom() As Integer
        Get
            Return mTOP + mAllHT
        End Get
    End Property
    Private mSpaSize As Single = 0.1 '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)
        End Set
    End Property
    Private mSpaceCurValXY As Integer = 2
    Property SpaceCurValXY() As Integer
        Get
            Return mSpaceCurValXY
        End Get
        Set(ByVal value As Integer)
            If mSpaceCurValXY = value Then Return
            mSpaceCurValXY = Ⅹ数値範囲Sng(0, 100, value)
        End Set
    End Property
    '***************************************************************************************
    Private mBtnIsStatic As Boolean = False
    Property BtnIsStatic() As Boolean
        Get
            Return mBtnIsStatic
        End Get
        Set(ByVal value As Boolean)
            If mBtnIsStatic = value Then Return
            mBtnIsStatic = value
            If Not mBtnIsStatic Then gggbol = zzPushOneDownOthersUp(0) 'All up
        End Set
    End Property
    Friend Function BtnIsStatic_OneSelect_CurIndex() As Integer
        If Not BtnIsStatic Then Return 0
        If Not ButtonPushOnlyOneSelect Then Return 0
        For a As Integer = 1 To mDTmax
            If (mDT(a).updn = True) Then Return a
        Next
        Return 0
    End Function
    Private 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
        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
    '***************************************************************************************
    Private 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
    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)
            Dim a, m As Integer
            If mDTmax = 0 Then Return
            For a = 1 To mDTmax : mDT(a).text = "" : Next
            If InStr(value, CutStr) = 0 Then
                m = Len(value)
                For a = 1 To mDTmax
                    If a <= m Then mDT(a).text = Mid(value, a, 1)
                Next
            Else
                Dim wAry() As String = {""}
                m = Ⅹ文をカットして配列にする(value, CutStr, wAry)
                For a = 1 To mDTmax
                    If a <= m Then mDT(a).text = IIf(mDoTrimText, Trim(wAry(a)), wAry(a))
                Next
            End If
        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
        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
            RaiseEvent StaticStateChanged(index, mDT(index).text, value, False)
        End Set
    End Property
    '***************************************************************************************
    Private mBackColorMain As Integer = &HFFFFFF&
    Property BackColorMain() As Color
        Get
            Return ColorTranslator.FromWin32(mBackColorMain)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mBackColorMain = c Then Return
            mBackColorMain = c
        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
        With mColors(1)
            .UB = UP背 : .UF = UP字 : .DB = DN背 : .DF = DN字
        End With
        Return True
    End Function
    Property BackColorUP() As Color
        Get
            Return ColorTranslator.FromWin32(mColors(1).UB)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mColors(1).UB = c Then Return
            mColors(1).UB = c
        End Set
    End Property
    Property ForeColorUP() As Color
        Get
            Return ColorTranslator.FromWin32(mColors(1).UF)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mColors(1).UF = c Then Return
            mColors(1).UF = c
        End Set
    End Property
    Property BackColorDN() As Color
        Get
            Return ColorTranslator.FromWin32(mColors(1).DB)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mColors(1).DB = c Then Return
            mColors(1).DB = c
        End Set
    End Property
    Property ForeColorDN() As Color
        Get
            Return ColorTranslator.FromWin32(mColors(1).DF)
        End Get
        Set(ByVal value As Color)
            Dim c As Integer = ColorTranslator.ToWin32(value)
            If mColors(1).DF = c Then Return
            mColors(1).DF = c
        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
        End Set
    End Property
    '***************************************************************************************
    Private 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
        With mColors(1)
            UB = .UB : UF = .UF : DB = .DB : DF = .DF
        End With
    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
        With mColors(1)
            .UB = UB : .UF = UF : .DB = DB : .DF = DF
        End With
        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
        Select Case Get0_Set1
            Case 0
                Dim n As Integer = Ⅹ数値範囲Int(1, cColorMax, mDT(index).CellColorIdx)
                With mColors(n)
                    UB = .UB : UF = .UF : DB = .DB : DF = .DF
                End With
            Case Else
                If UB = -1 Then    'グループカラーに戻す
                    mDT(index).CellColorIdx = 1
                End If
                '使用されていない mColors(?) アイテムを削除する
                Dim a As Integer
                Dim nnn(cColorMax) As Boolean
                For a = 1 To cColorMax : nnn(a) = False : Next
                For c As Integer = 1 To mDTmax : nnn(mDT(c).CellColorIdx) = True : Next
                For a = 1 To cColorMax
                    If nnn(a) = False Then
                        With mColors(a) : .UB = -1 : .UF = -1 : .DB = -1 : .DF = -1 : End With
                    End If
                Next
                If UB = -1 Then
                    'グループカラーに戻った
                Else
                    For a = 1 To cColorMax
                        With mColors(a)
                            If UB = .UB And UF = .UF And DB = .DB And DF = .DF Then
                                mDT(index).CellColorIdx = a
                                Exit For
                            End If
                        End With
                    Next
                    If a > cColorMax Then
                        For a = 1 To cColorMax
                            With mColors(a)
                                If .UB = -1 Then
                                    .UB = Ⅹ数値範囲Int(0, &HFFFFFF, UB) : .UF = Ⅹ数値範囲Int(0, &HFFFFFF, UF) : .DB = Ⅹ数値範囲Int(0, &HFFFFFF, DB) : .DF = Ⅹ数値範囲Int(0, &HFFFFFF, DF)
                                    mDT(index).CellColorIdx = a
                                    Exit For
                                End If
                            End With
                        Next
                    End If
                End If
        End Select
        Return True
    End Function
    Friend Function CellColorExUsing(ByVal index As Integer) As Boolean
        If mDTmax = 0 Then Return False
        If index < 1 Or index > mDTmax Then Return False
        Return (mDT(index).CellColorIdx > 1)
    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
            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
                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
                RaiseEvent CellEnabledByIndexChanged(Index, value)
            End If
        End Set
    End Property
    Property Visible() As Boolean
        Get
            Return mVisble
        End Get
        Set(ByVal value As Boolean)
            If mVisble = value Then Return
            mVisble = value
            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
                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
                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))
            ''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 * FontSizePercent / 100, rwFontSize)
                        '--------------------------------------------------------------
                        With mPct.Font
                            If fsz = .Size And rwBold = .Bold And .Name = rwFontName Then
                            Else
                                'qqqqq(Me.mName & ".FontGetSet() mPct.Font 変更された")
                                gggbol = Ⅹコントロールフォント変更(mPct, rwFontName, Math.Max(7, Math.Min(64, fsz)), FS) '2023/03/14 change
                            End If
                        End With
                        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 Not BtnIsStatic 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

    Friend Function IsInSide(ByVal x As Integer, ByVal y As Integer) As Boolean
        If Not Visible Then Return False
        Return x > mLEFT And x < mRIGHT And y > mTOP And y < mBOTTOM
    End Function
    '***********************************************************************************************
    Friend Sub PCTBOX_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
        gggbol = ⅩOLEDragDropテキストイベントANSI(2, mPct, e, "", 0, 0)
    End Sub
    Friend Sub PCTBOX_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
        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 a As Integer = CellIndexByXY(wDrpX_inControl, wDrpY_inControl, False)
            If a = 0 Then Return
            Dim sss As String = wTextANSI
            RaiseEvent CellTextByIndexChanged(a, sss)
            'イベントが処理されなかった場合は、ここで処理する
            gggbol = UserKeyText_NewSet(a, sss)
        End If
    End Sub
    Friend Function UserKeyText_NewSet(ByVal index As Integer, ByVal sss As String) As Boolean
        Try
            If index < 1 Then Return False
            Dim www As String = ⅩVBStrLeft(sss, cボタンテキストMax)
            Dim cap As String = ⅩStrChgOldStrNewStr(www, vbCrLf, "~")
            RaiseEvent CellTextByIndexChanged(index, cap)
            'イベントが処理されなかった場合は、ここで処理する
            If CellButtonText(index) <> cap Then
                CellButtonText(index) = cap
                gggbol = Draw(index)
                Me.mPct.Refresh()
                Return True
            End If
        Catch ex As Exception
            Return False
        End Try
    End Function
    '***********************************************************************************************
    Friend Sub PCTBOX_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        'If ButtonPushOnlyOneSelect Then qqqqq("mPct_MouseDown-1")
        Dim x As Integer = e.X : Dim y As Integer = e.Y
        Dim a As Integer
        If Not mPct.Visible Then Return
        If Not mEnabled Then Return
        '-------------------------------------------
        If (Not mCellColorSetEnabled) And e.Button = MouseButtons.Right Then
            gggbol = Ⅹマウスイベント検査2023(gcoMsDown, e)
            Return
        End If
        '-------------------------------------------
        'If ButtonPushOnlyOneSelect And BtnIsStatic Then qqqqq("mPct_MouseDown-3")
        '-------------------------------------------
        If e.Button <> MouseButtons.Left Then Return
        '-------------------------------------------
        If Not BtnIsStatic Then mCurBtn = 0
        '-------------------------------------------
        a = CellIndexByXY(x, y, False)
        If a = 0 Then Return
        With mDT(a)
            If .CellEnabled And .CellVisible Then
                If BtnIsStatic 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
                        mPct.Refresh()
                        Return
                    Else
                        .updn = True : mCurBtn = a : gggbol = Draw(mCurBtn)
                        mPct.Refresh()
                    End If
                Else
                    .updn = True : mCurBtn = a : gggbol = Draw(mCurBtn)
                    mPct.Refresh()
                End If
            End If
        End With
    End Sub
    Friend Sub PCTBOX_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs, ByVal UserCurText As TextBox)
        '------------------------------------------------------------------------------
        '2024/03/17 no op
        '------------------------------------------------------------------------------
    End Sub
    Friend Sub PCTBOX_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If Not mPct.Visible Then Return
        If Not mEnabled Then Return
        '-------------------------------------------
        If e.Button <> MouseButtons.Left Then Return
        '-------------------------------------------
        If mCurBtn = 0 Then Return 'in MouseDownEvent -----> If Not BtnIsStatic Then mCurBtn = 0
        '-------------------------------------------
        If BtnIsStatic Then
            If mButtonPushOnlyOneSelect Then
                gggbol = zzPushOneDownOthersUp(mCurBtn)
                mPct.Refresh()
            End If
            If mDT(mCurBtn).updn = True Then
                mIsMoseEvent = True : ButtonPushUpDown(mCurBtn) = True : mIsMoseEvent = False
                Dim index As Integer = mCurBtn
                Dim ttt As String = mDT(index).text
                RaiseEvent BtnStaticClick(index, ttt)
            End If
        Else
            mDT(mCurBtn).updn = False
            gggbol = Draw(mCurBtn)
            Dim index As Integer = mCurBtn
            mCurBtn = 0
            Dim ttt As String = mDT(index).text
            '--------------------------------------------
            '2024/02/29  If index = r改行コード文字CellIndex ---> 改行を出力
            If vbCrLf = BtnsText改行コードGetSet(0, index, 0, "") Then ttt = vbCrLf
            '--------------------------------------------
            RaiseEvent BtnClick(index, ttt)
        End If
        mPct.Refresh()
    End Sub

    Friend Function CellIndexByXY(ByVal x As Integer, ByVal y As Integer, ByVal ボタン間隔も含む As Boolean) As Integer
        If ボタン間隔も含む Then
            For a As Integer = 1 To mDTmax
                If mDT(a).rcag.Contains(x, y) Then Return a
            Next
            Dim xxx As Integer = x + SpaceCurValXY, yyy As Integer = y + SpaceCurValXY
            For a As Integer = 1 To mDTmax
                If mDT(a).rcag.Contains(xxx, yyy) Then Return a
            Next
        Else
            For a As Integer = 1 To mDTmax
                If mDT(a).rcag.Contains(x, y) Then Return a
            Next
        End If
        Return 0
    End Function

#End Region

#Region "New / Finalize"
    Public Sub New()
        MsgBox("データーが必要です")
    End Sub

    Public Sub New(ByVal rName As String, ByVal PCTBOX As PictureBox, ByVal rBtnIsStatic As Boolean, 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, ByVal rTexts As String, ByVal rFontSizePercent As Integer)
        mDrawEnable = False
        mPct = PCTBOX
        mName = rName
        BtnIsStatic = rBtnIsStatic
        mColumn = Ⅹ数値範囲Int(1, 50, rXko)
        mRow = Ⅹ数値範囲Int(1, 50, rYko)
        SpaceHilitu = rSpaSize
        mDTmax = mColumn * mRow
        ReDim mDT(mDTmax)
        For a As Integer = 1 To mDTmax
            With mDT(a) : .CellEnabled = True : .CellVisible = True : .updn = False : .CellColorIdx = 1 : End With
        Next
        For a As Integer = 1 To UBound(mColors)
            With mColors(a)
                If a = 1 Then
                    .UB = &HC0C0C0& : .UF = 0 : .DB = &HC0C0C0& : .DF = 0
                Else
                    .UB = -1 : .UF = -1 : .DB = -1 : .DF = -1
                End If
            End With
        Next
        AllButtonText = rTexts
        Enabled = True
        Visible = True
        mFontSizePercent = Ⅹ数値範囲Int(30, 70, rFontSizePercent) '2023/10/14 必要　既定のフォントサイズを初期決定する
    End Sub
    Public Sub New_ExDataSet(ByVal rDoTrimText As Boolean, ByVal rTextVposOffSetPercent As Integer, ByVal rCellColorSetEnabled As Boolean, ByVal UpBK As Integer, ByVal UpFR As Integer, ByVal DnBK As Integer, ByVal DnFR As Integer)
        DoTrimText = rDoTrimText
        TextVposOffSetPercent = rTextVposOffSetPercent
        CellColorSetEnabled = rCellColorSetEnabled
        gggbol = ColorsAllSetByInteger(UpBK, UpFR, DnBK, DnFR)
    End Sub

    Protected Overrides Sub Finalize()
        Try
        Catch ex As Exception
        End Try
        MyBase.Finalize()
    End Sub
#End Region

#Region "Call from frmMain.DlgColorSet_イベント -- from frmDlgColorSet"
    Friend Sub DlgColorSet_色のデーターをください(ByRef wmnu00_10 As String, ByRef wBackColorUP As Integer, ByRef wForeColorUP As Integer, ByRef wBackColorDN As Integer, ByRef wForeColorDN As Integer)
        If wmnu00_10 <> mName Then Return
        gggbol = ColorsAllGet(wBackColorUP, wForeColorUP, wBackColorDN, wForeColorDN)
    End Sub
    Friend Sub DlgColorSet_色を設定してください(ByRef wmnu00_10 As String, ByVal rBackColorUP As Integer, ByVal rForeColorUP As Integer, ByVal rBackColorDN As Integer, ByVal rForeColorDN As Integer)
        If wmnu00_10 <> mName Then Return
        gggbol = ColorsAllSet(rBackColorUP, rForeColorUP, rBackColorDN, rForeColorDN, True)
    End Sub
#End Region

End Class

