Ignore:
Timestamp:
Jul 2, 2007, 1:33:52 AM (17 years ago)
Author:
イグトランス (egtra)
Message:

#121対応、Classes/System/Windows/Forms以下を名前空間に入れた。

File:
1 edited

Legend:

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

    r240 r282  
    1717#require <Classes/System/Drawing/Rectangle.ab>
    1818#require <Classes/System/Runtime/InteropServices/GCHandle.ab>
     19#require <Classes/ActiveBasic/Strings/Strings.ab>
     20
     21Namespace System
     22Namespace Windows
     23Namespace Forms
     24
     25Namespace Detail
    1926
    2027TypeDef InvokeProc = *Function(p As VoidPtr) As VoidPtr
    2128
    2229Class AsyncResultForInvoke
    23     Inherits IAsyncResult
     30    Inherits System.IAsyncResult
    2431Public
    2532    ' Properties
     
    3239    End Function
    3340
    34     Override Function AsyncWaitHandle() As WaitHandle
     41    Override Function AsyncWaitHandle() As System.Threading.WaitHandle
    3542        Return waitHandle
    3643    End Function
     
    5360
    5461Private
    55     waitHandle As WaitHandle
     62    waitHandle As System.Threading.WaitHandle
    5663    result As VoidPtr
    5764End Class
     
    6370    AsyncResult As AsyncResultForInvoke
    6471End Class
     72
     73End Namespace 'Detail
    6574
    6675Class Control
     
    290299    ' 同期関数呼出、Controlが作成されたスレッドで関数を実行する。
    291300    ' 関数は同期的に呼び出されるので、関数が終わるまでInvokeは制御を戻さない。
    292     Function Invoke(pfn As InvokeProc, p As VoidPtr) As VoidPtr
     301    Function Invoke(pfn As System.Windows.Forms.Detail.InvokeProc, p As VoidPtr) As VoidPtr
    293302        Return wnd.SendMessage(WM_CONTROL_INVOKE, p As WPARAM, pfn As LPARAM) As VoidPtr
    294303    End Function
     
    297306    ' 関数は非同期的に呼び出されるので、BeginInvokeはすぐに制御を戻す。
    298307    ' 後にEndInvokeを呼び出すことにより、関数の戻り値を受け取れる。
    299     Function BeginInvoke(pfn As InvokeProc, p As VoidPtr) As IAsyncResult
     308    Function BeginInvoke(pfn As System.Windows.Forms.Detail.InvokeProc, p As VoidPtr) As System.IAsyncResult
    300309        ' EndInvokeがDeleteする
    301         Dim asyncResult = New AsyncResultForInvoke(CreateEvent(0, FALSE, FALSE, 0))
     310        Dim asyncResult = New System.Windows.Forms.Detail.AsyncResultForInvoke(CreateEvent(0, FALSE, FALSE, 0))
    302311        ' OnControlBeginInvokeがDeleteする
    303         Dim asyncInvokeData = New AsyncInvokeData
     312        Dim asyncInvokeData = New System.Windows.Forms.Detail.AsyncInvokeData
    304313        With asyncInvokeData
    305314            .FuncPtr = pfn
     
    307316            .AsyncResult = asyncResult
    308317        End With
    309         Dim gch = GCHandle.Alloc(asyncInvokeData)
    310         wnd.PostMessage(WM_CONTROL_BEGININVOKE, 0, GCHandle.ToIntPtr(gch))
     318        Dim gch = System.Runtime.InteropServices.GCHandle.Alloc(asyncInvokeData)
     319        wnd.PostMessage(WM_CONTROL_BEGININVOKE, 0, System.Runtime.InteropServices.GCHandle.ToIntPtr(gch))
    311320        Return pAsyncResult
    312321    End Function
     
    314323    ' BeginInvokeで呼び出した関数の戻り値を受け取る。
    315324    ' その関数がまだ終了していない場合、終了するまで待機する。
    316     Function EndInvoke(ar As IAsyncResult) As VoidPtr
     325    Function EndInvoke(ar As System.IAsyncResult) As VoidPtr
    317326        ar.WaitHandle.WaitOne()
    318         Dim arInvoke = ar As AsyncResultForInvoke
     327        Dim arInvoke = ar As System.Windows.Forms.Detail.AsyncResultForInvoke
    319328        Return arInvoke.Result
    320329    End Function
     
    327336        If IsWindow(hwnd) Then
    328337            If GetClassLongPtr(hwnd, GCW_ATOM) = atom Then
    329                 Dim gch = GCHandle.FromIntPtr(GetWindowLongPtr(hwnd, GWLP_THIS))
     338                Dim gch = System.Runtime.InteropServices.GCHandle.FromIntPtr(GetWindowLongPtr(hwnd, GWLP_THIS))
    330339                Return gch.Target As Control
    331340            End If
     
    424433            Select Case .Msg
    425434                Case WM_GETTEXTLENGTH
    426                     .Result = text.Length
     435                    .Result = text.Length 'ToDo: Unicode対応
    427436                Case WM_GETTEXT
    428                     Dim size = Math.Min(.WParam As ULONG_PTR, (text.Length + 1) As ULONG_PTR)
    429                     memcpy(.LParam As PCTSTR, ToTCStr(text), size * SizeOf (TCHAR))
     437                    Dim size = System.Math.Min(.WParam As SIZE_T, (text.Length + 1) As SIZE_T)
     438                    ActiveBasic.Strings.ChrCopy(.LParam As PCTSTR, ToTCStr(text), size)
    430439                    .Result = size
    431440                Case WM_SETTEXT
    432441                    text = New String(.LParam As PCTSTR)
    433442                Case WM_ENABLE
    434                     OnEnabledChanged(EventArgs.Empty)
     443                    OnEnabledChanged(System.EventArgs.Empty)
    435444                Case WM_ERASEBKGND
    436445                    ' OnPaintBackgroundに移すべき
     
    443452                    DeleteObject(hbr)
    444453                Case WM_CONTROL_INVOKE
    445                     Dim pfn = .LParam As InvokeProc
     454                    Dim pfn = .LParam As System.Windows.Forms.Detail.InvokeProc
    446455                    .Result = pfn(m.WParam As VoidPtr) As LRESULT
    447456                Case WM_CONTROL_BEGININVOKE
    448457                    OnControlBeginInvoke(m)
    449458                Case WM_CREATE
    450                     OnHandleCreated(EventArgs.Empty)
     459                    OnHandleCreated(System.EventArgs.Empty)
    451460                Case WM_DESTROY
    452                     OnHandleDestroyed(EventArgs.Empty)
     461                    OnHandleDestroyed(System.EventArgs.Empty)
    453462                Case Else
    454463                    DefWndProc(m)
     
    498507
    499508    Virtual Sub OnPaintBackground(e As PaintEventArgs) : End Sub
    500     Virtual Sub OnEnabledChanged(e As EventArgs) : End Sub
    501     Virtual Sub OnBackColorChanged(e As EventArgs) : End Sub
    502     Virtual Sub OnHandleCreated(e As EventArgs) : End Sub
    503     Virtual Sub OnHandleDestroyed(e As EventArgs) : End Sub
    504     Virtual Sub OnTextChanged(e As EventArgs)
     509    Virtual Sub OnEnabledChanged(e As System.EventArgs) : End Sub
     510    Virtual Sub OnBackColorChanged(e As System.EventArgs) : End Sub
     511    Virtual Sub OnHandleCreated(e As System.EventArgs) : End Sub
     512    Virtual Sub OnHandleDestroyed(e As System.EventArgs) : End Sub
     513    Virtual Sub OnTextChanged(e As System.EventArgs)
    505514        wnd.SetText(ToTCStr(text))
    506515    End Sub
     
    574583        If Object.ReferenceEquals(rThis As Object, Nothing) Then
    575584            Dim gchValue = TlsGetValue(tlsIndex) As LONG_PTR
    576             Dim gch = GCHandle.FromIntPtr(gchValue)
     585            Dim gch = System.Runtime.InteropServices.GCHandle.FromIntPtr(gchValue)
    577586            rThis = gch.Target As Control
    578587            ' ウィンドウが作られて最初にWndProcFirstが呼ばれたとき
     
    593602    ' BeginInvokeが呼ばれたときの処理
    594603    Sub OnControlBeginInvoke(m As Message)
    595         Dim gch = GCHandle.FromIntPtr(m.LParam)
    596         Dim data = gch.Target As AsyncInvokeData
     604        Dim gch = System.Runtime.InteropServices.GCHandle.FromIntPtr(m.LParam)
     605        Dim data = gch.Target As System.Windows.Forms.Detail.AsyncInvokeData
    597606        With data
    598607            Dim pfn = .FuncPtr
     
    603612End Class
    604613
     614Namespace Detail
    605615Class _System_ControlIinitializer
    606616Public
    607617    Sub _System_ControlIinitializer(hinst As HINSTANCE)
    608         Control.Initialize(hinst)
     618        System.Windows.Forms.Control.Initialize(hinst)
    609619    End Sub
    610620
    611621    Sub ~_System_ControlIinitializer()
    612         Control.Uninitialize()
     622        System.Windows.Forms.Control.Uninitialize()
    613623    End Sub
    614624End Class
     
    618628#endif '_SYSTEM_NO_INITIALIZE_CONTROL_
    619629
     630End Namespace
     631
     632End Namespace 'Forms
     633End Namespace 'Widnows
     634End Namespace 'System
     635
    620636#endif '__SYSTEM_WINDOWS_FORMS_CONTROL_AB__
    621637
Note: See TracChangeset for help on using the changeset viewer.