mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: DialogAPI - timer component
(cherry picked from commit 9aa7dda9a4)
This commit is contained in:
parent
f462b65ba3
commit
2f4f8428e1
3 changed files with 40 additions and 11 deletions
|
|
@ -42,6 +42,7 @@
|
|||
#define DM_SETPROGRESSSTYLE DM_FIRST+38
|
||||
#define DM_SETPASSWORDCHAR DM_FIRST+39
|
||||
#define DM_LISTCLEAR DM_FIRST+40
|
||||
#define DM_TIMERSETINTERVAL DM_FIRST+41
|
||||
|
||||
/* events messages */
|
||||
#define DN_FIRST 0x1000
|
||||
|
|
@ -51,6 +52,7 @@
|
|||
#define DN_GOTFOCUS DN_FIRST+4 /* Sent when the dialog item gets input focus */
|
||||
#define DN_INITDIALOG DN_FIRST+5 /* Sent before showing the dialog */
|
||||
#define DN_KILLFOCUS DN_FIRST+6 /* Sent before a dialog item loses the input focus */
|
||||
#define DN_TIMER DN_FIRST+7 /* Sent when a timer expires */
|
||||
|
||||
#define DN_KEYDOWN DM_KEYDOWN
|
||||
#define DN_KEYUP DM_KEYUP
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ const
|
|||
DM_SETPROGRESSSTYLE = DM_FIRST+38;
|
||||
DM_SETPASSWORDCHAR = DM_FIRST+39;
|
||||
DM_LISTCLEAR = DM_FIRST+40;
|
||||
DM_TIMERSETINTERVAL = DM_FIRST+41;
|
||||
|
||||
// events messages
|
||||
DN_FIRST = $1000;
|
||||
|
|
@ -54,6 +55,7 @@ const
|
|||
DN_GOTFOCUS = DN_FIRST+4; // Sent when the dialog item gets input focus
|
||||
DN_INITDIALOG = DN_FIRST+5; // Sent before showing the dialog
|
||||
DN_KILLFOCUS = DN_FIRST+6; // Sent before a dialog item loses the input focus
|
||||
DN_TIMER = DN_FIRST+7; // Sent when a timer expires
|
||||
|
||||
DN_KEYDOWN = DM_KEYDOWN;
|
||||
DN_KEYUP = DM_KEYUP;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
This unit contains realization of Dialog API functions.
|
||||
|
||||
Copyright (C) 2008-2019 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2008-2023 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -35,6 +35,7 @@ type
|
|||
{ TDialogBox }
|
||||
|
||||
TDialogBox = class(TForm)
|
||||
DialogTimer: TTimer;
|
||||
DialogButton: TButton;
|
||||
DialogBitBtn: TBitBtn;
|
||||
DialogFileNameEdit: TFileNameEdit;
|
||||
|
|
@ -88,9 +89,12 @@ type
|
|||
procedure ListBoxKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
// CheckBox events
|
||||
procedure CheckBoxChange(Sender: TObject);
|
||||
// Timer events
|
||||
procedure TimerTimer(Sender: TObject);
|
||||
private
|
||||
FRect: TRect;
|
||||
FText: String;
|
||||
FSelf: UIntPtr;
|
||||
FLRSData: String;
|
||||
FResult: LongBool;
|
||||
FDlgProc: TDlgProc;
|
||||
|
|
@ -211,19 +215,16 @@ function SendDlgMsg(pDlg: PtrUInt; DlgItemName: PAnsiChar; Msg, wParam, lParam:
|
|||
var
|
||||
Key: Word;
|
||||
AText: String;
|
||||
Index: Integer;
|
||||
Control: TControl;
|
||||
Component: TComponent = nil;
|
||||
lText: PAnsiChar absolute lParam;
|
||||
wText: PAnsiChar absolute wParam;
|
||||
pResult: Pointer absolute Result;
|
||||
DialogBox: TDialogBox absolute pDlg;
|
||||
Control: TControl absolute Component;
|
||||
begin
|
||||
// find component by name
|
||||
for Index:= 0 to DialogBox.ComponentCount - 1 do
|
||||
begin
|
||||
Control:= TControl(DialogBox.Components[Index]);
|
||||
if CompareText(Control.Name, DlgItemName) = 0 then Break;
|
||||
end;
|
||||
Component:= DialogBox.FindComponent(DlgItemName);
|
||||
if (Component = nil) then Exit(-1);
|
||||
// process message
|
||||
case Msg of
|
||||
DM_CLOSE:
|
||||
|
|
@ -234,9 +235,17 @@ begin
|
|||
end;
|
||||
DM_ENABLE:
|
||||
begin
|
||||
Result:= PtrInt(Control.Enabled);
|
||||
if wParam <> -1 then
|
||||
Control.Enabled:= Boolean(wParam);
|
||||
if (Component is TTimer) then
|
||||
begin
|
||||
Result:= PtrInt(TTimer(Component).Enabled);
|
||||
if wParam <> -1 then
|
||||
TTimer(Component).Enabled:= Boolean(wParam);
|
||||
end
|
||||
else begin
|
||||
Result:= PtrInt(Control.Enabled);
|
||||
if wParam <> -1 then
|
||||
Control.Enabled:= Boolean(wParam);
|
||||
end;
|
||||
end;
|
||||
DM_GETCHECK:
|
||||
begin
|
||||
|
|
@ -564,6 +573,13 @@ begin
|
|||
TCustomEdit(Control).PasswordChar:= Char(wParam);
|
||||
end;
|
||||
end;
|
||||
DM_TIMERSETINTERVAL:
|
||||
begin
|
||||
if (Component is TTimer) then
|
||||
begin
|
||||
TTimer(Component).Interval:= wParam;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -644,6 +660,7 @@ var
|
|||
begin
|
||||
FLRSData:= LRSData;
|
||||
FDlgProc:= DlgProc;
|
||||
FSelf:= UIntPtr(Self);
|
||||
|
||||
FileName:= mbGetModuleName(DlgProc);
|
||||
Path:= ExtractFilePath(FileName) + 'language' + PathDelim;
|
||||
|
|
@ -855,6 +872,14 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TDialogBox.TimerTimer(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
begin
|
||||
fDlgProc(FSelf, PAnsiChar((Sender as TTimer).Name), DN_TIMER, 0, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{.$I fdialogbox.lrs}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue