Changeset 282 for Include/Classes/System/Windows/Forms/Control.ab
- Timestamp:
- Jul 2, 2007, 1:33:52 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Windows/Forms/Control.ab
r240 r282 17 17 #require <Classes/System/Drawing/Rectangle.ab> 18 18 #require <Classes/System/Runtime/InteropServices/GCHandle.ab> 19 #require <Classes/ActiveBasic/Strings/Strings.ab> 20 21 Namespace System 22 Namespace Windows 23 Namespace Forms 24 25 Namespace Detail 19 26 20 27 TypeDef InvokeProc = *Function(p As VoidPtr) As VoidPtr 21 28 22 29 Class AsyncResultForInvoke 23 Inherits IAsyncResult30 Inherits System.IAsyncResult 24 31 Public 25 32 ' Properties … … 32 39 End Function 33 40 34 Override Function AsyncWaitHandle() As WaitHandle41 Override Function AsyncWaitHandle() As System.Threading.WaitHandle 35 42 Return waitHandle 36 43 End Function … … 53 60 54 61 Private 55 waitHandle As WaitHandle62 waitHandle As System.Threading.WaitHandle 56 63 result As VoidPtr 57 64 End Class … … 63 70 AsyncResult As AsyncResultForInvoke 64 71 End Class 72 73 End Namespace 'Detail 65 74 66 75 Class Control … … 290 299 ' 同期関数呼出、Controlが作成されたスレッドで関数を実行する。 291 300 ' 関数は同期的に呼び出されるので、関数が終わるまでInvokeは制御を戻さない。 292 Function Invoke(pfn As InvokeProc, p As VoidPtr) As VoidPtr301 Function Invoke(pfn As System.Windows.Forms.Detail.InvokeProc, p As VoidPtr) As VoidPtr 293 302 Return wnd.SendMessage(WM_CONTROL_INVOKE, p As WPARAM, pfn As LPARAM) As VoidPtr 294 303 End Function … … 297 306 ' 関数は非同期的に呼び出されるので、BeginInvokeはすぐに制御を戻す。 298 307 ' 後にEndInvokeを呼び出すことにより、関数の戻り値を受け取れる。 299 Function BeginInvoke(pfn As InvokeProc, p As VoidPtr) AsIAsyncResult308 Function BeginInvoke(pfn As System.Windows.Forms.Detail.InvokeProc, p As VoidPtr) As System.IAsyncResult 300 309 ' 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)) 302 311 ' OnControlBeginInvokeがDeleteする 303 Dim asyncInvokeData = New AsyncInvokeData312 Dim asyncInvokeData = New System.Windows.Forms.Detail.AsyncInvokeData 304 313 With asyncInvokeData 305 314 .FuncPtr = pfn … … 307 316 .AsyncResult = asyncResult 308 317 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)) 311 320 Return pAsyncResult 312 321 End Function … … 314 323 ' BeginInvokeで呼び出した関数の戻り値を受け取る。 315 324 ' その関数がまだ終了していない場合、終了するまで待機する。 316 Function EndInvoke(ar As IAsyncResult) As VoidPtr325 Function EndInvoke(ar As System.IAsyncResult) As VoidPtr 317 326 ar.WaitHandle.WaitOne() 318 Dim arInvoke = ar As AsyncResultForInvoke327 Dim arInvoke = ar As System.Windows.Forms.Detail.AsyncResultForInvoke 319 328 Return arInvoke.Result 320 329 End Function … … 327 336 If IsWindow(hwnd) Then 328 337 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)) 330 339 Return gch.Target As Control 331 340 End If … … 424 433 Select Case .Msg 425 434 Case WM_GETTEXTLENGTH 426 .Result = text.Length 435 .Result = text.Length 'ToDo: Unicode対応 427 436 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) 430 439 .Result = size 431 440 Case WM_SETTEXT 432 441 text = New String(.LParam As PCTSTR) 433 442 Case WM_ENABLE 434 OnEnabledChanged( EventArgs.Empty)443 OnEnabledChanged(System.EventArgs.Empty) 435 444 Case WM_ERASEBKGND 436 445 ' OnPaintBackgroundに移すべき … … 443 452 DeleteObject(hbr) 444 453 Case WM_CONTROL_INVOKE 445 Dim pfn = .LParam As InvokeProc454 Dim pfn = .LParam As System.Windows.Forms.Detail.InvokeProc 446 455 .Result = pfn(m.WParam As VoidPtr) As LRESULT 447 456 Case WM_CONTROL_BEGININVOKE 448 457 OnControlBeginInvoke(m) 449 458 Case WM_CREATE 450 OnHandleCreated( EventArgs.Empty)459 OnHandleCreated(System.EventArgs.Empty) 451 460 Case WM_DESTROY 452 OnHandleDestroyed( EventArgs.Empty)461 OnHandleDestroyed(System.EventArgs.Empty) 453 462 Case Else 454 463 DefWndProc(m) … … 498 507 499 508 Virtual Sub OnPaintBackground(e As PaintEventArgs) : End Sub 500 Virtual Sub OnEnabledChanged(e As EventArgs) : End Sub501 Virtual Sub OnBackColorChanged(e As EventArgs) : End Sub502 Virtual Sub OnHandleCreated(e As EventArgs) : End Sub503 Virtual Sub OnHandleDestroyed(e As EventArgs) : End Sub504 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) 505 514 wnd.SetText(ToTCStr(text)) 506 515 End Sub … … 574 583 If Object.ReferenceEquals(rThis As Object, Nothing) Then 575 584 Dim gchValue = TlsGetValue(tlsIndex) As LONG_PTR 576 Dim gch = GCHandle.FromIntPtr(gchValue)585 Dim gch = System.Runtime.InteropServices.GCHandle.FromIntPtr(gchValue) 577 586 rThis = gch.Target As Control 578 587 ' ウィンドウが作られて最初にWndProcFirstが呼ばれたとき … … 593 602 ' BeginInvokeが呼ばれたときの処理 594 603 Sub OnControlBeginInvoke(m As Message) 595 Dim gch = GCHandle.FromIntPtr(m.LParam)596 Dim data = gch.Target As AsyncInvokeData604 Dim gch = System.Runtime.InteropServices.GCHandle.FromIntPtr(m.LParam) 605 Dim data = gch.Target As System.Windows.Forms.Detail.AsyncInvokeData 597 606 With data 598 607 Dim pfn = .FuncPtr … … 603 612 End Class 604 613 614 Namespace Detail 605 615 Class _System_ControlIinitializer 606 616 Public 607 617 Sub _System_ControlIinitializer(hinst As HINSTANCE) 608 Control.Initialize(hinst)618 System.Windows.Forms.Control.Initialize(hinst) 609 619 End Sub 610 620 611 621 Sub ~_System_ControlIinitializer() 612 Control.Uninitialize()622 System.Windows.Forms.Control.Uninitialize() 613 623 End Sub 614 624 End Class … … 618 628 #endif '_SYSTEM_NO_INITIALIZE_CONTROL_ 619 629 630 End Namespace 631 632 End Namespace 'Forms 633 End Namespace 'Widnows 634 End Namespace 'System 635 620 636 #endif '__SYSTEM_WINDOWS_FORMS_CONTROL_AB__ 621 637
Note:
See TracChangeset
for help on using the changeset viewer.