Changeset 223 for Include/Classes/System
- Timestamp:
- Apr 30, 2007, 1:56:57 PM (18 years ago)
- Location:
- Include/Classes/System
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Drawing/Point.ab
r212 r223 4 4 #define __SYSTEM_DRAWING_POINT_AB__ 5 5 6 # include <Classes/System/Drawing/PointF.ab>7 # include <Classes/System/Drawing/Size.ab>8 # include <Classes/System/Drawing/SizeF.ab>6 #require <Classes/System/Drawing/PointF.ab> 7 #require <Classes/System/Drawing/Size.ab> 8 #require <Classes/System/Drawing/SizeF.ab> 9 9 10 10 Class Point … … 20 20 End Sub 21 21 22 Sub Point(pt As Point) 23 x = pt.x 24 y = pt.y 25 End Sub 26 27 Sub Point(ByRef sz As Size) 22 Sub Point(sz As Size) 28 23 x = sz.Width 29 24 y = sz.Height … … 54 49 Return x = 0 And y = 0 55 50 End Function 56 /* 57 Sub Operator = (ByRef pt As Point) 58 x = pt.x 59 y = pt.y 60 End Sub 61 */ 51 62 52 Function Operator + (pt As Point) As Point 63 53 Return Add(This, pt) -
Include/Classes/System/Drawing/Rectangle.ab
r212 r223 4 4 #define __SYSTEM_DRAWING_RECTANGLE_AB__ 5 5 6 # include <Classes/System/Math.ab>7 # include <Classes/System/Drawing/RectangleF.ab>8 # include <Classes/System/Drawing/Point.ab>9 # include <Classes/System/Drawing/Size.ab>6 #require <Classes/System/Math.ab> 7 #require <Classes/System/Drawing/RectangleF.ab> 8 #require <Classes/System/Drawing/Point.ab> 9 #require <Classes/System/Drawing/Size.ab> 10 10 11 11 Class Rectangle … … 32 32 End Sub 33 33 34 Sub Rectangle(ByRef r As Rectangle)35 x = r.x36 y = r.y37 width = r.width38 height = r.height39 End Sub40 41 34 Sub Rectangle(ByRef r As RECT) 42 This = FromLTRB(r.left, r.top, r.right, r.bottom) 35 x = r.left 36 y = r.top 37 width = r.right - r.left 38 height = r.top - r.bottom 43 39 End Sub 44 40 … … 111 107 112 108 Function IsEmpty() As Boolean 113 If Width <= 0 Or Height <= 0 Then 114 IsEmpty = _System_TRUE 115 Else 116 IsEmpty = _System_FALSE 117 End If 118 End Function 119 /* 120 Function Operator = (rc As Rectangle) 121 With rc 122 x = .x 123 y = .y 124 width = .width 125 height = .height 126 End With 127 End Function 128 */ 109 Return Width <= 0 Or Height <= 0 110 End Function 111 129 112 Function Operator == (rc As Rectangle) 130 113 Return Equals(rc) … … 140 123 141 124 Function Equals(rc As Rectangle) As Boolean 142 If X = rc.X And Y = rc.Y And Width = rc.Width And Height = rc.Height Then 143 Return True 144 Else 145 Return False 146 End If 125 Return X = rc.X And Y = rc.Y And Width = rc.Width And Height = rc.Height 147 126 End Function 148 127 149 128 Override Function GetHashCode() As Long 150 Return x Xor _System_BSwap(y) Xor width Xor _System_BSwap(height)129 Return x As DWord Xor _System_BSwap(y As DWord) Xor width As DWord Xor _System_BSwap(height As DWord) 151 130 End Function 152 131 153 132 Static Function FromLTRB(l As Long, t As Long, r As Long, b As Long) As Rectangle 154 return New Rectangle(l, t, r - l, r - b)133 return New Rectangle(l, t, r - l, b - t) 155 134 End Function 156 135 157 136 Function Contains(x As Long, y As Long) As Boolean 158 If x >= X And x < X + Width And y >= Y And y < Y + Height Then 159 Return True 160 Else 161 Return False 162 End If 137 Return x >= X And x < X + Width And y >= Y And y < Y + Height 163 138 End Function 164 139 … … 168 143 169 144 Function Contains(rc As Rectangle) As Boolean 170 If X <= rc.X And rc.Right <= Right And Y <= rc.Y And rc.Bottom <= Bottom Then 171 Return True 172 Else 173 Return False 174 End If 145 Return X <= rc.X And rc.Right <= Right And Y <= rc.Y And rc.Bottom <= Bottom 175 146 End Function 176 147 … … 205 176 206 177 Function IntersectsWith(rc As Rectangle) As Boolean 207 IfLeft < rc.Right And _178 Return Left < rc.Right And _ 208 179 Top < rc.Bottom And _ 209 180 Right > rc.Left And _ 210 Bottom > rc.Top Then 211 Return True 212 Else 213 Return False 214 End If 181 Bottom > rc.Top 215 182 End Function 216 183 -
Include/Classes/System/Drawing/Size.ab
r212 r223 77 77 78 78 Override Function GetHashCode() As Long 79 Return width Xor _System_BSwap(height)79 Return width As DWord Xor _System_BSwap(height As DWord) 80 80 End Function 81 81 -
Include/Classes/System/Drawing/SizeF.ab
r212 r223 64 64 */ 65 65 Function Equals(sz As SizeF) As Boolean 66 If width = sz.width And height = sz.height Then 67 Equals = _System_TRUE 68 Else 69 Equals = _System_FALSE 70 End If 66 Return width = sz.width And height = sz.height 71 67 End Function 72 68 73 69 Override Function GetHashCode() As Long 74 70 Return VarPtr(GetDWord(width)) Xor _System_BSwap(VarPtr(GetDWord(height))) 71 End Function 75 72 76 73 Function IsEmpty() As Boolean 77 If width = 0 And height = 0 Then 78 Empty = _System_TRUE 79 Else 80 Empty = _System_FALSE 81 End If 74 Return width = 0 And height = 0 82 75 End Function 83 76 -
Include/Classes/System/Runtime/InteropServices/GCHandle.ab
r208 r223 12 12 Sub Target(obj As Object) 13 13 allocated.Add(obj) 14 handle = GetPointer(VarPtr(obj)) 14 15 End Sub 15 16 … … 24 25 25 26 Sub Free() 26 Dim pobj = VarPtr(handle) As *Object27 27 allocated.Remove(Target) 28 28 handle = 0 … … 30 30 31 31 Static Function ToIntPtr(h As GCHandle) As LONG_PTR 32 Return h.handle As LONG_PTR Xor &hffffffff As LONG_PTR32 Return h.handle As LONG_PTR 33 33 End Function 34 34 35 35 Static Function FromIntPtr(ip As LONG_PTR) As GCHandle 36 36 FromIntPtr = New GCHandle 37 FromIntPtr.handle = (ip Xor &hffffffff As LONG_PTR)As VoidPtr37 FromIntPtr.handle = ip As VoidPtr 38 38 End Function 39 39 -
Include/Classes/System/Windows/Forms/Control.ab
r132 r223 4 4 #define __SYSTEM_WINDOWS_FORMS_CONTROL_AB__ 5 5 6 #include <windows/WindowHandle.sbp> 7 #include <Classes/System/Windows/Forms/misc.ab> 8 #include <Classes/System/Windows/Forms/CreateParams.ab> 9 #include <Classes/System/Windows/Forms/Message.ab> 10 #include <Classes/System/Windows/Forms/PaintEventArgs.ab> 11 #include <Classes/System/misc.ab> 12 #include <Classes/System/Math.ab> 13 #include <Classes/System/Threading/WaitHandle.ab> 14 #include <Classes/System/Drawing/Color.ab> 15 #include <Classes/System/Drawing/Point.ab> 16 #include <Classes/System/Drawing/Size.ab> 17 #include <Classes/System/Drawing/Rectangle.ab> 6 #require <windows/WindowHandle.sbp> 7 #require <Classes/System/Windows/Forms/misc.ab> 8 #require <Classes/System/Windows/Forms/CreateParams.ab> 9 #require <Classes/System/Windows/Forms/Message.ab> 10 #require <Classes/System/Windows/Forms/PaintEventArgs.ab> 11 #require <Classes/System/misc.ab> 12 #require <Classes/System/Math.ab> 13 #require <Classes/System/Threading/WaitHandle.ab> 14 #require <Classes/System/Drawing/Color.ab> 15 #require <Classes/System/Drawing/Point.ab> 16 #require <Classes/System/Drawing/Size.ab> 17 #require <Classes/System/Drawing/Rectangle.ab> 18 #require <Classes/System/Runtime/InteropServices/GCHandle.ab> 19 20 TypeDef InvokeProc = *Function(p As VoidPtr) As VoidPtr 18 21 19 22 Class AsyncResultForInvoke … … 25 28 End Sub 26 29 27 Override Function AsyncState() As *IObject28 Return 029 End Function 30 31 Override Function AsyncWaitHandle() As *WaitHandle32 Return VarPtr(AsyncWaitHandle)30 Override Function AsyncState() As IObject 31 Return Nothing 32 End Function 33 34 Override Function AsyncWaitHandle() As WaitHandle 35 Return waitHandle 33 36 End Function 34 37 … … 38 41 39 42 Override Function IsCompleted() As BOOL 40 Return AsyncWaitHandle()->WaitOne(0, FALSE)43 Return waitHandle.WaitOne(0, FALSE) 41 44 End Function 42 45 … … 56 59 Class AsyncInvokeData 57 60 Public 58 FuncPtr As *Function(p As VoidPtr) As VoidPtr61 FuncPtr As InvokeProc 59 62 Data As *VoidPtr 60 AsyncResult As *AsyncResultForInvoke63 AsyncResult As AsyncResultForInvoke 61 64 End Class 62 65 63 66 Class Control 64 Inherits IWin32Window67 ' Inherits IWin32Window 65 68 Public 66 69 '--------------------------------------------------------------------------- 67 70 ' Public Properties 68 71 69 Function AllowDrop() As B OOL70 End Function 71 72 OverrideFunction Handle() As HWND72 Function AllowDrop() As Boolean 73 End Function 74 75 /*Override*/ Function Handle() As HWND 73 76 Return wnd.HWnd 74 77 End Function 75 78 76 79 ' IDropTargetを実装するのでDragAcceptFiles関数は呼ばない。 77 Sub AllowDrop(a As B OOL)78 End Sub 79 80 Const Function Visible() As B OOL80 Sub AllowDrop(a As Boolean) 81 End Sub 82 83 Const Function Visible() As Boolean 81 84 Return wnd.Visible 82 85 End Function 83 86 84 Sub Visible(v As B OOL)87 Sub Visible(v As Boolean) 85 88 wnd.Visible(v) 86 89 End Sub … … 96 99 End Sub 97 100 98 Const Function Enabled() As B OOL101 Const Function Enabled() As Boolean 99 102 Return wnd.Enabled 100 103 End Function 101 104 102 Sub Enabled(e As B OOL)105 Sub Enabled(e As Boolean) 103 106 ' OnEnabledChangedはWM_ENABLE経由で呼ばれる 104 107 wnd.Enabled(e) … … 108 111 Dim wr As RECT 109 112 wr = wnd.WindowRect 110 Dim r AsRectangle(wr)113 Dim r = New Rectangle(wr) 111 114 Dim parent = Parent 112 If parent <> 0Then115 If Object.ReferenceEquals(parent, Nothing) Then 113 116 Return parent->RectangleToClient(r) 114 117 Else … … 117 120 End Function 118 121 119 Sub Bounds( ByRefr As Rectangle)122 Sub Bounds(r As Rectangle) 120 123 SetBoundsCore(r.X, r.Y, r.Width, r.Height, BoundsSpecified.All) 121 124 End Sub … … 138 141 139 142 Const Function ClientRectangle() As Rectangle 140 Dim r As Rectangle(wnd.ClientRect) 141 Return r 143 Return New Rectangle(wnd.ClientRect) 142 144 End Function 143 145 … … 191 193 192 194 Const Function PointToScreen(p As Point) As Point 193 wnd.ClientToScreen(ByVal VarPtr(p) As *POINTAPI) 194 Return r 195 PointToScreen = New Point 196 ret.X = p.X 197 ret.Y = p.Y 198 wnd.ClientToScreen(ByVal VarPtr(PointToScreen) As *POINTAPI) 195 199 End Function 196 200 197 201 Const Function PointToClient(p As Point) As Point 198 wnd.ScreenToClient(ByVal VarPtr(p) As *POINTAPI) 199 Return r 200 End Function 201 202 Const Function RectangleToScreen(p As Rectangle) As Rectangle 203 wnd.ClientToScreen(ByVal VarPtr(p) As *POINTAPI) 204 Return p 205 End Function 206 207 Const Function RectangleToClient(p As Rectangle) As Rectangle 208 wnd.ScreenToClient(ByVal VarPtr(p) As *POINTAPI) 209 Return p 210 End Function 211 212 Const Function InvokeRequired() As BOOL 202 PointToScreen = New Point 203 ret.X = p.X 204 ret.Y = p.Y 205 wnd.ScreenToClient(ByVal VarPtr(PointToScreen) As *POINTAPI) 206 End Function 207 208 Const Function RectangleToScreen(r As Rectangle) As Rectangle 209 Dim rc = r.ToRECT 210 wnd.ClientToScreen(rc) 211 Return New Rectangle(rc) 212 End Function 213 214 Const Function RectangleToClient(r As Rectangle) As Rectangle 215 Dim rc As RECT 216 rc = r.ToRECT() 217 wnd.ScreenToClient(rc) 218 Return New Rectangle(rc) 219 End Function 220 221 Const Function InvokeRequired() As Boolean 213 222 Return wnd.ThreadID <> GetCurrentThreadId() 214 223 End Function … … 224 233 End Sub 225 234 226 Function Parent() As *Control235 Function Parent() As Control 227 236 Return parent 237 End Function 238 239 Const Function IsHandleCreated() As Boolean 240 Return wnd.HWnd <> 0 228 241 End Function 229 242 … … 240 253 End Sub 241 254 242 Sub Control( ByReftext As String)255 Sub Control(text As String) 243 256 Dim sz = DefaultSize() 244 257 Control(text, 100, 100, sz.Width, sz.Height) 245 258 End Sub 246 259 247 Sub Control( ByRef parent As Control, ByReftext As String)260 Sub Control(parent As Control, text As String) 248 261 Dim sz = DefaultSize() 249 262 Control(parent, text, 100, 100, sz.Width, sz.Height) 250 263 End Sub 251 264 252 Sub Control( ByReftext As String, left As Long, top As Long, width As Long, height As Long)265 Sub Control(text As String, left As Long, top As Long, width As Long, height As Long) 253 266 This.text = text 254 267 bkColor = DefaultBackColor … … 257 270 End Sub 258 271 259 Sub Control( ByRef parent As Control, ByReftext As String, left As Long, top As Long, width As Long, height As Long)272 Sub Control(parent As Control, text As String, left As Long, top As Long, width As Long, height As Long) 260 273 This.parent = VarPtr(parent) 261 274 Control(text, left, top, width, height) … … 276 289 ' 同期関数呼出、Controlが作成されたスレッドで関数を実行する。 277 290 ' 関数は同期的に呼び出されるので、関数が終わるまでInvokeは制御を戻さない。 278 Function Invoke(pfn As *Function(p As VoidPtr) As VoidPtr, p As VoidPtr) As VoidPtr291 Function Invoke(pfn As InvokeProc, p As VoidPtr) As VoidPtr 279 292 Return wnd.SendMessage(WM_CONTROL_INVOKE, p As WPARAM, pfn As LPARAM) As VoidPtr 280 293 End Function … … 283 296 ' 関数は非同期的に呼び出されるので、BeginInvokeはすぐに制御を戻す。 284 297 ' 後にEndInvokeを呼び出すことにより、関数の戻り値を受け取れる。 285 ' 注意:現状の実装では必ずEndInvokeを呼び出す必要がある。 286 Function BeginInvoke(pfn As *Function(p As VoidPtr) As VoidPtr, p As VoidPtr) As *IAsyncResult 298 Function BeginInvoke(pfn As InvokeProc, p As VoidPtr) As IAsyncResult 287 299 ' EndInvokeがDeleteする 288 Dim pAsyncResult = New AsyncResultForInvoke(CreateEvent(0, FALSE, FALSE, 0))300 Dim asyncResult = New AsyncResultForInvoke(CreateEvent(0, FALSE, FALSE, 0)) 289 301 ' OnControlBeginInvokeがDeleteする 290 Dim pAsyncInvokeData = New AsyncInvokeData291 With pAsyncInvokeData[0]302 Dim asyncInvokeData = New AsyncInvokeData 303 With asyncInvokeData 292 304 .FuncPtr = pfn 293 305 .Data = p 294 .AsyncResult = pAsyncResult306 .AsyncResult = asyncResult 295 307 End With 296 wnd.PostMessage(WM_CONTROL_BEGININVOKE, 0, pAsyncInvokeData As LPARAM) 308 Dim gch = GCHandle.Alloc(asyncInvokeData) 309 wnd.PostMessage(WM_CONTROL_BEGININVOKE, 0, GCHandle.ToIntPtr(gch)) 297 310 Return pAsyncResult 298 311 End Function … … 300 313 ' BeginInvokeで呼び出した関数の戻り値を受け取る。 301 314 ' その関数がまだ終了していない場合、終了するまで待機する。 302 Function EndInvoke(ar As *IAsyncResult) As VoidPtr 303 ar->WaitHandle->WaitOne() 304 Dim arInvoke = ar As *AsyncResultForInvoke 305 Dim result = arInvoke->Result 306 Delete arInvoke 307 Return result 315 Function EndInvoke(ar As IAsyncResult) As VoidPtr 316 ar.WaitHandle.WaitOne() 317 Dim arInvoke = ar As AsyncResultForInvoke 318 Return arInvoke.Result 308 319 End Function 309 320 310 321 ' 与えられたウィンドウハンドルがControl(若しくはその派生クラス)の 311 322 ' インスタンスに対応するものであった場合、 312 ' 元のインスタンス へのポインタを返す。313 ' そうでなければ ヌルポインタを返す。314 Static Function FromHandle(hwnd As HWND) As *Control323 ' 元のインスタンスを返す。 324 ' そうでなければNothingを返す。 325 Static Function FromHandle(hwnd As HWND) As Control 315 326 If IsWindow(hwnd) Then 316 Dim className[19] As Byte 'Len (WindowClassName) 317 GetClassName(hwnd, className, Len (className)) 318 If memcmp(className, WindowClassName, Len (WindowClassName)) = 0 Then 319 Return GetWindowLongPtr(hwnd, GWLP_THIS) As *Control 327 If GetClassLongPtr(hwnd, GCW_ATOM) = atom Then 328 Dim gch = GCHandle.FromIntPtr(GetWindowLongPtr(hwnd, GWLP_THIS)) 329 Return gch.Target As Control 320 330 End If 321 331 End If 322 Return 0 As *Control332 Return Nothing As Control 323 333 End Function 324 334 … … 327 337 End Sub 328 338 329 /*Override*/ VirtualFunction ToString() As String339 Override Function ToString() As String 330 340 Return text 331 341 End Function … … 351 361 '--------------------------------------------------------------------------- 352 362 ' Protected Properties 353 ' Const Virtual Function CanRaiseEvents() As B OOL354 Virtual Function CreateParams() As *CreateParams355 Return VarPtr(createParams)363 ' Const Virtual Function CanRaiseEvents() As Boolean 364 Virtual Function CreateParams() As CreateParams 365 Return createParams 356 366 End Function 357 367 … … 373 383 Virtual Sub CreateHandle() 374 384 Dim createParams = CreateParams() 375 TlsSetValue(tlsIndex, VarPtr(This)) 385 Dim gch = GCHandle.Alloc(This) 386 TlsSetValue(tlsIndex, GCHandle.ToIntPtr(gch) As VoidPtr) 376 387 With createParams[0] 377 388 Dim hwndParent = 0 As HWND 378 If parent <> 0Then379 hwndParent = parent ->Handle389 If Not Object.ReferenceEquals(parent, Nothing) Then 390 hwndParent = parent.Handle 380 391 End If 381 392 If CreateWindowEx(.ExStyle, atom As ULONG_PTR As PCSTR, text, .Style, _ … … 383 394 hwndParent, 0, hInstance, 0) = 0 Then 384 395 ' Error 385 Dim buf[1023] As Byte386 wsprintf(buf, Ex"Control: CreateWindowEx failed. Error code: &h%08X\r\n", GetLastError())396 Dim buf[1023] As TCHAR 397 wsprintf(buf, ToTCStr(Ex"Control: CreateWindowEx failed. Error code: &h%08X\r\n"), GetLastError()) 387 398 OutputDebugString(buf) 388 399 ' Debug … … 390 401 End If 391 402 End With 392 End Sub 393 394 Virtual Sub DefWndProc(ByRef m As Message) 403 gch.Free() 404 End Sub 405 406 Virtual Sub DefWndProc(m As Message) 395 407 m.Result = DefWindowProc(m.HWnd, m.Msg, m.WParam, m.LParam) 396 408 End Sub 397 409 398 Virtual Sub WndProc( ByRefm As Message)410 Virtual Sub WndProc(m As Message) 399 411 With m 400 412 Select Case .Msg … … 402 414 .Result = text.Length 403 415 Case WM_GETTEXT 404 Dim size = Math.Min(.WParam As ULONG_PTR, text.Length As ULONG_PTR + 1)405 memcpy(.LParam As *Byte, text.StrPtr, size)416 Dim size = Math.Min(.WParam As ULONG_PTR, (text.Length + 1) As ULONG_PTR) 417 memcpy(.LParam As PCTSTR, ToTCStr(text), size * SizeOf (TCHAR)) 406 418 .Result = size 407 419 Case WM_SETTEXT 408 text = .LParam As *Byte420 text = New String(.LParam As PCTSTR) 409 421 Case WM_ENABLE 410 Dim e As EventArgs 411 OnEnabledChanged(e) 422 OnEnabledChanged(EventArgs.Empty) 412 423 Case WM_ERASEBKGND 413 424 ' OnPaintBackgroundに移すべき … … 420 431 DeleteObject(hbr) 421 432 Case WM_CONTROL_INVOKE 422 Dim pfn As *Function(p As VoidPtr) As VoidPtr 423 pfn = .LParam As *Function(p As VoidPtr) As VoidPtr 433 Dim pfn = .LParam As InvokeProc 424 434 .Result = pfn(m.WParam As VoidPtr) As LRESULT 425 435 Case WM_CONTROL_BEGININVOKE 426 436 OnControlBeginInvoke(m) 437 Case WM_CREATE 438 OnHandleCreated(EventArgs.Empty) 427 439 Case Else 428 440 DefWndProc(m) … … 450 462 451 463 Virtual Sub SetBoundsCore(x As Long, y As Long, width As Long, height As Long, bs As BoundsSpecified) 452 If Not (bs As DWord And BoundsSpecified.X As DWord) Then464 ' If Not (bs As DWord And BoundsSpecified.X As DWord) Then 453 465 x = Left 454 End If455 If Not (bs As DWord And BoundsSpecified.Y As DWord) Then466 ' End If 467 ' If Not (bs As DWord And BoundsSpecified.Y As DWord) Then 456 468 y = Right 457 End If458 If Not (bs As DWord And BoundsSpecified.Width As DWord) Then469 ' End If 470 ' If Not (bs As DWord And BoundsSpecified.Width As DWord) Then 459 471 width = Width 460 End If461 If Not (bs As DWord And BoundsSpecified.Height As DWord) Then472 ' End If 473 ' If Not (bs As DWord And BoundsSpecified.Height As DWord) Then 462 474 height = Height 463 End If475 ' End If 464 476 wnd.Move(x, y, width, height) 465 477 End Sub … … 471 483 End Sub 472 484 473 Virtual Sub OnPaintBackground(ByRef e As PaintEventArgs) : End Sub 474 Virtual Sub OnEnabledChanged(ByRef e As EventArgs) : End Sub 475 Virtual Sub OnBackColorChanged(ByRef e As EventArgs) : End Sub 476 Virtual Sub OnTextChanged(ByRef e As EventArgs) 477 wnd.SetText(text.StrPtr) 485 Virtual Sub OnPaintBackground(e As PaintEventArgs) : End Sub 486 Virtual Sub OnEnabledChanged(e As EventArgs) : End Sub 487 Virtual Sub OnBackColorChanged(e As EventArgs) : End Sub 488 Virtual Sub OnHandleCreated(e As EventArgs) : End Sub 489 Virtual Sub OnTextChanged(e As EventArgs) 490 wnd.SetText(ToTCStr(text)) 478 491 End Sub 479 492 … … 482 495 wnd As WindowHandle 483 496 text As String 484 parent As *Control497 parent As Control 485 498 bkColor As Color 486 499 … … 496 509 Static Const WM_CONTROL_BEGININVOKE = WM_USER + 1 As DWord 497 510 498 Static Const WindowClassName = "ActiveBasic Control" As *Byte511 Static Const WindowClassName = "ActiveBasic Control" 499 512 Public 500 513 Static Sub Initialize(hinst As HINSTANCE) … … 519 532 atom = RegisterClassEx(wcx) 520 533 If atom = 0 Then 521 Dim buf[1023] As Byte522 wsprintf(buf, Ex"Control: RegisterClasseEx failed. Error code: &h%08X\r\n", GetLastError())534 Dim buf[1023] As TCHAR 535 wsprintf(buf, ToTCStr(Ex"Control: RegisterClasseEx failed. Error code: &h%08X\r\n"), GetLastError()) 523 536 OutputDebugString(buf) 524 537 Debug … … 543 556 ' Windowsから呼ばれるウィンドウプロシージャ。WndProc 544 557 Static Function WndProcFirst(hwnd As HWND, msg As DWord, wp As WPARAM, lp As LPARAM) As LRESULT 545 Dim pThis = Control.FromHandle(hwnd) As *Control 546 If pThis = 0 Then 547 pThis = TlsGetValue(tlsIndex) 558 Dim rThis = Control.FromHandle(hwnd) As Control 559 If Object.ReferenceEquals(rThis As Object, Nothing) Then 560 Dim gchValue = TlsGetValue(tlsIndex) As LONG_PTR 561 Dim gch = GCHandle.FromIntPtr(gchValue) 562 rThis = gch.Target As Control 548 563 ' ウィンドウが作られて最初にWndProcFirstが呼ばれたとき 549 TlsSetValue(tlsIndex, 0) 550 If pThis = 0 Then 564 If Object.ReferenceEquals(rThis, Nothing) Then 551 565 ' あってはならない事態 552 566 Debug … … 554 568 End If 555 569 ' Debug 556 pThis->wnd = hwnd557 SetWindowLongPtr(hwnd, GWLP_THIS, pThis As LONG_PTR)570 rThis.wnd = New WindowHandle(hwnd) 571 SetWindowLongPtr(hwnd, GWLP_THIS, gchValue) 558 572 End If 559 573 Dim m As Message 560 574 m = Message.Create(hwnd, msg, wp, lp) 561 pThis->WndProc(m)575 rThis.WndProc(m) 562 576 Return m.Result 563 577 End Function 564 578 565 579 ' BeginInvokeが呼ばれたときの処理 566 Sub OnControlBeginInvoke( ByRefm As Message)567 Dim data As *AsyncInvokeData568 data = m.LParam As *AsyncInvokeData569 Dim asyncResult As *AsyncResultForInvoke570 asyncResult->Result = data->FuncPtr(data->Data)571 Dim wh = asyncResult->AsyncWaitHandle572 SetEvent(wh->Handle)573 Delete data580 Sub OnControlBeginInvoke(m As Message) 581 Dim gch = GCHandle.FromIntPtr(m.LParam) 582 Dim data = gch.Target As AsyncInvokeData 583 With data 584 Dim pfn = .FuncPtr 585 .AsyncResult.Result = pfn(.Data) 586 SetEvent(.AsyncResult.AsyncWaitHandle.Handle) 587 End With 574 588 End Sub 575 589 End Class -
Include/Classes/System/Windows/Forms/Message.ab
r77 r223 4 4 #define __SYSTEM_WINDOWS_FORMS_MESSAGE_AB__ 5 5 6 #require <windows.sbp> 7 6 8 Class Message 7 9 Public 8 Sub Operator =(ByRef x As Message) 9 hwnd = x.hwnd 10 msg = x.msg 11 wp = x.wp 12 lp = x.lp 13 lr = x.lr 14 End Sub 15 16 /*Const*/ Function HWnd() As HWND 10 Const Function HWnd() As HWND 17 11 Return hwnd 18 12 End Function … … 22 16 End Sub 23 17 24 /*Const*/Function Msg() As DWord18 Const Function Msg() As DWord 25 19 Return msg 26 20 End Function … … 30 24 End Sub 31 25 32 /*Const*/Function WParam() As WPARAM26 Const Function WParam() As WPARAM 33 27 Return wp 34 28 End Function … … 38 32 End Sub 39 33 40 /*Const*/Function LParam() As LPARAM34 Const Function LParam() As LPARAM 41 35 Return lp 42 36 End Function … … 46 40 End Sub 47 41 48 /*Const*/Function Result() As LRESULT42 Const Function Result() As LRESULT 49 43 Return lr 50 44 End Function … … 54 48 End Sub 55 49 56 /*Const*/ Function Equals(x As Message) As B OOL50 /*Const*/ Function Equals(x As Message) As Boolean 57 51 Return hwnd = x.hwnd And _ 58 52 msg = x.msg And _ … … 62 56 End Function 63 57 64 /*Const*/ Function Operator ==(x As Message) As BOOL 58 Override Function GetHashCode() As Long 59 Return _System_HashFromPtr(hwnd) Xor (Not msg) Xor _System_HashFromPtr(wp As VoidPtr) Xor _ 60 (Not _System_HashFromPtr(lp As VoidPtr)) Xor _System_HashFromPtr(lr As VoidPtr) 61 End Function 62 63 Const Function Operator ==(x As Message) As BOOL 65 64 Return Equals(x) 66 65 End Function 67 66 68 /*Const*/Function Operator <>(x As Message) As BOOL67 Const Function Operator <>(x As Message) As BOOL 69 68 Return Not Equals(x) 70 69 End Function -
Include/Classes/System/Windows/Forms/PaintEventArgs.ab
r77 r223 4 4 #define __SYSTEM_WINDOWS_FORMS_PAINTEVENTARGS_AB__ 5 5 6 # include <Classes/System/misc.ab>6 #require <Classes/System/misc.ab> 7 7 8 8 Class PaintEventArgs -
Include/Classes/System/Windows/Forms/index.ab
r77 r223 4 4 #define __SYSTEM_WINDOWS_FORMS_INDEX_AB__ 5 5 6 #include <Classes/System/Windows/Forms/misc.ab> 7 #include <Classes/System/Windows/Forms/Control.ab> 8 #include <Classes/System/Windows/Forms/Message.ab> 9 #include <Classes/System/Windows/Forms/CreateParams.ab> 10 #include <Classes/System/Windows/Forms/EventArgs.ab> 11 #include <Classes/System/Windows/Forms/PaintEventArgs.ab> 6 #require <Classes/System/Windows/Forms/misc.ab> 7 #require <Classes/System/Windows/Forms/Control.ab> 8 #require <Classes/System/Windows/Forms/Message.ab> 9 #require <Classes/System/Windows/Forms/CreateParams.ab> 10 #require <Classes/System/Windows/Forms/PaintEventArgs.ab> 12 11 13 12 #endif '__SYSTEM_WINDOWS_FORMS_INDEX_AB__ -
Include/Classes/System/Windows/Forms/misc.ab
r77 r223 9 9 10 10 Enum BoundsSpecified 11 None = 011 None = &h0 12 12 X = &h1 13 13 Y = &h2 -
Include/Classes/System/misc.ab
r77 r223 4 4 #define __SYSTEM_MISC_AB__ 5 5 6 # include <Classes/System/Threading/WaitHandle.ab>6 #require <Classes/System/Threading/WaitHandle.ab> 7 7 8 8 Interface IObject … … 28 28 29 29 Class EventArgs 30 Public 31 Static Empty = New EventArgs 30 32 End Class 31 33
Note:
See TracChangeset
for help on using the changeset viewer.