Changeset 461 for trunk/Include/Classes/System/Windows
- Timestamp:
- Mar 8, 2008, 12:40:31 PM (17 years ago)
- Location:
- trunk/Include/Classes/System/Windows/Forms
- Files:
-
- 5 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/Windows/Forms/Application.ab
r388 r461 31 31 PostQuitMessage(0) 32 32 End Sub 33 34 /*! 35 @brief 現在のスレッドで標準のアプリケーション メッセージ ループの実行を開始し、 36 指定したフォームを表示します。 37 */ 38 Static Sub Run( form As Form ) 39 40 ' フォームを表示する 41 form.Show() 42 43 Dim msgMain As MSG, iResult As Long 44 Do 45 iResult=GetMessage(msgMain,0,0,0) 46 If iResult=0 or iResult=-1 Then Exit Do 47 TranslateMessage(msgMain) 48 DispatchMessage(msgMain) 49 Loop 50 End Sub 33 51 End Class 34 52 -
trunk/Include/Classes/System/Windows/Forms/Control.ab
r388 r461 1 1 ' Classes/System/Windows/Forms/Control.ab 2 2 3 #ifndef __SYSTEM_WINDOWS_FORMS_CONTROL_AB__4 #define __SYSTEM_WINDOWS_FORMS_CONTROL_AB__5 6 /*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 */15 #require <Classes/System/Drawing/Color.ab>16 #require <Classes/System/Drawing/Point.ab>17 #require <Classes/System/Drawing/Size.ab>18 #require <Classes/System/Drawing/Rectangle.ab>19 /*20 #require <Classes/System/Runtime/InteropServices/GCHandle.ab>21 #require <Classes/ActiveBasic/Windows/WindowHandle.sbp>22 #require <Classes/ActiveBasic/Strings/Strings.ab>23 */24 3 Namespace System 25 4 Namespace Windows … … 77 56 78 57 Class Control 79 80 ' Inherits IWin32Window 58 Implements IWin32Window 81 59 Public 82 60 '--------------------------------------------------------------------------- … … 100 78 'CheckForIllegalCrossThreadCalls 101 79 102 /*Override*/Function Handle() As HWND80 Override Function Handle() As HWND 103 81 Return wnd.HWnd 104 82 End Function … … 301 279 302 280 Sub init(parent As Control, text As String, left As Long, top As Long, width As Long, height As Long) 281 This.text = text 303 282 This.parent = parent 304 ' CreateControl() 283 284 Dim rgb = GetSysColor( COLOR_HIGHLIGHT ) 285 This.bkColor = New Color( GetRValue(rgb) As Byte, GetGValue(rgb) As Byte, GetBValue(rgb) As Byte ) 286 287 Dim hParentWnd = NULL As HWND 288 If Not ActiveBasic.IsNothing( parent ) Then 289 hParentWnd = parent.Handle 290 End If 291 292 createParams = New CreateParams() 293 With createParams 294 .Caption = text 295 .X = left 296 .Y = top 297 .Width = width 298 .Height = height 299 .Parent = hParentWnd 300 End With 301 302 CreateControl() 305 303 End Sub 306 304 … … 358 356 If IsWindow(hwnd) Then 359 357 If GetClassLongPtr(hwnd, GCW_ATOM) = atom Then 360 Dim gch = System.Runtime.InteropServices.GCHandle.FromIntPtr(GetWindowLongPtr(hwnd, GWLP_THIS)) 361 Return gch.Target As Control 358 Dim lpValue = GetWindowLongPtr(hwnd, GWLP_THIS) 359 If lpValue Then 360 Dim gch = System.Runtime.InteropServices.GCHandle.FromIntPtr( lpValue ) 361 Return gch.Target As Control 362 End If 362 363 End If 363 364 End If … … 370 371 371 372 Override Function ToString() As String 372 Return text373 Return Super.ToString + ", Text: " + This.Text 373 374 End Function 374 375 … … 383 384 384 385 Sub Show() 385 Debug386 386 wnd.Show(SW_SHOW) 387 387 End Sub … … 418 418 ' Protected Methods 419 419 Virtual Sub CreateHandle() 420 Debug421 420 If Not Object.ReferenceEquals(wnd, Nothing) Then 422 421 If wnd.HWnd <> 0 Then … … 424 423 End If 425 424 End If 426 427 Dim createParams = CreateParams() 425 428 426 Dim gch = System.Runtime.InteropServices.GCHandle.Alloc(This) 429 427 TlsSetValue(tlsIndex, System.Runtime.InteropServices.GCHandle.ToIntPtr(gch) As VoidPtr) 430 With createParams 431 Dim pText As PCTSTR 432 If String.IsNullOrEmpty(text) Then 433 pText = "" As PCTSTR 434 Else 435 pText = ToTCStr(text) 436 End If 437 438 If CreateWindowEx(.ExStyle, atom As ULONG_PTR As PCSTR, pText, .Style, _ 439 .X, .Y, .Width, .Height, _ 440 .Parent, 0, hInstance, 0) = 0 Then 441 ' Error 442 Dim buf[1023] As TCHAR 443 wsprintf(buf, ToTCStr(Ex"Control: CreateWindowEx failed. Error code: &h%08X\r\n"), GetLastError()) 444 OutputDebugString(buf) 445 446 gch.Free() 428 429 Dim pText As PCTSTR 430 If String.IsNullOrEmpty(text) Then 431 pText = "" As PCTSTR 432 Else 433 pText = ToTCStr(text) 434 End If 435 436 Dim result As HANDLE 437 With This.CreateParams 438 result = CreateWindowEx( 439 .ExStyle, ' 拡張ウィンドウ スタイル 440 atom As ULONG_PTR As PCSTR, ' クラス名 441 pText, ' キャプション 442 .Style, ' ウィンドウ スタイル 443 .X, ' X座標 444 .Y, ' Y座標 445 .Width, ' 幅 446 .Height, ' 高さ 447 .Parent, ' 親ウィンドウ ハンドル 448 0, ' メニュー ハンドル 449 hInstance, ' アプリケーション インスタンス ハンドル 450 0) ' ウィンドウ作成データ 451 End With 452 453 If result = NULL Then 454 ' Error 455 Dim buf[1023] As TCHAR 456 wsprintf(buf, ToTCStr(Ex"Control: CreateWindowEx failed. Error code: &h%08X\r\n"), GetLastError()) 457 OutputDebugString(buf) 458 459 gch.Free() 447 460 ' Debug 448 ExitThread(0) 449 End If 450 End With 461 ExitThread(0) 462 End If 451 463 452 464 End Sub … … 549 561 ' Member variables 550 562 wnd As ActiveBasic.Windows.WindowHandle 563 createParams As CreateParams 551 564 text As String 552 565 parent As Control 553 566 bkColor As Color 554 555 Static createParams As CreateParams556 567 557 568 'ウィンドウ作成時にウィンドウプロシージャへThisを伝えるためのもの … … 593 604 ExitThread(0) 594 605 End If 595 596 With createParams597 ' 値は暫定的なもの598 .Style = WS_OVERLAPPEDWINDOW599 .ExStyle = WS_EX_APPWINDOW600 .Caption = String.Empty601 .X = 0602 .Y = 0603 .Width = 0604 .Height = 0605 End With606 606 End Sub 607 607 … … 672 672 End Namespace 'Widnows 673 673 End Namespace 'System 674 675 #endif '__SYSTEM_WINDOWS_FORMS_CONTROL_AB__676 -
trunk/Include/Classes/System/Windows/Forms/CreateParams.ab
r282 r461 1 ' Classes/System/Windows/Forms/CreateParams.ab2 3 #ifndef __SYSTEM_WINDOWS_FORMS_CREATEPARAMS_AB__4 #define __SYSTEM_WINDOWS_FORMS_CREATEPARAMS_AB__5 1 6 2 Namespace System … … 26 22 End Namespace 'Widnows 27 23 End Namespace 'System 28 29 #endif '__SYSTEM_WINDOWS_FORMS_CREATEPARAMS_AB__ -
trunk/Include/Classes/System/Windows/Forms/misc.ab
r388 r461 222 222 */ 223 223 224 TypeDef DialogResult = DWord225 224 TypeDef MouseButtons = DWord 226 225
Note:
See TracChangeset
for help on using the changeset viewer.