mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 12:20:38 +02:00
+ WinApi: added SetTimer/Killtimer based on existing Widgetset.CreateTimer as part of lclextentions integration
git-svn-id: trunk@23417 -
This commit is contained in:
parent
a6d1c188e0
commit
20448170ae
@ -1272,6 +1272,41 @@ begin
|
|||||||
Result := (Right <= Left) or (Bottom <= Top);
|
Result := (Right <= Left) or (Bottom <= Top);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: KillTimer
|
||||||
|
Params: hWnd:
|
||||||
|
uIDEvent:
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function KillTimer(Wnd: HWND; uIDEvent: UINT_PTR): BOOL;
|
||||||
|
var
|
||||||
|
MapID: record
|
||||||
|
case Boolean of
|
||||||
|
True: (nIDEvent: UINT_PTR; Wnd: HWND);
|
||||||
|
False: (filler: array[1..2] of Pointer);
|
||||||
|
end;
|
||||||
|
ID: Cardinal;
|
||||||
|
InfoPtr: PTimerInfo;
|
||||||
|
begin
|
||||||
|
if MTimerMap = nil then Exit(False);
|
||||||
|
if MTimerInfo = nil then Exit(False);
|
||||||
|
|
||||||
|
// make sure all is zero
|
||||||
|
FillByte(MapID, SizeOf(MapID), 0);
|
||||||
|
MapID.Wnd := Wnd;
|
||||||
|
MapID.nIDEvent := uIdEvent;
|
||||||
|
|
||||||
|
if not MTimerMap.GetData(MapID, ID) then Exit(False);
|
||||||
|
|
||||||
|
InfoPtr := MTimerInfo.GetDataPtr(ID);
|
||||||
|
if InfoPtr = nil then Exit(False);
|
||||||
|
|
||||||
|
Result := Widgetset.DestroyTimer(InfoPtr^.Handle);
|
||||||
|
MTimerInfo.Delete(ID);
|
||||||
|
MTimerMap.Delete(MapID);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: MakeLParam
|
Function: MakeLParam
|
||||||
Params:
|
Params:
|
||||||
@ -1450,6 +1485,76 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: SetTimer
|
||||||
|
Params: hWnd:
|
||||||
|
nIDEvent:
|
||||||
|
uElapse:
|
||||||
|
lpTimerFunc:
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function SetTimer(Wnd: HWND; nIDEvent: UINT_PTR; uElapse: UINT; lpTimerFunc: TTimerProc): UINT_PTR;
|
||||||
|
var
|
||||||
|
MapID: record
|
||||||
|
case Boolean of
|
||||||
|
True: (nIDEvent: UINT_PTR; Wnd: HWND);
|
||||||
|
False: (filler: array[1..2] of Pointer);
|
||||||
|
end;
|
||||||
|
ID: Cardinal;
|
||||||
|
Info: TTimerInfo;
|
||||||
|
InfoPtr: PTimerInfo;
|
||||||
|
Existing: Boolean;
|
||||||
|
begin
|
||||||
|
if MTimerMap = nil
|
||||||
|
then MTimerMap := TMap.Create({$ifdef CPU32}itu8{$else}itu16{$endif}, SizeOf(Cardinal));
|
||||||
|
if MTimerInfo = nil
|
||||||
|
then MTimerInfo := TMap.Create(itu4, SizeOf(TTimerInfo));
|
||||||
|
|
||||||
|
// make sure all is zero
|
||||||
|
FillByte(MapID, SizeOf(MapID), 0);
|
||||||
|
MapID.Wnd := Wnd;
|
||||||
|
MapID.nIDEvent := nIdEvent;
|
||||||
|
|
||||||
|
Existing := MTimerMap.GetData(MapID, ID);
|
||||||
|
if Existing
|
||||||
|
then begin
|
||||||
|
InfoPtr := MTimerInfo.GetDataPtr(ID);
|
||||||
|
if InfoPtr = nil
|
||||||
|
then Existing := False
|
||||||
|
else Widgetset.DestroyTimer(InfoPtr^.Handle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not Existing
|
||||||
|
then begin
|
||||||
|
// new id
|
||||||
|
Inc(MTimerSeq);
|
||||||
|
ID := MTimerSeq;
|
||||||
|
Info.Wnd := Wnd;
|
||||||
|
// for null windows we create an ID else the ID passed is used
|
||||||
|
if Wnd = 0
|
||||||
|
then Info.IDEvent := ID
|
||||||
|
else Info.IDEvent := nIdEvent;
|
||||||
|
MapID.nIDEvent := Info.IDEvent;
|
||||||
|
MTimerMap.Add(MapID, ID);
|
||||||
|
InfoPtr := @Info;
|
||||||
|
end;
|
||||||
|
|
||||||
|
InfoPtr^.TimerProc := lpTimerFunc;
|
||||||
|
InfoPtr^.Handle := WidgetSet.CreateTimer(uElapse, @TTimerID(PtrUInt(ID)).TimerNotify);
|
||||||
|
|
||||||
|
if not Existing
|
||||||
|
then MTimerInfo.Add(ID, Info); // add after all data is set
|
||||||
|
|
||||||
|
if InfoPtr^.Handle <> 0
|
||||||
|
then Exit(ID); // success
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
MTimerInfo.Delete(ID);
|
||||||
|
MTimerMap.Delete(MapID);
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function:
|
Function:
|
||||||
Params:
|
Params:
|
||||||
|
@ -174,6 +174,8 @@ function IsWindowEnabled(handle: HWND): boolean; {$IFDEF IF_BASE_MEMBER}virtual;
|
|||||||
function IsWindowVisible(handle: HWND): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function IsWindowVisible(handle: HWND): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function IsZoomed(handle: HWND): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function IsZoomed(handle: HWND): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
|
|
||||||
|
//function KillTimer --> independent
|
||||||
|
|
||||||
procedure LeaveCriticalSection(var CritSection: TCriticalSection); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
procedure LeaveCriticalSection(var CritSection: TCriticalSection); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function LineTo(DC: HDC; X, Y: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function LineTo(DC: HDC; X, Y: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
|
|
||||||
@ -237,6 +239,7 @@ function SetStretchBltMode(DC: HDC; StretchMode: Integer): Integer; {$IFDEF IF_B
|
|||||||
function SetSysColors(cElements: Integer; const lpaElements; const lpaRgbValues): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function SetSysColors(cElements: Integer; const lpaElements; const lpaRgbValues): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function SetTextCharacterExtra(_hdc : hdc; nCharExtra : Integer):Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function SetTextCharacterExtra(_hdc : hdc; nCharExtra : Integer):Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function SetTextColor(DC: HDC; Color: TColorRef): TColorRef; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function SetTextColor(DC: HDC; Color: TColorRef): TColorRef; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
|
//function SetTimer --> independent
|
||||||
function SetWindowLong(Handle: HWND; Idx: Integer; NewLong : PtrInt): PtrInt;{$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function SetWindowLong(Handle: HWND; Idx: Integer; NewLong : PtrInt): PtrInt;{$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function SetViewPortExtEx(DC: HDC; XExtent, YExtent : Integer; OldSize: PSize): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function SetViewPortExtEx(DC: HDC; XExtent, YExtent : Integer; OldSize: PSize): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
function SetViewPortOrgEx(DC: HDC; NewX, NewY: Integer; OldPoint: PPoint): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
function SetViewPortOrgEx(DC: HDC; NewX, NewY: Integer; OldPoint: PPoint): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||||
@ -298,6 +301,8 @@ function IntersectRect(var DestRect: TRect; const SrcRect1, SrcRect2: TRect): Bo
|
|||||||
function IsCharAlphaNumeric(c : Char) : Boolean;
|
function IsCharAlphaNumeric(c : Char) : Boolean;
|
||||||
function IsRectEmpty(const ARect: TRect): Boolean;
|
function IsRectEmpty(const ARect: TRect): Boolean;
|
||||||
|
|
||||||
|
function KillTimer(Wnd: HWND; uIDEvent: UINT_PTR): BOOL;
|
||||||
|
|
||||||
function MakeWParam(l, h: Word): WPARAM; inline;
|
function MakeWParam(l, h: Word): WPARAM; inline;
|
||||||
function MakeLParam(l, h: Word): LPARAM; inline;
|
function MakeLParam(l, h: Word): LPARAM; inline;
|
||||||
function MakeLResult(l, h: Word): LRESULT; inline;
|
function MakeLResult(l, h: Word): LRESULT; inline;
|
||||||
@ -310,10 +315,11 @@ function PointToSmallPoint(const P : TPoint) : TSmallPoint; inline;
|
|||||||
function RGB(R, G, B : Byte) : TColorRef; inline;
|
function RGB(R, G, B : Byte) : TColorRef; inline;
|
||||||
|
|
||||||
function ScrollWindow(hWnd: HWND; XAmount, YAmount: Integer; Rect, ClipRect: PRect): Boolean; inline;
|
function ScrollWindow(hWnd: HWND; XAmount, YAmount: Integer; Rect, ClipRect: PRect): Boolean; inline;
|
||||||
function SetRect(Var ARect : TRect; xLeft,yTop,xRight,yBottom : Integer) : Boolean;
|
function SetRect(var ARect : TRect; xLeft,yTop,xRight,yBottom : Integer) : Boolean;
|
||||||
function SetRectEmpty(var ARect: TRect): Boolean;
|
function SetRectEmpty(var ARect: TRect): Boolean;
|
||||||
function SetScrollPos(Handle: HWND; nBar, nPos: Integer; bRedraw: Boolean): Integer;
|
function SetScrollPos(Handle: HWND; nBar, nPos: Integer; bRedraw: Boolean): Integer;
|
||||||
function SetScrollRange(Handle: HWND; nBar, nMinPos, nMaxPos: Integer; bRedraw: Boolean): Boolean;
|
function SetScrollRange(Handle: HWND; nBar, nMinPos, nMaxPos: Integer; bRedraw: Boolean): Boolean;
|
||||||
|
function SetTimer(Wnd: HWND; nIDEvent: UINT_PTR; uElapse: UINT; lpTimerFunc: TTimerProc): UINT_PTR;
|
||||||
function SmallPointToPoint(const P : TSmallPoint) : Tpoint;
|
function SmallPointToPoint(const P : TSmallPoint) : Tpoint;
|
||||||
|
|
||||||
function UnionRect(var DestRect: TRect; const SrcRect1, SrcRect2: TRect): Boolean; //pbd
|
function UnionRect(var DestRect: TRect; const SrcRect1, SrcRect2: TRect): Boolean; //pbd
|
||||||
|
@ -79,6 +79,9 @@ type
|
|||||||
lcDragDockStartOnTitleClick // ability to start drag/dock events on title bar click
|
lcDragDockStartOnTitleClick // ability to start drag/dock events on title bar click
|
||||||
);
|
);
|
||||||
|
|
||||||
|
type
|
||||||
|
TWSTimerProc = procedure of object;
|
||||||
|
|
||||||
{ TWidgetSet }
|
{ TWidgetSet }
|
||||||
|
|
||||||
TWidgetSet = class(TObject)
|
TWidgetSet = class(TObject)
|
||||||
@ -117,7 +120,7 @@ type
|
|||||||
function IsHelpKey(Key: Word; Shift: TShiftState): Boolean; virtual;
|
function IsHelpKey(Key: Word; Shift: TShiftState): Boolean; virtual;
|
||||||
|
|
||||||
// create and destroy
|
// create and destroy
|
||||||
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle; virtual; abstract;
|
function CreateTimer(Interval: integer; TimerProc: TWSTimerProc): THandle; virtual; abstract;
|
||||||
function DestroyTimer(TimerHandle: THandle): boolean; virtual; abstract;
|
function DestroyTimer(TimerHandle: THandle): boolean; virtual; abstract;
|
||||||
function AppHandle: Thandle; virtual;
|
function AppHandle: Thandle; virtual;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ type
|
|||||||
function IsHelpKey(Key: Word; Shift: TShiftState): Boolean; override;
|
function IsHelpKey(Key: Word; Shift: TShiftState): Boolean; override;
|
||||||
|
|
||||||
// create and destroy
|
// create and destroy
|
||||||
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle; override;
|
function CreateTimer(Interval: integer; TimerFunc: TWSTimerProc) : THandle; override;
|
||||||
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
||||||
function PrepareUserEvent(Handle: HWND; Msg: Cardinal; wParam: WParam;
|
function PrepareUserEvent(Handle: HWND; Msg: Cardinal; wParam: WParam;
|
||||||
lParam: LParam; out Target: EventTargetRef): EventRef;
|
lParam: LParam; out Target: EventTargetRef): EventRef;
|
||||||
|
@ -556,7 +556,7 @@ begin
|
|||||||
inherited Create;
|
inherited Create;
|
||||||
FTerminating := False;
|
FTerminating := False;
|
||||||
|
|
||||||
FTimerMap := TMap.Create(its4, SizeOf(TFNTimerProc));
|
FTimerMap := TMap.Create(its4, SizeOf(TWSTimerProc));
|
||||||
FCurrentCursor := 0;
|
FCurrentCursor := 0;
|
||||||
FMainMenu := 0;
|
FMainMenu := 0;
|
||||||
FCaptureWidget := 0;
|
FCaptureWidget := 0;
|
||||||
@ -1217,7 +1217,7 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TimerCallback(inTimer: EventLoopTimerRef; inUserData: UnivPtr);
|
procedure TimerCallback(inTimer: EventLoopTimerRef; inUserData: UnivPtr);
|
||||||
var
|
var
|
||||||
TimerFunc: TFNTimerProc;
|
TimerFunc: TWSTimerProc;
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseTimer}
|
{$IFDEF VerboseTimer}
|
||||||
DebugLn('TimerCallback');
|
DebugLn('TimerCallback');
|
||||||
@ -1242,7 +1242,7 @@ end;
|
|||||||
|
|
||||||
Creates new timer with specified interval and callback function
|
Creates new timer with specified interval and callback function
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonWidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle;
|
function TCarbonWidgetSet.CreateTimer(Interval: integer; TimerFunc: TWSTimerProc): THandle;
|
||||||
var
|
var
|
||||||
Timer: EventLoopTimerRef;
|
Timer: EventLoopTimerRef;
|
||||||
begin
|
begin
|
||||||
|
@ -47,9 +47,9 @@ type
|
|||||||
{ TCocoaTimerObject }
|
{ TCocoaTimerObject }
|
||||||
|
|
||||||
TCocoaTimerObject=objcclass(NSObject)
|
TCocoaTimerObject=objcclass(NSObject)
|
||||||
func : TFNTimerProc;
|
func : TWSTimerProc;
|
||||||
procedure timerEvent; message 'timerEvent';
|
procedure timerEvent; message 'timerEvent';
|
||||||
class function initWithFunc(afunc: TFNTimerProc): TCocoaTimerObject; message 'initWithFunc:';
|
class function initWithFunc(afunc: TWSTimerProc): TCocoaTimerObject; message 'initWithFunc:';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaAppDelegate }
|
{ TCocoaAppDelegate }
|
||||||
@ -84,7 +84,7 @@ type
|
|||||||
procedure AppBringToFront; override;
|
procedure AppBringToFront; override;
|
||||||
procedure AppSetTitle(const ATitle: string); override;
|
procedure AppSetTitle(const ATitle: string); override;
|
||||||
|
|
||||||
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle; override;
|
function CreateTimer(Interval: integer; TimerFunc: TWSTimerProc): THandle; override;
|
||||||
function DestroyTimer(TimerHandle: THandle): boolean; override;
|
function DestroyTimer(TimerHandle: THandle): boolean; override;
|
||||||
function AppHandle: THandle; override;
|
function AppHandle: THandle; override;
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ begin
|
|||||||
NSApp.dockTile.setBadgeLabel(NSStringUtf8(ATitle));
|
NSApp.dockTile.setBadgeLabel(NSStringUtf8(ATitle));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCocoaWidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle;
|
function TCocoaWidgetSet.CreateTimer(Interval: integer; TimerFunc: TWSTimerProc): THandle;
|
||||||
var
|
var
|
||||||
timer : NSTimer;
|
timer : NSTimer;
|
||||||
user : TCocoaTimerObject;
|
user : TCocoaTimerObject;
|
||||||
@ -387,7 +387,7 @@ begin
|
|||||||
if Assigned(@func) then func;
|
if Assigned(@func) then func;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TCocoaTimerObject.initWithFunc(afunc: TFNTimerProc): TCocoaTimerObject;
|
class function TCocoaTimerObject.initWithFunc(afunc: TWSTimerProc): TCocoaTimerObject;
|
||||||
begin
|
begin
|
||||||
Result:=alloc;
|
Result:=alloc;
|
||||||
Result.func:=afunc;
|
Result.func:=afunc;
|
||||||
|
@ -73,7 +73,7 @@ type
|
|||||||
procedure SetDesigning(AComponent: TComponent); override;
|
procedure SetDesigning(AComponent: TComponent); override;
|
||||||
|
|
||||||
// create and destroy
|
// create and destroy
|
||||||
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle; override;
|
function CreateTimer(Interval: integer; TimerFunc: TWSTimerProc): THandle; override;
|
||||||
function DestroyTimer(TimerHandle: THandle): boolean; override;
|
function DestroyTimer(TimerHandle: THandle): boolean; override;
|
||||||
|
|
||||||
// device contexts
|
// device contexts
|
||||||
|
@ -23,11 +23,11 @@ type
|
|||||||
private
|
private
|
||||||
FLCLTimer: TTimer;
|
FLCLTimer: TTimer;
|
||||||
FTimer: TfpgTimer;
|
FTimer: TfpgTimer;
|
||||||
FCallback: TFNTimerProc;
|
FCallback: TWSTimerProc;
|
||||||
protected
|
protected
|
||||||
procedure FPGTimer(Sender: TObject);
|
procedure FPGTimer(Sender: TObject);
|
||||||
public
|
public
|
||||||
constructor Create(AInterval: Integer; ACallbackFunc: TFNTimerProc);
|
constructor Create(AInterval: Integer; ACallbackFunc: TWSTimerProc);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
property Timer : TfpgTimer read FTimer;
|
property Timer : TfpgTimer read FTimer;
|
||||||
@ -41,7 +41,7 @@ begin
|
|||||||
FCallback;
|
FCallback;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TFPGUITimer.Create(AInterval: Integer; ACallbackFunc: TFNTimerProc);
|
constructor TFPGUITimer.Create(AInterval: Integer; ACallbackFunc: TWSTimerProc);
|
||||||
begin
|
begin
|
||||||
FTimer := TfpgTimer.Create(AInterval);
|
FTimer := TfpgTimer.Create(AInterval);
|
||||||
FTimer.OnTimer:=@FPGTimer;
|
FTimer.OnTimer:=@FPGTimer;
|
||||||
@ -91,7 +91,7 @@ end;
|
|||||||
|
|
||||||
Creates a new timer and sets the callback event.
|
Creates a new timer and sets the callback event.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TFpGuiWidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle;
|
function TFpGuiWidgetSet.CreateTimer(Interval: integer; TimerFunc: TWSTimerProc): THandle;
|
||||||
var
|
var
|
||||||
Timer: TFPGUITimer;
|
Timer: TFPGUITimer;
|
||||||
begin
|
begin
|
||||||
|
@ -220,7 +220,7 @@ type
|
|||||||
PGtkITimerInfo = ^TGtkITimerinfo;
|
PGtkITimerInfo = ^TGtkITimerinfo;
|
||||||
TGtkITimerInfo = record
|
TGtkITimerInfo = record
|
||||||
TimerHandle: guint; // the gtk handle for this timer
|
TimerHandle: guint; // the gtk handle for this timer
|
||||||
TimerFunc : TFNTimerProc; // owner function to handle timer
|
TimerFunc : TWSTimerProc; // owner function to handle timer
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
@ -286,7 +286,7 @@ type
|
|||||||
ConvertAmpersandsToUnderScores: Boolean) : PChar;
|
ConvertAmpersandsToUnderScores: Boolean) : PChar;
|
||||||
|
|
||||||
// create and destroy
|
// create and destroy
|
||||||
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle; override;
|
function CreateTimer(Interval: integer; TimerProc: TWSTimerProc) : THandle; override;
|
||||||
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
||||||
procedure DestroyLCLComponent(Sender: TObject);virtual;
|
procedure DestroyLCLComponent(Sender: TObject);virtual;
|
||||||
|
|
||||||
|
@ -1484,17 +1484,17 @@ end;
|
|||||||
Design: A callback to the TTimer class is implemented.
|
Design: A callback to the TTimer class is implemented.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TGtkWidgetSet.CreateTimer(Interval: integer;
|
function TGtkWidgetSet.CreateTimer(Interval: integer;
|
||||||
TimerFunc: TFNTimerProc) : THandle;
|
TimerProc: TWSTimerProc) : THandle;
|
||||||
var
|
var
|
||||||
TimerInfo: PGtkITimerinfo;
|
TimerInfo: PGtkITimerinfo;
|
||||||
begin
|
begin
|
||||||
if ((Interval < 1) or (not Assigned(TimerFunc)))
|
if ((Interval < 1) or (not Assigned(TimerProc)))
|
||||||
then
|
then
|
||||||
Result := 0
|
Result := 0
|
||||||
else begin
|
else begin
|
||||||
New(TimerInfo);
|
New(TimerInfo);
|
||||||
FillByte(TimerInfo^,SizeOf(TGtkITimerinfo),0);
|
FillByte(TimerInfo^,SizeOf(TGtkITimerinfo),0);
|
||||||
TimerInfo^.TimerFunc := TimerFunc;
|
TimerInfo^.TimerFunc := TimerProc;
|
||||||
{$IFDEF VerboseTimer}
|
{$IFDEF VerboseTimer}
|
||||||
DebugLn(['TGtkWidgetSet.CreateTimer Interval=',dbgs(Interval)]);
|
DebugLn(['TGtkWidgetSet.CreateTimer Interval=',dbgs(Interval)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1502,7 +1502,7 @@ begin
|
|||||||
if Result = 0 then
|
if Result = 0 then
|
||||||
Dispose(TimerInfo)
|
Dispose(TimerInfo)
|
||||||
else begin
|
else begin
|
||||||
TimerInfo^.TimerFunc := TimerFunc;
|
TimerInfo^.TimerFunc := TimerProc;
|
||||||
TimerInfo^.TimerHandle:=Result;
|
TimerInfo^.TimerHandle:=Result;
|
||||||
FTimerData.Add(TimerInfo);
|
FTimerData.Add(TimerInfo);
|
||||||
end;
|
end;
|
||||||
|
@ -61,7 +61,7 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
// create and destroy
|
// create and destroy
|
||||||
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle; override;
|
function CreateTimer(Interval: integer; TimerFunc: TWSTimerProc) : THandle; override;
|
||||||
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
||||||
procedure DestroyLCLComponent(Sender: TObject);virtual;
|
procedure DestroyLCLComponent(Sender: TObject);virtual;
|
||||||
public
|
public
|
||||||
@ -137,7 +137,7 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TNoGUIWidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc
|
function TNoGUIWidgetSet.CreateTimer(Interval: integer; TimerFunc: TWSTimerProc
|
||||||
): THandle;
|
): THandle;
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
|
@ -114,7 +114,7 @@ type
|
|||||||
procedure SetDesigning(AComponent: TComponent); override;
|
procedure SetDesigning(AComponent: TComponent); override;
|
||||||
|
|
||||||
// create and destroy
|
// create and destroy
|
||||||
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle; override;
|
function CreateTimer(Interval: integer; TimerFunc: TWSTimerProc): THandle; override;
|
||||||
function DestroyTimer(TimerHandle: THandle): boolean; override;
|
function DestroyTimer(TimerHandle: THandle): boolean; override;
|
||||||
|
|
||||||
// device contexts
|
// device contexts
|
||||||
|
@ -69,7 +69,7 @@ end;
|
|||||||
|
|
||||||
Creates a new timer and sets the callback event.
|
Creates a new timer and sets the callback event.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TQtWidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle;
|
function TQtWidgetSet.CreateTimer(Interval: integer; TimerFunc: TWSTimerProc): THandle;
|
||||||
var
|
var
|
||||||
QtTimer: TQtTimer;
|
QtTimer: TQtTimer;
|
||||||
begin
|
begin
|
||||||
|
@ -33,7 +33,7 @@ uses
|
|||||||
// Free Pascal
|
// Free Pascal
|
||||||
Classes, SysUtils, Types,
|
Classes, SysUtils, Types,
|
||||||
// LCL
|
// LCL
|
||||||
LCLType, LCLIntf, Menus, LCLProc, Graphics, ClipBrd, ExtCtrls;
|
LCLType, LCLIntf, Menus, LCLProc, Graphics, ClipBrd, ExtCtrls, Interfacebase;
|
||||||
|
|
||||||
type
|
type
|
||||||
// forward declarations
|
// forward declarations
|
||||||
@ -596,11 +596,11 @@ type
|
|||||||
TQtTimer = class(TQtObject)
|
TQtTimer = class(TQtObject)
|
||||||
private
|
private
|
||||||
FTimerHook: QTimer_hookH;
|
FTimerHook: QTimer_hookH;
|
||||||
FCallbackFunc: TFNTimerProc;
|
FCallbackFunc: TWSTimerProc;
|
||||||
FId: Integer;
|
FId: Integer;
|
||||||
FAppObject: QObjectH;
|
FAppObject: QObjectH;
|
||||||
public
|
public
|
||||||
constructor CreateTimer(Interval: integer; const TimerFunc: TFNTimerProc; App: QObjectH); virtual;
|
constructor CreateTimer(Interval: integer; const TimerFunc: TWSTimerProc; App: QObjectH); virtual;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure AttachEvents; override;
|
procedure AttachEvents; override;
|
||||||
procedure DetachEvents; override;
|
procedure DetachEvents; override;
|
||||||
@ -3690,7 +3690,7 @@ end;
|
|||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
constructor TQtTimer.CreateTimer(Interval: integer;
|
constructor TQtTimer.CreateTimer(Interval: integer;
|
||||||
const TimerFunc: TFNTimerProc; App: QObjectH);
|
const TimerFunc: TWSTimerProc; App: QObjectH);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FDeleteLater := True;
|
FDeleteLater := True;
|
||||||
|
@ -30,7 +30,7 @@ unit Win32Def;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, Classes, LCLType;
|
Windows, Classes, LCLType, Interfacebase;
|
||||||
|
|
||||||
const
|
const
|
||||||
// it is not good to use WM_USER since many programs use it.
|
// it is not good to use WM_USER since many programs use it.
|
||||||
@ -41,7 +41,7 @@ type
|
|||||||
PWin32TimerInfo = ^TWin32Timerinfo;
|
PWin32TimerInfo = ^TWin32Timerinfo;
|
||||||
TWin32TimerInfo = record
|
TWin32TimerInfo = record
|
||||||
TimerID: UINT; // the windows timer ID for this timer
|
TimerID: UINT; // the windows timer ID for this timer
|
||||||
TimerFunc: TFNTimerProc; // owner function to handle timer
|
TimerFunc: TWSTimerProc; // owner function to handle timer
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
@ -188,7 +188,7 @@ type
|
|||||||
procedure ShowHide(Sender: TObject);
|
procedure ShowHide(Sender: TObject);
|
||||||
|
|
||||||
// create and destroy
|
// create and destroy
|
||||||
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle; override;
|
function CreateTimer(Interval: integer; TimerFunc: TWSTimerProc) : THandle; override;
|
||||||
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
||||||
|
|
||||||
// thread synchronize support
|
// thread synchronize support
|
||||||
|
@ -546,7 +546,7 @@ end;
|
|||||||
Design: A timer which calls TimerCallBackProc, is created.
|
Design: A timer which calls TimerCallBackProc, is created.
|
||||||
The TimerCallBackProc calls the TimerFunc.
|
The TimerCallBackProc calls the TimerFunc.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TWin32WidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle;
|
function TWin32WidgetSet.CreateTimer(Interval: integer; TimerFunc: TWSTimerProc) : THandle;
|
||||||
var
|
var
|
||||||
TimerInfo: PWin32TimerInfo;
|
TimerInfo: PWin32TimerInfo;
|
||||||
begin
|
begin
|
||||||
|
@ -107,7 +107,7 @@ type
|
|||||||
PWinCETimerInfo = ^TWinCETimerinfo;
|
PWinCETimerInfo = ^TWinCETimerinfo;
|
||||||
TWinCETimerInfo = record
|
TWinCETimerInfo = record
|
||||||
TimerID: UINT; // the windows timer ID for this timer
|
TimerID: UINT; // the windows timer ID for this timer
|
||||||
TimerFunc: TFNTimerProc; // owner function to handle timer
|
TimerFunc: TWSTimerProc; // owner function to handle timer
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifdef WinCE}
|
{$ifdef WinCE}
|
||||||
|
@ -204,7 +204,7 @@ type
|
|||||||
procedure ShowHide(Sender: TObject);
|
procedure ShowHide(Sender: TObject);
|
||||||
|
|
||||||
// create and destroy
|
// create and destroy
|
||||||
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle; override;
|
function CreateTimer(Interval: integer; TimerFunc: TWSTimerProc) : THandle; override;
|
||||||
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
function DestroyTimer(TimerHandle: THandle) : boolean; override;
|
||||||
|
|
||||||
// thread synchronize support
|
// thread synchronize support
|
||||||
|
@ -452,7 +452,7 @@ end;
|
|||||||
Design: A timer which calls TimerCallBackProc, is created.
|
Design: A timer which calls TimerCallBackProc, is created.
|
||||||
The TimerCallBackProc calls the TimerFunc.
|
The TimerCallBackProc calls the TimerFunc.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TWinCEWidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle;
|
function TWinCEWidgetSet.CreateTimer(Interval: integer; TimerFunc: TWSTimerProc) : THandle;
|
||||||
var
|
var
|
||||||
TimerInfo: PWinCETimerInfo;
|
TimerInfo: PWinCETimerInfo;
|
||||||
begin
|
begin
|
||||||
|
@ -52,7 +52,7 @@ uses
|
|||||||
{$IFDEF Windows}Windows, ShellApi, {$ENDIF}
|
{$IFDEF Windows}Windows, ShellApi, {$ENDIF}
|
||||||
{$IFDEF Darwin}MacOSAll, {$ENDIF}
|
{$IFDEF Darwin}MacOSAll, {$ENDIF}
|
||||||
Types, Math, Classes, SysUtils, LCLType, LCLProc, GraphType, InterfaceBase,
|
Types, Math, Classes, SysUtils, LCLType, LCLProc, GraphType, InterfaceBase,
|
||||||
LResources, FileUtil, UTF8Process;
|
LResources, FileUtil, UTF8Process, Maps, LMessages;
|
||||||
|
|
||||||
{$ifdef Trace}
|
{$ifdef Trace}
|
||||||
{$ASSERTIONS ON}
|
{$ASSERTIONS ON}
|
||||||
@ -98,12 +98,60 @@ function OpenURL(AURL: String): Boolean;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
type
|
||||||
|
{ TTimerID }
|
||||||
|
|
||||||
|
TTimerID = class
|
||||||
|
procedure TimerNotify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PTimerInfo = ^TTimerInfo;
|
||||||
|
TTimerInfo = record
|
||||||
|
Wnd: HWND;
|
||||||
|
IDEvent: UINT_PTR;
|
||||||
|
TimerProc: TTimerProc;
|
||||||
|
Handle: THandle;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
MTimerMap: TMap = nil; // hWnd + nIDEvent -> ID
|
||||||
|
MTimerInfo: TMap = nil; // ID -> TTimerInfo
|
||||||
|
MTimerSeq: Cardinal;
|
||||||
|
|
||||||
FPredefinedClipboardFormats:
|
FPredefinedClipboardFormats:
|
||||||
array[TPredefinedClipboardFormat] of TClipboardFormat;
|
array[TPredefinedClipboardFormat] of TClipboardFormat;
|
||||||
LowerCaseChars: array[char] of char;
|
LowerCaseChars: array[char] of char;
|
||||||
UpperCaseChars: array[char] of char;
|
UpperCaseChars: array[char] of char;
|
||||||
|
|
||||||
|
|
||||||
|
{ TTimerMap }
|
||||||
|
|
||||||
|
procedure TTimerID.TimerNotify;
|
||||||
|
var
|
||||||
|
Info: PTimerInfo;
|
||||||
|
ID: Cardinal;
|
||||||
|
begin
|
||||||
|
if MTimerInfo = nil then Exit;
|
||||||
|
|
||||||
|
// this is a bit of a hack.
|
||||||
|
// to pass the ID if the timer, it is passed as an cast to self
|
||||||
|
// So there isn't realy an instance of TTimerID
|
||||||
|
ID := PtrUInt(Self);
|
||||||
|
Info := MTimerInfo.GetDataPtr(ID);
|
||||||
|
if Info = nil then Exit;
|
||||||
|
|
||||||
|
if Info^.TimerProc = nil
|
||||||
|
then begin
|
||||||
|
// send message
|
||||||
|
PostMessage(Info^.Wnd, LM_TIMER, Info^.IDEvent, 0);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
// a timerproc was passed
|
||||||
|
Info^.TimerProc(Info^.Wnd, LM_TIMER, Info^.IDEvent, GetTickCount);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$IFNDEF WINDOWS}
|
{$IFNDEF WINDOWS}
|
||||||
function GetTickCount: DWord;
|
function GetTickCount: DWord;
|
||||||
begin
|
begin
|
||||||
@ -314,4 +362,7 @@ end;
|
|||||||
initialization
|
initialization
|
||||||
InternalInit;
|
InternalInit;
|
||||||
|
|
||||||
|
finalization
|
||||||
|
FreeAndNil(MTimerMap);
|
||||||
|
FreeAndNil(MTimerInfo);
|
||||||
end.
|
end.
|
||||||
|
@ -67,6 +67,7 @@ type
|
|||||||
TUTF8Char = String[7];
|
TUTF8Char = String[7];
|
||||||
{$ENDIF USE_UTF8BIDI_LCL}
|
{$ENDIF USE_UTF8BIDI_LCL}
|
||||||
UINT = LongWord;
|
UINT = LongWord;
|
||||||
|
UINT_PTR = PtrUInt;
|
||||||
|
|
||||||
TTranslateString = type String;
|
TTranslateString = type String;
|
||||||
|
|
||||||
@ -2398,9 +2399,20 @@ type
|
|||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// prototype for timer callback
|
//timer
|
||||||
type
|
type
|
||||||
TFNTimerProc = procedure of object;
|
TTimerProc = procedure(hWnd: HWND; uMsg: UINT; idEvent: UINT_PTR; dwTime: DWORD); stdcall;
|
||||||
|
|
||||||
|
TLMTimer = record
|
||||||
|
Msg: Cardinal;
|
||||||
|
TimerID: LongWord;
|
||||||
|
TimerProc: TFarProc;
|
||||||
|
Result: LRESULT;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// delphi
|
||||||
|
TFNTimerProc = TFarProc;
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// clipboard
|
// clipboard
|
||||||
|
Loading…
Reference in New Issue
Block a user