Changeset 679 for trunk


Ignore:
Timestamp:
Jan 26, 2009, 1:53:37 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

UI.TimerをWM_TIMER使用に修正。Step32時計のサンプルを追加。

Location:
trunk/ab5.0/ablib
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Control.ab

    r674 r679  
    11'Classes/ActiveBasic/Windows/UI/Control.ab
    22
     3#require <Classes/ActiveBasic/Windows/UI/WindowHandle.ab>
    34#require <Classes/ActiveBasic/Windows/UI/EventArgs.ab>
    45#require <Classes/ActiveBasic/COM/ComClassBase.ab>
  • trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/Timer.ab

    r677 r679  
     1
     2#require <Classes/ActiveBasic/Windows/UI/Control.ab>
    13/*
    24@brief タイマ
     
    1012Public
    1113    'Timer クラスの新しいインスタンスを初期化します。
    12     Sub Timer()
    13         Dim tc As TIMECAPS
    14         timeGetDevCaps(tc,SizeOf(TIMECAPS))
    15         If 50 < tc.wPeriodMin Then
    16             '今の時代にこんなPCはほとんどないだろうけど念のため
    17             This.resolution = tc.wPeriodMin
    18         Else
    19             'Froms.Timerの精度は55msec前後
    20             This.resolution = 50
    21         End If
     14    Sub Timer(control As Control)
     15        If IsNothing(control) Then
     16            Throw New System.ArgumentNullException("control")
     17        EndIf
     18        ctrl = control
    2219    End Sub
    2320
     
    2522    Sub Enabled(value As Boolean)
    2623        If value Then
    27             If This.id=0 Then This.Start()
     24            If This.handle=0 Then This.Start()
    2825        Else
    29             If This.id Then This.Stop()
     26            If This.handle Then This.Stop()
    3027        End If
    3128    End Sub
    3229    Function Enabled() As Boolean
    33         Return This.enabled
     30        Return handle <> 0
    3431    End Function
    3532
     
    5249    'オーバーロードされます。
    5350    Sub Dispose()
    54         This.Stop()
     51        killImpl()
    5552    End Sub
    5653
    5754    'タイマを起動します。
    5855    Sub Start()
    59         This.id = timeSetEvent(This.interval,This.resolution,AddressOf(Detail.TimerProc_Impl),ObjPtr(This) As ULONG_PTR,TIME_PERIODIC or TIME_CALLBACK_FUNCTION)
    60         If This.id Then This.enabled = True Else This.enabled = False
     56        If handle = 0 Then
     57            handle = AllocObjectHandle(This)
     58            If SetTimer(ctrl As HWND, handle, interval, AddressOf(timerProc)) = 0 Then
     59                ThrowWithLastError()
     60            End If
     61        End If
    6162    End Sub
    6263
    6364    'タイマを停止します。
    6465    Sub Stop()
    65         timeKillEvent(This.id)
    66         This.id = 0
    67         This.enabled = False
     66        If killImpl() = 0 Then
     67            ThrowWithLastError()
     68        End If
    6869    End Sub
    6970
     
    8081    End Sub
    8182
    82 Protected
    83     id As ULONG_PTR
    84     interval As Long
    85     resolution As DWord
    86     enabled As Boolean
    87     tag As Object
    88 
    8983Public
    9084    Sub AddTick(h As System.EventHandler)
     
    10094        End If
    10195    End Sub
     96Private
     97    Static Sub timerProc(hwnd As HWND, msg As DWord, id As ULONG_PTR, time As DWord)
     98        Dim timer = GetObjectFromHandle(id) As Timer
     99        timer.OnTick(Nothing)
     100    End Sub
     101
     102    Function killImpl() As Boolean
     103        If handle <> 0 Then
     104            killImpl = KillTimer(ctrl As HWND, handle) <> 0
     105            ReleaseObjectHandle(handle)
     106            handle = 0
     107        End If
     108    End Function
    102109
    103110    Tick As System.EventHandler
     111    ctrl As Control
     112    handle As LONG_PTR 'タイマ実行中のGC回避およびタイマIDとして使用
     113    interval As DWord
    104114End Class
    105 
    106 
    107 Namespace Detail
    108     Class Timer_Impl
    109         Inherits Timer
    110 
    111     Public
    112         Sub OnTick()
    113             Super.OnTick(Nothing)
    114         End Sub
    115     End Class
    116 
    117     Sub TimerProc_Impl(uID As DWord, uMsg As DWord, dwUser As DWORD_PTR, dw1 As DWORD_PTR, dw2 As DWORD_PTR)
    118         Dim timer As Timer_Impl
    119         timer = dwUser As Timer_Impl
    120         timer.OnTick()
    121     End Sub
    122 
    123 End Namespace
    124115
    125116End Namespace 'UI
  • trunk/ab5.0/ablib/src/api_gdi.sbp

    r559 r679  
    788788
    789789Declare Function ExtSelectClipRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN, fnMode As Long) As Long
     790Const ETO_OPAQUE = &h0002
     791Const ETO_CLIPPED = &h0004
     792'#if WINVER >= &h0400
     793Const ETO_GLYPH_INDEX = &h0010
     794Const ETO_RTLREADING = &h0080
     795Const ETO_NUMERICSLOCAL = &h0400
     796Const ETO_NUMERICSLATIN = &h0800
     797Const ETO_IGNORELANGUAGE = &h1000
     798'#endif
     799'#if _WIN32_WINNT >= &h0500
     800'Const ETO_PDY = &h2000
     801'#endif
     802'#if _WIN32_WINNT >= &h0600
     803'Const ETO_REVERSE_INDEX_MAP = &h10000
     804'#endif
    790805Declare Function ExtTextOutA Lib "gdi32" (hdc As HDC, x As Long, y As Long, fuOptions As DWord, ByRef rc As RECT, lpString As PCSTR, cbCount As Long, pDx As *Long) As Long
    791806Declare Function ExtTextOutW Lib "gdi32" (hdc As HDC, x As Long, y As Long, fuOptions As DWord, ByRef rc As RECT, lpString As PCWSTR, cbCount As Long, pDx As *Long) As Long
Note: See TracChangeset for help on using the changeset viewer.