Changeset 388 for trunk/Include/Classes/System/Windows/Forms/Control.ab
- Timestamp:
- Nov 25, 2007, 4:31:35 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/Windows/Forms/Control.ab
r381 r388 4 4 #define __SYSTEM_WINDOWS_FORMS_CONTROL_AB__ 5 5 6 /* 6 7 #require <Classes/System/Windows/Forms/misc.ab> 7 8 #require <Classes/System/Windows/Forms/CreateParams.ab> … … 11 12 #require <Classes/System/Math.ab> 12 13 #require <Classes/System/Threading/WaitHandle.ab> 14 */ 13 15 #require <Classes/System/Drawing/Color.ab> 14 16 #require <Classes/System/Drawing/Point.ab> 15 17 #require <Classes/System/Drawing/Size.ab> 16 18 #require <Classes/System/Drawing/Rectangle.ab> 19 /* 17 20 #require <Classes/System/Runtime/InteropServices/GCHandle.ab> 18 21 #require <Classes/ActiveBasic/Windows/WindowHandle.sbp> 19 22 #require <Classes/ActiveBasic/Strings/Strings.ab> 20 23 */ 21 24 Namespace System 22 25 Namespace Windows … … 143 146 End If 144 147 End Function 145 148 /* BoundsSpecifiedが使用不能なのでコメントアウト 146 149 Sub Bounds(r As Rectangle) 147 150 SetBoundsCore(r.X, r.Y, r.Width, r.Height, BoundsSpecified.All) 148 151 End Sub 149 152 */ 150 153 Const Function Location() As Point 151 154 Return Bounds.Location 152 155 End Function 153 156 /* 154 157 Sub Location(p As Point) 155 158 SetBoundsCore(p.X, p.Y, 0, 0, BoundsSpecified.Location) 156 159 End Sub 157 160 */ 158 161 Const Function Size() As Size 159 162 Return Bounds.Size 160 163 End Function 161 164 /* 162 165 Sub Size(s As Size) 163 166 SetBoundsCore(0, 0, s.Width, s.Height, BoundsSpecified.Size) … … 171 174 Return ClientRectangle.Size 172 175 End Function 173 176 */ 174 177 Const Function Left() As Long 175 178 Dim b = Bounds 176 179 Return b.Left 177 180 End Function 178 181 /* 179 182 Sub Left(l As Long) 180 183 SetBoundsCore(l, 0, 0, 0, BoundsSpecified.X) 181 184 End Sub 182 185 */ 183 186 Const Function Top() As Long 184 187 Dim b = Bounds 185 188 Return b.Top 186 189 End Function 187 190 /* 188 191 Sub Top(t As Long) 189 192 SetBoundsCore(0, t, 0, 0, BoundsSpecified.Y) 190 193 End Sub 191 194 */ 192 195 Const Function Width() As Long 193 196 Dim b = Bounds 194 197 Return b.Width 195 198 End Function 196 199 /* 197 200 Sub Width(w As Long) 198 201 SetBoundsCore(0, 0, w, 0, BoundsSpecified.Width) 199 202 End Sub 200 203 */ 201 204 Const Function Height() As Long 202 205 Dim b = Bounds 203 206 Return b.Height 204 207 End Function 205 208 /* 206 209 Sub Height(h As Long) 207 210 SetBoundsCore(0, 0, 0, h, BoundsSpecified.Height) 208 211 End Sub 209 212 */ 210 213 Const Function Right() As Long 211 214 Dim b = Bounds … … 273 276 274 277 Sub Control() 275 Debug276 278 Dim sz = DefaultSize() 277 Control("", 100, 100, sz.Width, sz.Height)279 init(Nothing, "", 100, 100, sz.Width, sz.Height) 278 280 End Sub 279 281 280 282 Sub Control(text As String) 281 283 Dim sz = DefaultSize() 282 Control(text, 100, 100, sz.Width, sz.Height)284 init(Nothing, text, 100, 100, sz.Width, sz.Height) 283 285 End Sub 284 286 285 287 Sub Control(parent As Control, text As String) 286 288 Dim sz = DefaultSize() 287 Control(parent, text, 100, 100, sz.Width, sz.Height)289 init(parent, text, 100, 100, sz.Width, sz.Height) 288 290 End Sub 289 291 290 292 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) 293 294 End Sub 294 295 295 296 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 300 Private 301 302 Sub init(parent As Control, text As String, left As Long, top As Long, width As Long, height As Long) 296 303 This.parent = parent 297 Control(text, left, top, width, height) 298 End Sub 304 ' CreateControl() 305 End Sub 306 299 307 300 308 '--------------------------------------------------------------------------- 301 309 ' Destractor 302 310 Public 303 311 Virtual Sub ~Control() 304 312 If Not Object.ReferenceEquals(wnd, Nothing) Then … … 398 406 399 407 Virtual Function DefaultSize() As Size 400 Dim s As Size(300, 300) 401 Return s 408 Return New Size(300, 300) 402 409 End Function 403 410 … … 411 418 ' Protected Methods 412 419 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 413 427 Dim createParams = CreateParams() 414 428 Dim gch = System.Runtime.InteropServices.GCHandle.Alloc(This) 415 429 TlsSetValue(tlsIndex, System.Runtime.InteropServices.GCHandle.ToIntPtr(gch) As VoidPtr) 416 430 With createParams 417 Dim hwndParent = 0 As HWND418 If Not Object.ReferenceEquals(parent, Nothing) Then419 hwndParent = parent.Handle420 End If421 431 Dim pText As PCTSTR 422 432 If String.IsNullOrEmpty(text) Then … … 427 437 428 438 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 Then439 .X, .Y, .Width, .Height, _ 440 .Parent, 0, hInstance, 0) = 0 Then 431 441 ' Error 432 442 Dim buf[1023] As TCHAR 433 443 wsprintf(buf, ToTCStr(Ex"Control: CreateWindowEx failed. Error code: &h%08X\r\n"), GetLastError()) 434 444 OutputDebugString(buf) 445 446 gch.Free() 435 447 ' Debug 436 448 ExitThread(0) 437 449 End If 438 450 End With 439 gch.Free()451 440 452 End Sub 441 453 … … 475 487 Case WM_DESTROY 476 488 OnHandleDestroyed(System.EventArgs.Empty) 489 490 Case WM_LBUTTONDOWN 491 Goto *ButtonDown 492 *ButtonDown 477 493 Case Else 478 494 DefWndProc(m) … … 521 537 End Sub 522 538 523 Virtual Sub OnPaintBackground(e As PaintEventArgs) : End Sub539 ' Virtual Sub OnPaintBackground(e As PaintEventArgs) : End Sub 524 540 Virtual Sub OnEnabledChanged(e As System.EventArgs) : End Sub 525 541 Virtual Sub OnBackColorChanged(e As System.EventArgs) : End Sub … … 582 598 .Style = WS_OVERLAPPEDWINDOW 583 599 .ExStyle = WS_EX_APPWINDOW 600 .Caption = String.Empty 601 .X = 0 602 .Y = 0 603 .Width = 0 604 .Height = 0 584 605 End With 585 606 End Sub … … 608 629 rThis.wnd = New ActiveBasic.Windows.WindowHandle(hwnd) 609 630 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() 610 634 End If 611 635
Note:
See TracChangeset
for help on using the changeset viewer.