Hola compañeros me gustaría compartir con ustedes estas nuevas funciones pr si les resultase de ayuda
Código Delphi
[-] function FireCheck(CHK:TCheckBox; Ds:TDataSource; CAMPO:string):string; begin
if Ds.DataSet.FieldByName(CAMPO).Value='SI' then
begin
CHK.Checked:=True;
Result:='SI';
end else
begin
CHK.Checked:=False;
Result:='NO';
end;
end;
function CheckFire(CHK:TCheckBox; Ds:TDataSource; CAMPO:string):string; begin
if CHK.Checked=true then
begin
Ds.DataSet.FieldByName(CAMPO).Value:='SI';
Result:='SI';
end else
begin
Ds.DataSet.FieldByName(CAMPO).Value:='NO';
Result:='NO';
end;
end;
function MAxMin(Max,Min,Valor:integer): Integer;
var VMiRetorrno:integer;
focusRectangle:tshape;
begin
VMiRetorrno:=VALOR;
if min>valor then VMiRetorrno:=Min;
if maxthen VMiRetorrno:=Max;
Result:=VMiRetorrno;
end;
Function Redondear(Control: TWinControl;Round:integer;ColorLine,ColorFondo:Tcolor;WidthLine,Style,Border,space,STyleF:integer):b oolean ;
var
R: TRect;
Rgn: HRGN;
focusRectangle:tshape; begin
focusRectangle := TShape.Create(Control) ;
case border of
1: focusRectangle.Shape := stRectangle;
2: focusRectangle.Shape := stSquare; 3: focusRectangle.Shape := stRoundRect;
4: focusRectangle.Shape := stRoundSquare; 5: focusRectangle.Shape := stEllipse; 6: focusRectangle.Shape := stCircle; end;
focusRectangle.Visible := false;
case Style of
1: focusRectangle.Pen.Style := psSolid;
2: focusRectangle.Pen.Style := psDash;
3: focusRectangle.Pen.Style := psDot;
4: focusRectangle.Pen.Style := psDashDot;
5: focusRectangle.Pen.Style := psDashDotDot;
6: focusRectangle.Pen.Style := psClear;
7: focusRectangle.Pen.Style := psInsideFrame;
8: focusRectangle.Pen.Style := psUserStyle;
9: focusRectangle.Pen.Style := psAlternate;
end;
focusRectangle.Brush.Color:=ColorFondo;
case STyleF of
1:focusRectangle.Brush.Style := bsSolid;
2:focusRectangle.Brush.Style := bsClear;
3:focusRectangle.Brush.Style := bsHorizontal;
4:focusRectangle.Brush.Style := bsVertical;
5:focusRectangle.Brush.Style := bsFDiagonal;
6:focusRectangle.Brush.Style := bsCross;
7:focusRectangle.Brush.Style := bsDiagCross;
end;
FocusRectangle.Pen.Color := ColorLine;
focusRectangle.Pen.Width := WidthLine;
with Control do
begin
R := ClientRect;
rgn := CreateRoundRectRgn(R.Left, R.Top, R.Right, R.Bottom, Round, Round) ;
Perform(EM_GETRECT, 0, lParam(@r)) ;
InflateRect(r, - 4, - 4) ;
Perform(EM_SETRECTNP, 0, lParam(@r)) ;
SetWindowRgn(Handle, rgn, True) ;
with focusRectangle do
begin
Parent := Control.Parent;
Top := Control.Top - (space+WidthLine);
Height := Control.Height + ((space*2)+WidthLine);
Left := Control.Left - (space+WidthLine);
Width := Control.Width + ((Space*2)+WidthLine);
Visible := true;
end;
Invalidate;
end;
end;
Function ActQuery(QRY:TIBQuery; TxtSql:string): Boolean;
var AntSql:string;
begin
try
try
AntSql:=QRY.SQL.Text;
QRY.Active:=false;
QRY.SQL.Clear;
QRY.SQL.Text:=TxtSql;
QRY.Active:=true;
Result:=true;
except
on E: Exception do
begin
ShowMessage('Se ha producido un error: ' + Chr(13) + Chr(13)
+ 'Clase de error: ' + E.ClassName + Chr(13) + Chr(13)
+ 'Mensaje del error: ' + E.Message+ Chr(13) + Chr(13)
+' '+ Chr(13) + Chr(13)
+'Se volvera al estado anterior');
Result:=false;
end;
end;
finally
if Result=false then
begin
QRY.Active:=false;
QRY.SQL.Clear;
QRY.SQL.Text:=AntSql;
QRY.Active:=true;
end;
end;
end;