You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
2.9 KiB
114 lines
2.9 KiB
unit ufrmPopUp;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, IniFiles, DateUtils, System.UITypes,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, umstMaster, Vcl.ComCtrls, Vcl.StdCtrls;
|
|
|
|
type
|
|
TfrmPopUp = class(TmstMaster)
|
|
mb_texto: TMemo;
|
|
dtp_datatermino: TDateTimePicker;
|
|
Button1: TButton;
|
|
Button2: TButton;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure Button1Click(Sender: TObject);
|
|
procedure Button2Click(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frmPopUp: TfrmPopUp;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses udtmSystem;
|
|
|
|
procedure TfrmPopUp.Button1Click(Sender: TObject);
|
|
var
|
|
resp: integer;
|
|
begin
|
|
if mb_texto.ToString = '' then
|
|
begin
|
|
resp := MessageDlg('Deseja apagar a mensagem do Pop Up?', mtWarning,
|
|
mbYesNo, 0);
|
|
if resp = mrNo then
|
|
begin
|
|
Abort;
|
|
end;
|
|
end;
|
|
if DaysBetween(dtp_datatermino.Date, now) > 360 then
|
|
begin
|
|
resp := MessageDlg
|
|
('A data para termino do envio da mensagem parece incorreta. Deseja continuar?',
|
|
mtWarning, mbYesNo, 0);
|
|
if resp = mrNo then
|
|
begin
|
|
Abort;
|
|
end;
|
|
end;
|
|
// with TIniFile.Create(ExtractFilePath(Application.ExeName) + 'popup.ini') do
|
|
with TIniFile.Create(dtmSystem.path_executavel + '\popup.ini') do
|
|
begin
|
|
WriteString('MENSAGEM', 'Texto', mb_texto.Text);
|
|
WriteString('MENSAGEM', 'Data-Fim', DateToStr(dtp_datatermino.Date));
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmPopUp.Button2Click(Sender: TObject);
|
|
var
|
|
msg: string;
|
|
data_termino: TDate;
|
|
begin
|
|
// with TIniFile.Create(ExtractFilePath(Application.ExeName) + 'popup.ini') do
|
|
with TIniFile.Create(dtmSystem.path_executavel + 'popup.ini') do
|
|
begin
|
|
msg := ReadString('MENSAGEM', 'Texto', '');
|
|
try
|
|
data_termino := StrToDate(ReadString('MENSAGEM', 'Data-Fim', ''));
|
|
except
|
|
data_termino := 0;
|
|
end;
|
|
end;
|
|
mb_texto.Text := msg;
|
|
dtp_datatermino.Date := data_termino;
|
|
end;
|
|
|
|
procedure TfrmPopUp.FormCreate(Sender: TObject);
|
|
var
|
|
msg: string;
|
|
data_termino: TDate;
|
|
begin
|
|
// if not(FileExists(ExtractFilePath(Application.ExeName) + 'popup.ini')) then
|
|
if not(FileExists(dtmSystem.path_executavel + '\popup.ini')) then
|
|
begin
|
|
// with TIniFile.Create(ExtractFilePath(Application.ExeName) + 'popup.ini') do
|
|
with TIniFile.Create(dtmSystem.path_executavel + '\popup.ini') do
|
|
begin
|
|
WriteString('MENSAGEM', 'Texto', '');
|
|
WriteString('MENSAGEM', 'Data-Fim', '');
|
|
end;
|
|
end;
|
|
|
|
// with TIniFile.Create(ExtractFilePath(Application.ExeName) + 'popup.ini') do
|
|
with TIniFile.Create(dtmSystem.path_executavel + '\popup.ini') do
|
|
begin
|
|
msg := ReadString('MENSAGEM', 'Texto', '');
|
|
try
|
|
data_termino := StrToDate(ReadString('MENSAGEM', 'Data-Fim', ''));
|
|
except
|
|
data_termino := 0;
|
|
end;
|
|
end;
|
|
mb_texto.Text := msg;
|
|
dtp_datatermino.Date := data_termino;
|
|
end;
|
|
|
|
end.
|