Ignore:
Timestamp:
Nov 25, 2007, 4:31:35 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

Stringなどで例外を投げるようにした。
#147の解決。
CType ASCII文字判定関数群の追加。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/System/Windows/Forms/Control.ab

    r381 r388  
    44#define __SYSTEM_WINDOWS_FORMS_CONTROL_AB__
    55
     6/*
    67#require <Classes/System/Windows/Forms/misc.ab>
    78#require <Classes/System/Windows/Forms/CreateParams.ab>
     
    1112#require <Classes/System/Math.ab>
    1213#require <Classes/System/Threading/WaitHandle.ab>
     14*/
    1315#require <Classes/System/Drawing/Color.ab>
    1416#require <Classes/System/Drawing/Point.ab>
    1517#require <Classes/System/Drawing/Size.ab>
    1618#require <Classes/System/Drawing/Rectangle.ab>
     19/*
    1720#require <Classes/System/Runtime/InteropServices/GCHandle.ab>
    1821#require <Classes/ActiveBasic/Windows/WindowHandle.sbp>
    1922#require <Classes/ActiveBasic/Strings/Strings.ab>
    20 
     23*/
    2124Namespace System
    2225Namespace Windows
     
    143146        End If
    144147    End Function
    145 
     148/* BoundsSpecifiedが使用不能なのでコメントアウト
    146149    Sub Bounds(r As Rectangle)
    147150        SetBoundsCore(r.X, r.Y, r.Width, r.Height, BoundsSpecified.All)
    148151    End Sub
    149 
     152*/
    150153    Const Function Location() As Point
    151154        Return Bounds.Location
    152155    End Function
    153 
     156/*
    154157    Sub Location(p As Point)
    155158        SetBoundsCore(p.X, p.Y, 0, 0, BoundsSpecified.Location)
    156159    End Sub
    157 
     160*/
    158161    Const Function Size() As Size
    159162        Return Bounds.Size
    160163    End Function
    161 
     164/*
    162165    Sub Size(s As Size)
    163166        SetBoundsCore(0, 0, s.Width, s.Height, BoundsSpecified.Size)
     
    171174        Return ClientRectangle.Size
    172175    End Function
    173 
     176*/
    174177    Const Function Left() As Long
    175178        Dim b = Bounds
    176179        Return b.Left
    177180    End Function
    178 
     181/*
    179182    Sub Left(l As Long)
    180183        SetBoundsCore(l, 0, 0, 0, BoundsSpecified.X)
    181184    End Sub
    182 
     185*/
    183186    Const Function Top() As Long
    184187        Dim b = Bounds
    185188        Return b.Top
    186189    End Function
    187 
     190/*
    188191    Sub Top(t As Long)
    189192        SetBoundsCore(0, t, 0, 0, BoundsSpecified.Y)
    190193    End Sub
    191 
     194*/
    192195    Const Function Width() As Long
    193196        Dim b = Bounds
    194197        Return b.Width
    195198    End Function
    196 
     199/*
    197200    Sub Width(w As Long)
    198201        SetBoundsCore(0, 0, w, 0, BoundsSpecified.Width)
    199202    End Sub
    200 
     203*/
    201204    Const Function Height() As Long
    202205        Dim b = Bounds
    203206        Return b.Height
    204207    End Function
    205 
     208/*
    206209    Sub Height(h As Long)
    207210        SetBoundsCore(0, 0, 0, h, BoundsSpecified.Height)
    208211    End Sub
    209 
     212*/
    210213    Const Function Right() As Long
    211214        Dim b = Bounds
     
    273276
    274277    Sub Control()
    275         Debug
    276278        Dim sz = DefaultSize()
    277         Control("", 100, 100, sz.Width, sz.Height)
     279        init(Nothing, "", 100, 100, sz.Width, sz.Height)
    278280    End Sub
    279281
    280282    Sub Control(text As String)
    281283        Dim sz = DefaultSize()
    282         Control(text, 100, 100, sz.Width, sz.Height)
     284        init(Nothing, text, 100, 100, sz.Width, sz.Height)
    283285    End Sub
    284286
    285287    Sub Control(parent As Control, text As String)
    286288        Dim sz = DefaultSize()
    287         Control(parent, text, 100, 100, sz.Width, sz.Height)
     289        init(parent, text, 100, 100, sz.Width, sz.Height)
    288290    End Sub
    289291
    290292    Sub Control(text As String, left As Long, top As Long, width As Long, height As Long)
    291         This.text = text
    292         bkColor = DefaultBackColor
     293        init(Nothing, text, left, top, width, height)
    293294    End Sub
    294295
    295296    Sub Control(parent As Control, text As String, left As Long, top As Long, width As Long, height As Long)
     297        init(parent, text, left, top, width, height)
     298    End Sub
     299
     300Private
     301
     302    Sub init(parent As Control, text As String, left As Long, top As Long, width As Long, height As Long)
    296303        This.parent = parent
    297         Control(text, left, top, width, height)
    298     End Sub
     304'       CreateControl()
     305    End Sub
     306   
    299307
    300308    '---------------------------------------------------------------------------
    301309    ' Destractor
    302 
     310Public
    303311    Virtual Sub ~Control()
    304312        If Not Object.ReferenceEquals(wnd, Nothing) Then
     
    398406
    399407    Virtual Function DefaultSize() As Size
    400         Dim s As Size(300, 300)
    401         Return s
     408        Return New Size(300, 300)
    402409    End Function
    403410
     
    411418    ' Protected Methods
    412419    Virtual Sub CreateHandle()
     420        Debug
     421        If Not Object.ReferenceEquals(wnd, Nothing) Then
     422            If wnd.HWnd <> 0 Then
     423                Exit Sub
     424            End If
     425        End If
     426       
    413427        Dim createParams = CreateParams()
    414428        Dim gch = System.Runtime.InteropServices.GCHandle.Alloc(This)
    415429        TlsSetValue(tlsIndex, System.Runtime.InteropServices.GCHandle.ToIntPtr(gch) As VoidPtr)
    416430        With createParams
    417             Dim hwndParent = 0 As HWND
    418             If Not Object.ReferenceEquals(parent, Nothing) Then
    419                 hwndParent = parent.Handle
    420             End If
    421431            Dim pText As PCTSTR
    422432            If String.IsNullOrEmpty(text) Then
     
    427437
    428438            If CreateWindowEx(.ExStyle, atom As ULONG_PTR As PCSTR, pText, .Style, _
    429                 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
    430                 hwndParent, 0, hInstance, 0) = 0 Then
     439                .X, .Y, .Width, .Height, _
     440                .Parent, 0, hInstance, 0) = 0 Then
    431441                ' Error
    432442                Dim buf[1023] As TCHAR
    433443                wsprintf(buf, ToTCStr(Ex"Control: CreateWindowEx failed. Error code: &h%08X\r\n"), GetLastError())
    434444                OutputDebugString(buf)
     445
     446                gch.Free()
    435447'               Debug
    436448                ExitThread(0)
    437449            End If
    438450        End With
    439         gch.Free()
     451       
    440452    End Sub
    441453
     
    475487                Case WM_DESTROY
    476488                    OnHandleDestroyed(System.EventArgs.Empty)
     489
     490                Case WM_LBUTTONDOWN
     491                    Goto *ButtonDown
     492*ButtonDown
    477493                Case Else
    478494                    DefWndProc(m)
     
    521537    End Sub
    522538
    523     Virtual Sub OnPaintBackground(e As PaintEventArgs) : End Sub
     539'   Virtual Sub OnPaintBackground(e As PaintEventArgs) : End Sub
    524540    Virtual Sub OnEnabledChanged(e As System.EventArgs) : End Sub
    525541    Virtual Sub OnBackColorChanged(e As System.EventArgs) : End Sub
     
    582598            .Style = WS_OVERLAPPEDWINDOW
    583599            .ExStyle = WS_EX_APPWINDOW
     600            .Caption = String.Empty
     601            .X = 0
     602            .Y = 0
     603            .Width = 0
     604            .Height = 0
    584605        End With
    585606    End Sub
     
    608629            rThis.wnd = New ActiveBasic.Windows.WindowHandle(hwnd)
    609630            SetWindowLongPtr(hwnd, GWLP_THIS, gchValue)
     631        ElseIf msg = WM_NCDESTROY Then
     632            Dim gch = System.Runtime.InteropServices.GCHandle.FromIntPtr(GetWindowLongPtr(hwnd, GWLP_THIS))
     633             gch.Free()
    610634        End If
    611635
Note: See TracChangeset for help on using the changeset viewer.