RTFormwork/public10/design/U_WindowFormdesign.pas

947 lines
30 KiB
ObjectPascal
Raw Normal View History

2024-07-07 09:35:27 +08:00
unit U_WindowFormdesign;
interface
uses
Windows, SysUtils, Messages, Classes, Controls, StdCtrls, ComCtrls, Forms,
ExtCtrls, ComObj, DXCORE, ActiveX, cxMemo, cxButtons, Graphics, IniFiles, DBClient,
Dialogs, Menus, DB, ADODB, cxLabel, BtnEdit, RTComboBox, cxTextEdit, cxMRUEdit,
cxDBData, cxGridLevel, cxButtonEdit, cxCurrencyEdit, cxGridTableView, cxGrid,
cxGridCustomTableView, cxGraphics, cxCalendar, cxCheckBox, cxGridDBTableView,
cxGridDBBandedTableView, cxStyles, cxPc, cxGroupBox, U_cxGridCustomCss,
2024-07-07 09:35:27 +08:00
cxCustomData, cxClasses, cxTimeEdit, cxEdit, cxLookAndFeels,dxLayoutControl,
cxLookAndFeelPainters, cxGridCustomView, Buttons, cxDropDownEdit;
2024-07-07 09:35:27 +08:00
type
TWindowFormDeSign = class(TObject)
private
fFontSize: integer;
fWhatDesign: string;
fFormCaption: string;
fDllName: string;
fFormName: string;
fFormId: integer;
fIsShowColumnfilter: boolean;
ADOQueryCmd: TADOQuery;
ADOQueryTmp: TADOQuery;
client1:TClientDataSet ;
// procedure SetCxGridColumnBestWidth(cxGrid: TcxGridDBTableView);
// function SaveFormGridInfo(mCxGridView: TcxGridDBTableView; ADOCmd: TADOQuery; mdesignCode: string; mGridName: string; mGridType: integer): boolean;
procedure SetFormOperRight(mParent: TwinControl; mRightCaptions: string);
2024-07-07 09:35:27 +08:00
function GetMaxId(): integer;
procedure cxGridViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure cxGridViewSelectionChanged(Sender: TcxCustomGridTableView);
function InitCtrlData(mCtrl: TControl; mSql: string; mdefault: string): boolean;
procedure OpenGridDesignWin(mCxGridView: TcxGridDBTableView);
function getChgDefaultValue(mValue: string): string;
procedure dxLayoutControl1DblClick(Sender: TObject);
2024-10-12 10:45:24 +08:00
procedure setGridClick(Sender: TObject);
2024-07-07 09:35:27 +08:00
function getColumnRelation(tv1:TcxGridDBTableView):TclientDataSet;
procedure cxGridViewCustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
public
2024-10-12 10:45:24 +08:00
fProcedureName:string;
2024-07-07 09:35:27 +08:00
function FormStyleInit(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
2024-10-12 10:45:24 +08:00
function FormStyleInit1(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
function FormStyleInit10(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
2024-07-07 09:35:27 +08:00
procedure QueryDataPlus(ADOTmp: TADOQuery);
2024-10-12 10:45:24 +08:00
procedure OpenGridDesignWin10(mdesignCode:string;mGridName:string;mCxGridView: TcxGridDBTableView);
2024-07-07 09:35:27 +08:00
end;
const
// panel<65><6C><EFBFBD><EFBFBD>
clPanelBack = TColor($00FAF8F7);
clToolBarBack = TColor($00FAF8F7);
// <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ɫ
clFormBack = TColor($00FAF8F7);
implementation
uses
U_DataLink, U_globalVar,U_cxGridCustomSet,U_FormLayOutDesign;
/// //////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ã<EFBFBD>
/// //////////////////////////////////////////////////////
function TWindowFormDeSign.FormStyleInit(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
var
i: integer;
cxStyle_GridOddRow: TcxStyle;
cxStyle_GridEvenRow: TcxStyle;
cxStyle_active: TcxStyle;
cxStyle_gridGroupBox: TcxStyle;
cxStyle_gridFoot: TcxStyle;
cxStyle_selection: TcxStyle;
mvalue: TcxStyleValues;
mCtl3D, mToolBarList: boolean;
mIsCustomBackColor: boolean;
mIsDrawGridHeader: boolean;
mdesignCode: string;
2024-10-12 10:45:24 +08:00
setGridButton: TToolButton;
2024-07-07 09:35:27 +08:00
begin
if gIsYsUse then exit;
2024-07-07 09:35:27 +08:00
ADOQueryCmd := ADOQCmd;
ADOQueryTmp := ADOTmp;
fDllName := gDllFileName;
2024-10-12 10:45:24 +08:00
fFormName := mForm.name;
2024-07-07 09:35:27 +08:00
fFormId := mFormId;
//gIsCanDesign :=IsHasDesignRight(ADOTmp,PWideChar(dCode)) ;
2024-10-12 10:45:24 +08:00
//
//if trim(mStyleCode) = '' then
// mStyleCode := '01';
2024-07-07 09:35:27 +08:00
2024-08-20 09:43:44 +08:00
if gFontSize>=9 then
begin
fFontSize:= gFontSize ;
end
else
fFontSize:=9;
// else
// begin
// fFontSize:= getSystemFontSize(ADOTmp,PWideChar(mStyleCode));
// if fFontSize < 9 then
// fFontSize := 12;
// gFontSize:=fFontSize;
// end;
2024-07-07 09:35:27 +08:00
mForm.Font.Size := fFontSize;
// <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ɫ
2024-08-20 09:43:44 +08:00
try
2024-07-07 09:35:27 +08:00
for i := 0 to mForm.ComponentCount - 1 do
begin
2024-08-01 15:47:53 +08:00
if not(mForm.Components[i] is Twincontrol) then
2024-07-07 09:35:27 +08:00
begin
2024-08-01 15:47:53 +08:00
continue;
2024-07-07 09:35:27 +08:00
end;
2024-10-12 10:45:24 +08:00
if ((mForm.Components[i] is TcxTextEdit and TcxTextEdit(mForm.Components[i]).ParentFont)
or (mForm.Components[i] is TcxComboBox and TcxComboBox(mForm.Components[i]).ParentFont)
or (mForm.Components[i] is TcxdateEdit) and TcxdateEdit(mForm.Components[i]).ParentFont ) then
Continue;
2024-08-01 15:47:53 +08:00
if mForm.Components[i] is TcxTextEdit then
2024-07-07 09:35:27 +08:00
begin
2024-10-12 10:45:24 +08:00
if (mForm.Components[i].Tag<999) and not TcxTextEdit(mForm.Components[i]).ParentFont then
TcxTextEdit(mForm.Components[i]).ParentFont:=True;
2024-07-07 09:35:27 +08:00
continue;
end;
2024-08-01 15:47:53 +08:00
if (mForm.Components[i] is TcxComboBox) then
2024-07-07 09:35:27 +08:00
begin
2024-10-12 10:45:24 +08:00
if (mForm.Components[i].Tag<999) and not TcxComboBox(mForm.Components[i]).ParentFont then
2024-08-01 15:47:53 +08:00
TcxComboBox(mForm.Components[i]).ParentFont:=True;
continue;
end;
if mForm.Components[i] is TcxButtonEdit then
begin
if (mForm.Components[i].Tag<999) and not TcxButtonEdit(mForm.Components[i]).ParentFont then
2024-07-07 09:35:27 +08:00
TcxButtonEdit(mForm.Components[i]).ParentFont:=True;
continue;
end;
2024-08-01 15:47:53 +08:00
if mForm.Components[i] is TcxdateEdit then
begin
if mForm.Components[i].Tag<999 then
TcxdateEdit(mForm.Components[i]).ParentFont:=True;
continue;
2024-10-12 10:45:24 +08:00
end;
if mForm.Components[i] is TcxCurrencyEdit then
begin
if mForm.Components[i].Tag<999 then
TcxCurrencyEdit(mForm.Components[i]).ParentFont:=True;
continue;
2024-08-01 15:47:53 +08:00
end;
// if mForm.Components[i] is TfrmFrameDateSel then
// begin
// TfrmFrameDateSel(mForm.Components[i]).Font.Size:= fFontSize;
// TfrmFrameDateSel(mForm.Components[i]).cbbType.ParentFont:= true;
// TfrmFrameDateSel(mForm.Components[i]).BegDate.ParentFont:=true;
// TfrmFrameDateSel(mForm.Components[i]).endDate.ParentFont:=true;
// // TfrmFrameDateSel(mForm.Components[i]).TimeType.ParentFont:=true;
// continue;
// end;
2024-07-07 09:35:27 +08:00
if mForm.Components[i] is TcxMemo then
begin
if mForm.Components[i].Tag<999 then
TcxMemo(mForm.Components[i]).ParentFont:=True;
continue;
end;
2024-08-01 15:47:53 +08:00
// Tcxgroup
if mForm.Components[i] is TcxgroupBox then
begin
if mForm.Components[i].Tag<999 then
TcxgroupBox(mForm.Components[i]).ParentFont:=True;
2024-10-12 10:45:24 +08:00
// if mIsCustomBackColor then
// TcxgroupBox(mForm.Components[i]).Color := clPanelBack;
// TcxgroupBox(mForm.Components[i]).Ctl3D := mCtl3D;
// mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + TcxgroupBox(mForm.Components[i]).name;
2024-08-01 15:47:53 +08:00
continue;
end;
2024-07-07 09:35:27 +08:00
if mForm.Components[i] is TToolBar then
begin
2024-10-12 10:45:24 +08:00
if mForm.Components[i].Tag>=999 then exit;
2024-07-07 09:35:27 +08:00
if mForm.Components[i].Tag<999 then
2024-10-12 10:45:24 +08:00
TToolBar(mForm.Components[i]).ParentFont:=True;
2024-07-07 09:35:27 +08:00
TToolBar(mForm.Components[i]).AutoSize := true;
TToolBar(mForm.Components[i]).Flat := true;
2024-10-12 10:45:24 +08:00
//
if gIsCanDesign then
begin
if mForm.Components[i].FindComponent('TgridLiSet')=nil then
begin
TToolBar(mForm.Components[i]).Wrapable:=false;
setGridButton := TToolButton.Create(mForm); //
setGridButton.Left := TToolBar(mForm.Components[i]).ButtonWidth * TToolBar(mForm.Components[i]).ButtonCount;
setGridButton.Parent := TToolBar(mForm.Components[i]);
setGridButton.ImageIndex := 16; //<2F><>
setGridButton.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
setGridButton.Style := tbsButton;
setGridButton.AutoSize:=true;
setGridButton.OnClick := setGridClick; //
end;
end;
2024-07-07 09:35:27 +08:00
if mIsCustomBackColor then
TToolBar(mForm.Components[i]).Color := clToolBarBack;
if mForm.Components[i].Tag = 0 then
begin
if ADOTmp.IsEmpty then
TToolBar(mForm.Components[i]).List := false
else
TToolBar(mForm.Components[i]).List := mToolBarList;
end;
if mRightCaptions<>'' then
SetFormOperRight(TToolBar(mForm.Components[i]), PWideChar(mRightCaptions));
2024-07-07 09:35:27 +08:00
continue;
end;
if mForm.Components[i] is TcxTabControl then
begin
if mForm.Components[i].Tag<999 then
TdxLayoutControl(mForm.Components[i]).ParentFont:=true;
continue;
end;
if mForm.Components[i] is TcomBoBox then
begin
if mForm.Components[i].Tag<999 then
TcomBoBox(mForm.Components[i]).ParentFont:=true;
continue;
end;
if mForm.Components[i] is TdxCustomLayoutControl then
begin
2024-10-12 10:45:24 +08:00
if mForm.Components[i].Tag<999 then
2024-07-07 09:35:27 +08:00
TdxLayoutControl(mForm.Components[i]).ParentFont:=true;
if mForm.Components[i].Tag<>1000 then
begin
TdxLayoutControl(mForm.Components[i]).OnDblClick := dxLayoutControl1DblClick ;
2024-08-20 09:43:44 +08:00
readLayOut(TdxLayoutControl(mForm.Components[i]),ADOTmp,PWideChar( fDllFileName+'|'+mForm.name+'|'+TdxLayoutControl(mForm.Components[i]).Name+'.ini'));
2024-07-07 09:35:27 +08:00
end;
continue;
end;
// Tpanel
if mForm.Components[i] is Tpanel then
begin
if mForm.Components[i].Tag<999 then
Tpanel(mForm.Components[i]).ParentFont:=True;
if mIsCustomBackColor and (Tpanel(mForm.Components[i]).Tag < 99) then
Tpanel(mForm.Components[i]).Color := clPanelBack;
Tpanel(mForm.Components[i]).Ctl3D := mCtl3D;
2024-10-12 10:45:24 +08:00
// mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + Tpanel(mForm.Components[i]).name;
2024-07-07 09:35:27 +08:00
continue;
end;
2024-10-12 10:45:24 +08:00
// TScrollBox
2024-07-07 09:35:27 +08:00
if mForm.Components[i] is TScrollBox then
begin
if mForm.Components[i].Tag<999 then
TScrollBox(mForm.Components[i]).ParentFont:=true;
if mIsCustomBackColor and (Tpanel(mForm.Components[i]).Tag < 99) then
Tpanel(mForm.Components[i]).Color := clPanelBack;
Tpanel(mForm.Components[i]).Ctl3D := mCtl3D;
mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + TScrollBox(mForm.Components[i]).name;
continue;
end;
// Tcxgroup
if mForm.Components[i] is TgroupBox then
begin
if mForm.Components[i].Tag<999 then
TgroupBox(mForm.Components[i]).ParentFont:=true;
if mIsCustomBackColor then
TgroupBox(mForm.Components[i]).Color := clPanelBack;
TgroupBox(mForm.Components[i]).Ctl3D := mCtl3D;
continue;
end;
2024-08-01 15:47:53 +08:00
if mForm.Components[i] is TdatetimePicker then
begin
if TdatetimePicker(mForm.Components[i]).Width <= 90 then
TdatetimePicker(mForm.Components[i]).Width := TdatetimePicker(mForm.Components[i]).Width + ffontsize * 2;
continue;
end;
// end;
2024-07-07 09:35:27 +08:00
// TcxPageControl
if mForm.Components[i] is TcxPageControl then
begin
if mForm.Components[i].Tag<999 then
TcxPageControl(mForm.Components[i]).ParentFont:=True;
if mIsCustomBackColor then
TcxPageControl(mForm.Components[i]).Color := clPanelBack;
continue;
end;
if mForm.Components[i] is Tcxtimeedit then
begin
if mForm.Components[i].Tag<999 then
Tcxtimeedit(mForm.Components[i]).ParentFont:=true;
Tcxtimeedit(mForm.Components[i]).Style.BorderStyle := ebsFlat;
continue;
end;
// TcxGrid and gIsCustomDrawGridHeader
if mForm.Components[i] is TcxGrid then
begin
if mForm.Components[i].Tag>=999 then Continue;
TcxGrid(mForm.Components[i]).ParentFont:=true;
2024-10-12 10:45:24 +08:00
//TcxGrid(mForm.Components[i]).LookAndFeel.ScrollbarMode := sbmClassic;
2024-07-07 09:35:27 +08:00
//<2F>Զ<EFBFBD><D4B6><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).dataController.filter.AutoDataSetFilter := true;
2024-10-12 10:45:24 +08:00
// TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).OnKeyDown := cxGridViewKeyDown;
2024-07-07 09:35:27 +08:00
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).OnSelectionChanged := cxGridViewSelectionChanged;
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).OnCustomDrawIndicatorCell := cxGridViewCustomDrawIndicatorCell;
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).optionsCustomize.columnfiltering := true;
mdesignCode := fDllFileName +'|'+mForm.name+ '|' + intTostr(fFormId) + '|' + TcxGrid(mForm.Components[i]).name;
CreateCxGridColumn( TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]),ADOQueryTmp,PWideChar(mdesignCode));
2024-07-07 09:35:27 +08:00
continue;
end;
end;
2024-08-20 09:43:44 +08:00
except
showMessage('<27><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>쳣!');
end;
2024-07-07 09:35:27 +08:00
end;
2024-10-12 10:45:24 +08:00
/// //////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ã<EFBFBD>
/// //////////////////////////////////////////////////////
function TWindowFormDeSign.FormStyleInit1(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
var
i: integer;
mCtl3D, mToolBarList: boolean;
mIsCustomBackColor: boolean;
// mIsDrawGridHeader: boolean;
2024-10-12 10:45:24 +08:00
mdesignCode: string;
setGridButton: TToolButton;
comp: TComponent;
view: TcxGridDBTableView;
grid: TcxGrid;
toolBar: TToolBar;
layoutControl: TdxLayoutControl;
2024-10-12 10:45:24 +08:00
begin
if gIsYsUse then
exit;
2024-10-12 10:45:24 +08:00
ADOQueryCmd := ADOQCmd;
ADOQueryTmp := ADOTmp;
fDllName := gDllFileName;
fFormName := mForm.name;
fFormId := mFormId;
try
2024-10-23 13:46:15 +08:00
for i := 0 to mForm.ComponentCount - 1 do
2024-10-12 10:45:24 +08:00
begin
comp := mForm.Components[i];
if not ( comp is TcxGrid) and not( comp is TToolBar) and not( comp is TdxCustomLayoutControl) then Continue;
2024-10-23 13:46:15 +08:00
if comp is TcxGrid then
2024-10-12 10:45:24 +08:00
begin
grid := TcxGrid(comp);
if grid.Tag>=999 then Continue;
grid.BeginUpdate();
// TcxGrid(mForm.Components[i]).ParentFont:=true;
view := TcxGridDBTableView(grid.Views[0]);
2024-10-12 10:45:24 +08:00
//<2F>Զ<EFBFBD><D4B6><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
view.dataController.filter.AutoDataSetFilter := true;
view.optionsCustomize.columnfiltering := true;
view.OnSelectionChanged := cxGridViewSelectionChanged;
view.OnCustomDrawIndicatorCell := cxGridViewCustomDrawIndicatorCell;
view.optionsCustomize.columnfiltering := true;
mdesignCode := fDllFileName +'|'+mForm.name+ '|' + intTostr(fFormId) + '|' + grid.name;
grid.EndUpdate ;
CreateCxGridColumn( view,ADOQueryTmp,PWideChar(mdesignCode));
//continue;
end
2024-10-12 10:45:24 +08:00
//
else if mForm.Components[i] is TToolBar then
2024-10-12 10:45:24 +08:00
begin
toolBar := TToolBar(comp);
if toolBar.Tag>=999 then exit;
if toolBar.Tag<999 then
toolBar.ParentFont:=True;
toolBar.AutoSize := true;
toolBar.Flat := true;
2024-10-12 10:45:24 +08:00
//
if gIsCanDesign then
begin
if (mForm.Components[i].FindComponent('TgridLiSet')=nil) or (mForm.Components[i].FindComponent('TgridSet')=nil) then
2024-10-12 10:45:24 +08:00
begin
toolBar.Wrapable:=false;
2024-10-12 10:45:24 +08:00
setGridButton := TToolButton.Create(mForm); //
setGridButton.Left := toolBar.ButtonWidth * toolBar.ButtonCount;
setGridButton.Parent := toolBar;
2024-10-12 10:45:24 +08:00
setGridButton.ImageIndex := 16; //<2F><>
setGridButton.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
// setGridButton.Name:='TgridLiSet';
setGridButton.Style := tbsButton;
setGridButton.AutoSize:=true;
setGridButton.OnClick := setGridClick; //
end;
end;
if mIsCustomBackColor then
toolBar.Color := clToolBarBack;
if toolBar.Tag = 0 then
2024-10-12 10:45:24 +08:00
begin
if ADOTmp.IsEmpty then
toolBar.List := false
2024-10-12 10:45:24 +08:00
else
toolBar.List := mToolBarList;
2024-10-12 10:45:24 +08:00
end;
if mRightCaptions<>'' then
SetFormOperRight(toolBar, PWideChar(mRightCaptions));
//continue;
end
else if mForm.Components[i] is TdxLayoutControl then
2024-10-23 13:46:15 +08:00
begin
layoutControl := TdxLayoutControl(comp);
if layoutControl.Tag<999 then
layoutControl.ParentFont:=true;
if layoutControl.Tag<>1000 then
2024-10-23 13:46:15 +08:00
begin
layoutControl.OnDblClick := dxLayoutControl1DblClick ;
readLayOut(layoutControl,ADOTmp,PWideChar( fDllFileName+'|'+mForm.name+'|'+layoutControl.Name+'.ini'));
2024-10-23 13:46:15 +08:00
end;
continue;
end;
2024-10-12 10:45:24 +08:00
end;
2024-10-30 13:45:23 +08:00
2024-10-12 10:45:24 +08:00
except
showMessage('<27><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>쳣!');
end;
end;
/// //////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ã<EFBFBD>
/// //////////////////////////////////////////////////////
function TWindowFormDeSign.FormStyleInit10(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
var
i: integer;
cxStyle_GridOddRow: TcxStyle;
cxStyle_GridEvenRow: TcxStyle;
cxStyle_active: TcxStyle;
cxStyle_gridGroupBox: TcxStyle;
cxStyle_gridFoot: TcxStyle;
cxStyle_selection: TcxStyle;
mvalue: TcxStyleValues;
mCtl3D, mToolBarList: boolean;
mIsCustomBackColor: boolean;
mIsDrawGridHeader: boolean;
mdesignCode: string;
setGridButton: TToolButton;
begin
ADOQueryCmd := ADOQCmd;
ADOQueryTmp := ADOTmp;
fDllName := gDllFileName;
fFormName := mForm.name;
fFormId := mFormId;
2024-10-30 13:45:23 +08:00
exit;
2024-10-12 10:45:24 +08:00
if gFontSize>=9 then
begin
2024-10-12 10:45:24 +08:00
fFontSize:= gFontSize ;
end
else
begin
fFontSize:= 9;//
end;
2024-10-12 10:45:24 +08:00
mForm.Font.Size := fFontSize;
end;
2024-07-07 09:35:27 +08:00
/// /////////////////////////////////////////////////
//
/// ///////////////////////////////////////////////////
/// ////////////////////////////////////////////////////////////////
// <20><>ʼ<EFBFBD><CABC><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>SQL<51>Ŀؼ<C4BF>
/// ////////////////////////////////////////////////////////////////
function TWindowFormDeSign.InitCtrlData(mCtrl: TControl; mSql: string; mdefault: string): boolean;
var
idx: integer;
begin
result := false;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add(mSql);
open;
end;
if mCtrl is TcomBoBox then
begin
if ADOQueryTmp.RecordCount > 0 then
TcomBoBox(mCtrl).Clear;
while not ADOQueryTmp.Eof do
begin
TcomBoBox(mCtrl).Items.Add(trim(ADOQueryCmd.Fields[0].AsString));
ADOQueryCmd.Next;
end;
if mdefault <> '' then
begin
idx := TcomBoBox(mCtrl).Items.IndexOf(mdefault);
if idx >= 0 then
begin
TcomBoBox(mCtrl).ItemIndex := idx;
end;
end;
exit;
end;
/// //////////////
if mCtrl is TcxComboBox then
begin
if ADOQueryCmd.RecordCount > 0 then
begin
TcxComboBox(mCtrl).Clear;
TcxComboBox(mCtrl).Properties.Items.Clear;
end;
while not ADOQueryCmd.Eof do
begin
TcxComboBox(mCtrl).Properties.Items.Add(trim(ADOQueryCmd.Fields[0].AsString));
ADOQueryCmd.Next;
end;
if mdefault <> '' then
begin
idx := TcxComboBox(mCtrl).Properties.Items.IndexOf(mdefault);
if idx >= 0 then
begin
TcxComboBox(mCtrl).ItemIndex := idx;
end;
end;
exit;
end;
if mCtrl is Tdatetimepicker then
begin
Tdatetimepicker(mCtrl).Date := ADOQueryCmd.Fields[0].AsDateTime;
exit;
end;
if mCtrl is TcxDateEdit then
begin
TcxDateEdit(mCtrl).Date := ADOQueryCmd.Fields[0].AsDateTime;
exit;
end;
result := true;
except
application.MessageBox('<27><>ʼ<EFBFBD><CABC><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
/// ///////////////////////////////////////////////////////////////////////////////////////
//
/// ///////////////////////////////////////////////////////////////////////////////////////
//procedure TWindowFormDeSign.SetCxGridColumnBestWidth(cxGrid: TcxGridDBTableView);
//var
// i: integer;
// mCaption: string;
// mMinWidth: integer;
//begin
// try
// cxGrid.BeginUpdate;
// for i := 0 to cxGrid.ColumnCount - 1 do
// begin
// if cxGrid.ColumnCount < 6 then
// begin
// cxGrid.Columns[i].Width := 120;
// continue;
// end;
// mCaption := trim(cxGrid.Columns[i].Caption);
// if length(mCaption) <= 2 then
// mMinWidth := (length(mCaption) + 3) * 12
// else if (length(mCaption) > 2) and (length(mCaption) <= 4) then
// mMinWidth := (length(mCaption) + 2) * 12
// else if (length(mCaption) > 4) and (length(mCaption) <= 8) then
// mMinWidth := (length(mCaption) + 1) * 12
// else
// mMinWidth := (length(mCaption)) * 9;
// cxGrid.Columns[i].Width := mMinWidth;
// end;
// finally
// cxGrid.EndUpdate;
// end;
//end;
/// ////////////////////////////////////////
procedure TWindowFormDeSign.cxGridViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
mGridDBTableView: TcxGridDBTableView;
begin
if Key = vk_f12 then
begin
mGridDBTableView := TcxGridDBTableView(TcxGridSite(Sender).ViewInfo.GridView);
OpenGridDesignWin(mGridDBTableView);
end;
end;
/////////////////////////////////////////////
procedure TWindowFormDeSign.dxLayoutControl1DblClick(Sender: TObject);
begin
layoutDesign(TdxLayoutControl(Sender),ADOQueryCmd,PWideChar(dcode));
end;
/// ////////////////////////////////////////////////////////////////
// <20>򿪱<EFBFBD><F2BFAAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD>
// 0: mGridType <20><>ѯ; 1:<3A><><EFBFBD><EFBFBD>
/// /////////////////////////////////////////////////////////////////
procedure TWindowFormDeSign.OpenGridDesignWin(mCxGridView: TcxGridDBTableView);
var
mGridType: integer;
mdesignCode: string;
mGridName: string;
k: integer;
client1:TClientDataSet;
begin
/// ////////////////////////////////////
// Ȩ<>޿<EFBFBD><DEBF><EFBFBD>
2024-10-12 10:45:24 +08:00
2024-07-07 09:35:27 +08:00
mGridName := TcxGrid(TcxGridLevel(mCxGridView.level).Control).name;
2024-10-12 10:45:24 +08:00
mdesignCode :=fDllFileName+'|'+ fFormName + '|' + intTostr(fFormId) + '|' + mGridName;
if not gIsCanDesign then
2024-07-07 09:35:27 +08:00
exit;
ShowCxGridDesign(application, mCxGridView, getColumnRelation(mCxGridView),AdOQueryCmd,fFormName ,mGridName,fDllFileName,fformId,0,fProcedureName);
CreateCxGridColumn( mCxGridView,ADOQueryTmp,PWideChar(mdesignCode));
2024-10-12 10:45:24 +08:00
end;
/// ////////////////////////////////////////////////////////////////
// <20>򿪱<EFBFBD><F2BFAAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD> <20>µİ汾
/// /////////////////////////////////////////////////////////////////
procedure TWindowFormDeSign.OpenGridDesignWin10(mdesignCode:string;mGridName:string;mCxGridView: TcxGridDBTableView);
begin
ShowCxGridDesign(application, mCxGridView, getColumnRelation(mCxGridView),AdOQueryCmd,fFormName ,mGridName,fDllFileName,fformId,0,fProcedureName);
CreateCxGridColumn( mCxGridView,ADOQueryTmp,PWideChar(mdesignCode));
2024-07-07 09:35:27 +08:00
end;
/// //////////////////////////////////////
//
/// ///////////////////////////////////////
function TWindowFormDeSign.GetMaxId(): integer;
begin
result := 0;
try
with ADOQueryTmp do
begin
close;
sql.Clear;
Filtered := false;
sql.Add('select max(id) as id');
sql.Add('from SD_FormGrid_Design A');
open;
result := fieldByName('id').AsInteger + 1;
end;
except
end;
end;
/// //////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD>toolbar<61><72>ťȨ<C5A5>޲<EFBFBD><DEB2><EFBFBD>
/// //////////////////////////////////////////////////////////////
procedure TWindowFormDeSign.SetFormOperRight(mParent: TwinControl; mRightCaptions: string);
var
i: integer;
mCaption: string;
mOperRight: string;
begin
mOperRight := mRightCaptions;
if mOperRight = '' then
exit;
try
/// ////////////////////////////////////////////
if mParent is TToolBar then
begin
for i := 0 to TToolBar(mParent).ButtonCount - 1 do
begin
mCaption := trim(TToolBar(mParent).Buttons[i].Caption);
if (mCaption = '<27>ر<EFBFBD>') or (mCaption = '<27>˳<EFBFBD>') or (mCaption = '<27><><EFBFBD><EFBFBD>') then
exit;
/// //////////////////////////
if trim(mOperRight) = '<27><>ѯ' then
begin
if pos(mCaption, '<27><>ѯ,ˢ<><CBA2>,<2C><><EFBFBD><EFBFBD>,<2C>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>,<2C>߼<EFBFBD><DFBC><EFBFBD>ѯ') > 0 then // ,<2C>鿴,<2C><>ϸ
begin
TToolBar(mParent).Buttons[i].Visible := true;
end
else
begin
TToolBar(mParent).Buttons[i].Visible := false;
end;
end
else
begin
if (pos(mCaption, mOperRight) > 0) or (pos(mCaption, '<27><>ѯ,ˢ<><CBA2>,<2C><><EFBFBD><EFBFBD>,<2C>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>,<2C>߼<EFBFBD><DFBC><EFBFBD>ѯ') > 0) then // <20>鿴,
begin
TToolBar(mParent).Buttons[i].Visible := true;
end
else
begin
TToolBar(mParent).Buttons[i].Visible := false;
end;
end;
end;
exit;
end;
/// ////////////////////////////////////////////////
if trim(mOperRight) = '<27><>ѯ' then
exit;
with mParent do
begin
for i := 0 to ControlCount - 1 do
begin
mCaption := '';
if (Controls[i] is TBitBtn) then
mCaption := trim(TBitBtn(Controls[i]).Caption)
else if (Controls[i] is TButton) then
mCaption := trim(TButton(Controls[i]).Caption)
else if (Controls[i] is TSpeedButton) then
mCaption := trim(TSpeedButton(Controls[i]).Caption)
else
continue;
if (Controls[i] is TBitBtn) or (Controls[i] is TButton) or (Controls[i] is TSpeedButton) then
begin
if (pos(mCaption, mOperRight) > 0) or (mCaption = '<27><>ѯ') or (mCaption = '<27><><EFBFBD><EFBFBD>') or (mCaption = '<27>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>') then
begin
Controls[i].Visible := true;
end
else
Controls[i].Visible := false;
end;
end;
end;
except
application.MessageBox('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD>ťȨ<C5A5>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ', 0);
end;
end;
2024-07-07 09:35:27 +08:00
/// ////////////////////////////////////////////////////////////
//
/// ////////////////////////////////////////////////////////////
function TWindowFormDeSign.getChgDefaultValue(mValue: string): string;
begin
if '$$USERNAME' = mValue then
begin
result := DName;
end
else
result := mValue;
end;
/// ////////////////////////////////////////////////////
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ
/// /////////////////////////////////////////////////////
procedure TWindowFormDeSign.QueryDataPlus(ADOTmp: TADOQuery);
begin
end;
/////////////////////////////////////////////////////////
///
//////////////////////////////////////////////////////////
procedure TWindowFormDeSign.cxGridViewSelectionChanged(Sender: TcxCustomGridTableView);
var
i, J, idx: integer;
FocusedRowIndex: integer;
begin
if Sender.Tag = 888 then
exit;
try
Sender.BeginUpdate();
TcxGridDbTableView(Sender).BeginUpdate();
FocusedRowIndex := TcxGridDbTableView(Sender).Controller.FocusedRowIndex;
Sender.DataController.GotoFirst;
if TcxGridDbTableView(Sender).DataController.DataSet.FieldByName('ssel') = nil then
exit;
if TcxGridDbTableView(Sender).GetColumnByFieldName('ssel') = nil then
exit;
idx := TcxGridDbTableView(Sender).GetColumnByFieldName('ssel').Index;
for i := 0 to Sender.DataController.RecordCount - 1 do
begin
if TcxGridDbTableView(Sender).DataController.GetItemByFieldName('ssel').EditValue = true then
begin
TcxGridDbTableView(Sender).DataController.Edit;
TcxGridDbTableView(Sender).DataController.GetItemByFieldName('ssel').EditValue := false;
TcxGridDbTableView(Sender).DataController.Post();
end;
Sender.DataController.GotoNext;
end;
for i := 0 to Sender.DataController.GetSelectedCount - 1 do
begin
TcxGridDbTableView(Sender).Controller.FocusedRow := TcxGridDbTableView(Sender).Controller.SelectedRows[i];
if TcxGridDbTableView(Sender).DataController.GetItemByFieldName('ssel').EditValue = false then
begin
TcxGridDbTableView(Sender).DataController.Edit;
TcxGridDbTableView(Sender).DataController.GetItemByFieldName('ssel').EditValue := true;
TcxGridDbTableView(Sender).DataController.Post();
end;
end;
finally
TcxGridDbTableView(Sender).Controller.FocusedRowIndex := FocusedRowIndex;
TcxGridDbTableView(Sender).EndUpdate;
Sender.EndUpdate;
end;
end;
///////////////////////////////////////////////////////////////
///
///
procedure TWindowFormDeSign.cxGridViewCustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
ATextRect: TRect;
// AStyle: TcxStyle;
aCV: TcxCanvas;
begin
if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
Exit;
Sender.BeginUpdate() ;
aCV := ACanvas;
AViewInfo.GetBestFitWidth ;
ATextRect := AViewInfo.ContentBounds;
AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
InflateRect(ATextRect, -2, -1);
if AIndicatorViewInfo.GridRecord.Selected then //<2F><><EFBFBD><EFBFBD>if<69><66><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>кŴ<D0BA><C5B4>Ѱ<EFBFBD>ѡ<EFBFBD>е<EFBFBD><D0B5>кŸ<D0BA><C5B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>
begin
aCV.Font.Style := ACanvas.Font.Style + [fsBold];
aCV.Font.Color := clRed;
end
else
begin
aCV.Font.Style := ACanvas.Font.Style - [fsBold];
aCV.Font.Color := clblack;
end;
Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds, ATextRect, [], cxBordersAll, cxbsNormal, taCenter, vaCenter, False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1),
aCV.Font, aCV.font.Color, aCV.Brush.color);
Sender.EndUpdate;
ADone := True;
end;
/////////////////////////////////////////////////////////////////
///
function TWindowFormDeSign.getColumnRelation(tv1:TcxGridDBTableView):TclientDataSet;
var
i:Integer;
begin
if client1=nil then
begin
client1 := TClientDataSet.Create(nil);
client1.FieldDefs.Add('fieldName', ftString, 100);
client1.FieldDefs.Add('caption', ftString,100);
client1.FieldDefs.Add('ValueType', ftString,100);
client1.CreateDataSet;
end
else
client1.EmptyDataSet;
for i := 0 to tv1.ColumnCount - 1 do
begin
client1.Append;
client1.FieldByName('fieldName').Value:=tv1.Columns[i].DataBinding.FieldName;
client1.FieldByName('caption').Value:=tv1.Columns[i].Caption;
client1.FieldByName('ValueType').Value:=tv1.Columns[i].DataBinding.ValueType;
client1.Post;
end;
result:=client1;
end;
2024-10-12 10:45:24 +08:00
/////////////////////////////////////////////
procedure TWindowFormDeSign.setGridClick(Sender: TObject);
var
i:integer;
view:TcxGridDBTableView;
begin
view:=nil;
with TToolButton( Sender ).Parent.Parent do
begin
for i:=0 to ComponentCount-1 do
begin
if Components[i] is TcxGrid then
begin
if TcxGrid(Components[i]).IsFocused then
begin
view:= TcxGridDBTableView(TcxGrid(Components[i]).Views[0]);
end;
end;
end;
end;
//
if view<>nil then
begin
OpenGridDesignWin(view);
end
else
begin
showMessage('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>Ҫ<EFBFBD><D2AA><EFBFBD>Ƶı<C6B5><C4B1><EFBFBD>!');
end;
end;
2024-07-07 09:35:27 +08:00
end.