Prvni verze
This commit is contained in:
185
uUtils.pas
Normal file
185
uUtils.pas
Normal file
@ -0,0 +1,185 @@
|
||||
unit uUtils;
|
||||
|
||||
interface
|
||||
uses WinApi.Messages, System.Types, WinApi.Windows, VCL.Forms, Vcl.DBGrids, Data.DB, System.SysUtils, JvDBGrid, JvStringGrid,
|
||||
RzDBGrid;
|
||||
|
||||
type
|
||||
TNoScrollDBGrid = class(TDBGrid)
|
||||
private
|
||||
procedure WMNCCalcSize(var Msg: TMessage); message WM_NCCALCSIZE;
|
||||
end;
|
||||
|
||||
|
||||
procedure plgCenterForm(AForm : TForm);
|
||||
function plgMinimizeApplication(AForm: TForm; var AMessage: TWMSysCommand): Boolean;
|
||||
function FindColIndexByColName (g: TJvDBGrid; colName: string): integer; overload;
|
||||
function FindColIndexByColName (g: TDBGrid; colName: string): integer; overload;
|
||||
function FindColIndexByColName (g: TrzDBGrid; colName: string): integer; overload;
|
||||
function ColWidthSum (g: TJvDBGrid; jenVisible: boolean = true): integer; overload;
|
||||
function ColWidthSum (g: TDBGrid; jenVisible: boolean = true): integer; overload;
|
||||
function GetVisibleColsCount (const g: TDBGrid): integer; overload;
|
||||
function GetFirstVisibleColIndex (const g: TDBGrid): integer; overload;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
procedure TNoScrollDBGrid.WMNCCalcSize (var Msg: TMessage);
|
||||
const ScrollStyly = WS_VSCROLL or WS_HSCROLL;
|
||||
var styl: Integer;
|
||||
begin
|
||||
styl:= GetWindowLong(Handle, GWL_STYLE);
|
||||
if (styl and ScrollStyly) <> 0 then
|
||||
SetWindowLong(Handle, GWL_STYLE, styl and not ScrollStyly);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
function GetFirstVisibleColIndex (const g: TDBGrid): integer;
|
||||
var i: integer;
|
||||
begin
|
||||
result:= -1;
|
||||
for i:=0 to g.Columns.Count-1 do
|
||||
if (result=-1) and (g.Columns.Items[i].Visible) and (g.Columns.Items[i].Width>1) then
|
||||
result:= i;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
function GetVisibleColsCount (const g: TDBGrid): integer;
|
||||
var i: integer;
|
||||
begin
|
||||
result:= 0;
|
||||
for i:=0 to g.Columns.Count-1 do
|
||||
if (g.Columns.Items[i].Visible) and (g.Columns.Items[i].Width>1) then
|
||||
Inc(result);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function ColWidthSum (g: TJvDBGrid; jenVisible: boolean = true): integer; overload;
|
||||
var i: Integer;
|
||||
begin
|
||||
result:= 0;
|
||||
for i:=0 to g.Columns.Count-1 do
|
||||
begin
|
||||
if (jenVisible) then
|
||||
begin
|
||||
if (g.Columns.Items[i].Visible) then
|
||||
result:= result + g.Columns.Items[i].Width;
|
||||
end
|
||||
else
|
||||
result:= result + g.Columns.Items[i].Width;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function ColWidthSum (g: TDBGrid; jenVisible: boolean = true): integer; overload;
|
||||
var i: Integer;
|
||||
begin
|
||||
result:= 0;
|
||||
for i:=0 to g.Columns.Count-1 do
|
||||
begin
|
||||
if (jenVisible) then
|
||||
begin
|
||||
if (g.Columns.Items[i].Visible) then
|
||||
result:= result + g.Columns.Items[i].Width;
|
||||
end
|
||||
else
|
||||
result:= result + g.Columns.Items[i].Width;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function FindColIndexByColName (g: TJvDBGrid; colName: string): integer; overload;
|
||||
var i: integer;
|
||||
c: TColumn;
|
||||
fld: TField;
|
||||
fName: string;
|
||||
begin
|
||||
result:= -1;
|
||||
|
||||
i:= 0;
|
||||
while (i<=g.Columns.Count-1) and (result=-1) do
|
||||
begin
|
||||
if SameText(g.Columns.Items[i].FieldName, colName) then
|
||||
result:= i;
|
||||
Inc (i);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
function FindColIndexByColName (g: TrzDBGrid; colName: string): integer; overload;
|
||||
var i: integer;
|
||||
begin
|
||||
result:= -1;
|
||||
|
||||
i:= 0;
|
||||
while (i<=g.Columns.Count-1) or (result=-1) do
|
||||
begin
|
||||
if SameText(g.Columns.Items[i].FieldName, colName) then
|
||||
result:= i;
|
||||
Inc (i);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function FindColIndexByColName (g: TDBGrid; colName: string): integer; overload;
|
||||
var i: integer;
|
||||
begin
|
||||
result:= -1;
|
||||
|
||||
i:= 0;
|
||||
while (i<=g.Columns.Count-1) or (result=-1) do
|
||||
begin
|
||||
if SameText(g.Columns.Items[i].FieldName, colName) then
|
||||
result:= i;
|
||||
Inc (i);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure plgCenterForm (AForm: TForm);
|
||||
var LRect: TRect;
|
||||
LMon: TMonitor;
|
||||
begin
|
||||
// [RK 26.05.2010] centrovani na monitoru, kde okno lezi
|
||||
with AForm do
|
||||
begin
|
||||
LMon := Monitor;
|
||||
if LMon <> nil then
|
||||
LRect := LMon.WorkareaRect
|
||||
else
|
||||
LRect := Screen.WorkareaRect;
|
||||
|
||||
SetBounds(LRect.Left + ((RectWidth(LRect) - Width) div 2),
|
||||
LRect.Top + ((RectHeight(LRect) - Height) div 2), Width, Height);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function plgMinimizeApplication(AForm: TForm; var AMessage: TWMSysCommand): Boolean;
|
||||
begin
|
||||
// [RK 18.08.2011] uprava podle Heliosu
|
||||
Result := ((AMessage.CmdType and $FFF0) = SC_MINIMIZE);
|
||||
if Result then
|
||||
begin
|
||||
AMessage.Result := 0;
|
||||
EnableWindow(Application.Handle, True);
|
||||
ShowWindow(Application.Handle, SW_MINIMIZE);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user