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.
130 lines
3.1 KiB
130 lines
3.1 KiB
unit ufrmMemoBox;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, System.UITypes,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, umstMaster, Vcl.StdCtrls, Vcl.ComCtrls,
|
|
Vcl.DBCtrls, rDBComponents, Data.DB;
|
|
|
|
type
|
|
TfrmMemoBox = class(TmstMaster)
|
|
dbmb_obs: TDBMemo;
|
|
lbl_tfonte: TLabel;
|
|
up_fonte: TUpDown;
|
|
edt_fonte: TEdit;
|
|
cb_negrito: TCheckBox;
|
|
dtsHistorico: TDataSource;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure up_fonteClick(Sender: TObject; Button: TUDBtnType);
|
|
procedure cb_negritoClick(Sender: TObject);
|
|
procedure edt_fonteEnter(Sender: TObject);
|
|
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|
procedure dtsHistoricoStateChange(Sender: TObject);
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
private
|
|
procedure WMMoving(var Msg: TWMMoving); message WM_MOVING;
|
|
|
|
{ Private declarations }
|
|
public
|
|
chamou_esc : boolean;
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frmMemoBox: TfrmMemoBox;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses udtmSystem;
|
|
|
|
procedure TfrmMemoBox.cb_negritoClick(Sender: TObject);
|
|
begin
|
|
if cb_negrito.Checked then
|
|
begin
|
|
dbmb_obs.Font.Style := dbmb_obs.Font.Style + [fsBold];
|
|
// toggle do negrito
|
|
end
|
|
else
|
|
begin
|
|
dbmb_obs.Font.Style := dbmb_obs.Font.Style - [fsBold];
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmMemoBox.dtsHistoricoStateChange(Sender: TObject);
|
|
begin
|
|
dbmb_obs.ReadOnly := not(dtsHistorico.State in [dsEdit, dsInsert]);
|
|
end;
|
|
|
|
procedure TfrmMemoBox.edt_fonteEnter(Sender: TObject);
|
|
begin
|
|
if StrToInt(edt_fonte.text) < 8 then // min e max do tamanho da fonte
|
|
begin
|
|
text := '8';
|
|
dbmb_obs.Font.Size := 8;
|
|
end;
|
|
if StrToInt(edt_fonte.text) > 72 then
|
|
begin
|
|
text := '72';
|
|
dbmb_obs.Font.Size := 72;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmMemoBox.FormClose(Sender: TObject; var Action: TCloseAction);
|
|
begin
|
|
inherited;
|
|
if (dtsHistorico.State in [dsInsert,dsEdit]) and (chamou_esc = false) then
|
|
begin
|
|
dtsHistorico.DataSet.FieldByName('TL_MEMO').AsString := dbmb_obs.Lines.Text;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmMemoBox.FormCreate(Sender: TObject);
|
|
begin
|
|
edt_fonte.text := inttostr(dbmb_obs.Font.Size);
|
|
chamou_esc := false;
|
|
end;
|
|
|
|
procedure TfrmMemoBox.FormKeyDown(Sender: TObject; var Key: Word;
|
|
Shift: TShiftState);
|
|
begin
|
|
if Key = VK_ESCAPE then
|
|
begin
|
|
Key := 0;
|
|
chamou_esc := true;
|
|
Close;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmMemoBox.up_fonteClick(Sender: TObject; Button: TUDBtnType);
|
|
begin
|
|
dbmb_obs.Font.Size := StrToInt(edt_fonte.text);
|
|
end;
|
|
|
|
procedure TfrmMemoBox.WMMoving(var Msg: TWMMoving);
|
|
var
|
|
workArea: TRect;
|
|
begin
|
|
workArea := Screen.WorkareaRect;
|
|
|
|
with Msg.DragRect^ do
|
|
begin
|
|
if left < workArea.left then
|
|
OffsetRect(Msg.DragRect^, workArea.left - left, 0);
|
|
|
|
if top < workArea.top then
|
|
OffsetRect(Msg.DragRect^, 0, workArea.top - top);
|
|
|
|
if Right > workArea.Right then
|
|
OffsetRect(Msg.DragRect^, workArea.Right - Right, 0);
|
|
|
|
if Bottom > workArea.Bottom then
|
|
OffsetRect(Msg.DragRect^, 0, workArea.Bottom - Bottom);
|
|
end;
|
|
|
|
end;
|
|
|
|
end.
|