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,dxSkinsCore, dxSkinWXI,dxSkinsDefaultPainters, cxCustomData, cxClasses, cxTimeEdit, cxEdit, cxLookAndFeels,dxLayoutControl, cxLookAndFeelPainters, cxGridCustomView, Buttons, cxDropDownEdit,FrameDateSel; 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); 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); function getColumnRelation(tv1:TcxGridDBTableView):TclientDataSet; procedure cxGridViewCustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean); public function FormStyleInit(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean; procedure QueryDataPlus(ADOTmp: TADOQuery); //function IsHasDesignRight(ADOTmp: TADOQuery): boolean; end; const // panel背景 clPanelBack = TColor($00FAF8F7); clToolBarBack = TColor($00FAF8F7); // 窗口背景色 clFormBack = TColor($00FAF8F7); implementation uses U_DataLink, U_globalVar,U_cxGridCustomSet,U_FormLayOutDesign; /// ////////////////////////////////////////////////////// // 窗口样式,其它界面信息设置; /// ////////////////////////////////////////////////////// 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; begin ADOQueryCmd := ADOQCmd; ADOQueryTmp := ADOTmp; fDllName := gDllFileName; fFormName := Tform(mForm).name; fFormId := mFormId; gIsCanDesign :=IsHasDesignRight(ADOTmp,PWideChar(dCode)) ; if trim(mStyleCode) = '' then mStyleCode := '01'; if gFontSize>=9 then begin fFontSize:= gFontSize ; end else begin fFontSize:= getSystemFontSize(ADOTmp,PWideChar(mStyleCode)); if fFontSize < 9 then fFontSize := 12; gFontSize:=fFontSize; end; mForm.Font.Size := fFontSize; // 窗口背景色 try for i := 0 to mForm.ComponentCount - 1 do begin if not(mForm.Components[i] is Twincontrol) then begin continue; end; // if (fFontSize > 9) then // begin if (mForm.Components[i] is Tlabel) or (mForm.Components[i] is Tcxlabel) then begin // mForm.Components[i] is TfrmFrameDateSel //if (mForm.Components[i].Tag<>10) and (Tlabel(mForm.Components[i]).Font.Size<>fFontSize) then // Tlabel(mForm.Components[i]).Font.Size:= fFontSize ; // if Tlabel(mForm.Components[i]).Left >= fFontSize then // Tlabel(mForm.Components[i]).Left := Tlabel(mForm.Components[i]).Left - fFontSize; continue; end; if mForm.Components[i] is TcxTextEdit then begin if (mForm.Components[i].Tag<999) and not TcxTextEdit(mForm.Components[i]).ParentFont then TcxTextEdit(mForm.Components[i]).ParentFont:=True; continue; end; if (mForm.Components[i] is TcxComboBox) then begin if (mForm.Components[i].Tag<999) and not TcxComboBox(mForm.Components[i]).ParentFont then 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 TcxButtonEdit(mForm.Components[i]).ParentFont:=True; continue; end; if mForm.Components[i] is TcxdateEdit then begin if mForm.Components[i].Tag<999 then TcxdateEdit(mForm.Components[i]).ParentFont:=True; continue; 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; continue; end; if mForm.Components[i] is TcxMemo then begin if mForm.Components[i].Tag<999 then TcxMemo(mForm.Components[i]).ParentFont:=True; continue; end; // Tcxgroup if mForm.Components[i] is TcxgroupBox then begin if mForm.Components[i].Tag<999 then TcxgroupBox(mForm.Components[i]).ParentFont:=True; if mIsCustomBackColor then TcxgroupBox(mForm.Components[i]).Color := clPanelBack; TcxgroupBox(mForm.Components[i]).Ctl3D := mCtl3D; mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + TcxgroupBox(mForm.Components[i]).name; continue; end; if mForm.Components[i] is TToolBar then begin if mForm.Components[i].Tag<999 then TToolBar(mForm.Components[i]).ParentFont:=True; TToolBar(mForm.Components[i]).AutoSize := true; TToolBar(mForm.Components[i]).Flat := true; 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(application,TToolBar(mForm.Components[i]), PWideChar(mRightCaptions)); 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 if mForm.Components[i].Tag<999 then TdxLayoutControl(mForm.Components[i]).ParentFont:=true; if mForm.Components[i].Tag<>1000 then begin TdxLayoutControl(mForm.Components[i]).OnDblClick := dxLayoutControl1DblClick ; readLayOut(TdxLayoutControl(mForm.Components[i]),ADOTmp,PWideChar( fDllFileName+'|'+mForm.name+'|'+TdxLayoutControl(mForm.Components[i]).Name+'.ini')); 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; mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + Tpanel(mForm.Components[i]).name; continue; end; // Tpanel 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; 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; // 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; TcxGrid(mForm.Components[i]).LookAndFeel.ScrollbarMode := sbmClassic; //自动响应过滤 TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).dataController.filter.AutoDataSetFilter := true; //if mForm.Components[i].Tag < 99 then // SetCxGridColumnBestWidth(TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0])); TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).OnKeyDown := cxGridViewKeyDown; 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(application, TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]),ADOQueryTmp,PWideChar(mdesignCode)); continue; end; end; except showMessage('窗口初始化异常!'); end; end; /// //////////////////////////////////////////////////////////////////// // 保存窗口表格列的原始信息 /// /////////////////////////////////////////////////////////////////////// //function TWindowFormDeSign.SaveFormGridInfo(mCxGridView: TcxGridDBTableView; ADOCmd: TADOQuery; mdesignCode: string; mGridName: string; mGridType: integer): boolean; //var // i: integer; // mfieldName: string; //begin // result := false; // try // /// //////////////// // /// //////////////// // with ADOQueryCmd do // begin // close; // sql.Clear; // sql.Add('select * from SD_FormGrid_Main A'); // sql.Add('where A.designCode=' + quotedStr(mdesignCode)); // open; // if RecordCount <= 0 then // begin // append; // fieldByName('designCode').value := mdesignCode; // fieldByName('GridType').value := mGridType; // fieldByName('gridName').value := TcxGrid(TcxGridLevel(mCxGridView.level).Control).name; // end // else // edit; // // fieldByName('ProcedureParam').value := ''; // fieldByName('newProcedureName').value := ''; // post; // // close; // // end; // // 子信息 // with ADOCmd do // begin // close; // sql.Clear; // sql.Add('select * from SD_FormGrid_Design'); // sql.Add('where designCode=' + quotedStr(mdesignCode)); // sql.Add('and formId=' + intTostr(fFormId)); // sql.Add('and formName=' + quotedStr(fFormName)); // // sql.Add('and GridName='+QuotedStr(mgridName)); // open; // // for i := mCxGridView.ColumnCount - 1 downto 0 do // begin // mfieldName := TcxGridDBColumn(mCxGridView.Columns[i]).DataBinding.FieldName; // // if locate('fieldName', mfieldName, []) then // begin // continue; // end // else // begin // append; // fieldByName('Id').value := GetMaxId(); // fieldByName('formId').value := fFormId; // fieldByName('formName').value := fFormName; // fieldByName('designCode').value := mdesignCode; // fieldByName('GridName').value := mGridName; // // fieldByName('ColumnName').value := mCxGridView.Columns[i].name; // fieldByName('Visible').value := mCxGridView.Columns[i].Visible; // fieldByName('ColumnHide').value := mCxGridView.Columns[i].Hidden; // fieldByName('oldCaption').value := mCxGridView.Columns[i].Caption; // fieldByName('Valid').value := 1; // end; // // fieldByName('GridIndex').value := mGridType; // fieldByName('FieldName').value := trim(TcxGridDBColumn(mCxGridView.Columns[i]).DataBinding.FieldName); // fieldByName('Caption').value := mCxGridView.Columns[i].Caption; // fieldByName('ColumnType').value := trim(TcxGridDBColumn(mCxGridView.Columns[i]).DataBinding.ValueType); // // fieldByName('Width').value := mCxGridView.Columns[i].Width; // fieldByName('IsOrder').value := 1; // fieldByName('ColumnFilter').value := mCxGridView.Columns[i].Filtered; // fieldByName('ColumnOrder').value := mCxGridView.Columns[i].Index; // if mCxGridView.Columns[i].FixedKind= fkLeftDynamic then // begin // fieldByName('fixColumn').value := True; // end // else // begin // fieldByName('fixColumn').value := false; // end; // post; // end; // // close; // end; // // /// ///////////////////////////////////////////// // // // for i := 0 to mCxGridView.dataController.DataSet.FieldCount - 1 do // begin // mfieldName := trim(mCxGridView.dataController.DataSet.Fields[i].FieldName); // if mfieldName = '' then // continue; // with ADOCmd do // begin // close; // sql.Clear; // sql.Add('select * from SD_FormGrid_Design'); // sql.Add('where designCode=' + quotedStr(mdesignCode)); // // sql.Add('and GridName='+QuotedStr(mgridName)); // sql.Add('and fieldName=' + quotedStr(mfieldName)); // open; // if RecordCount <= 0 then // begin // append; // fieldByName('Id').value := GetMaxId(); // fieldByName('formName').value := fFormName; // fieldByName('formId').value := fFormId; // fieldByName('GridName').value := mGridName; // fieldByName('GridIndex').value := mGridType; // fieldByName('designCode').value := mdesignCode; // // fieldByName('fieldName').value := mfieldName; // // fieldByName('ColumnType').value := mCxGridView.dataController.DataSet.Fields[i].DataType; // fieldByName('Caption').value := '未启用'; // fieldByName('ColumnName').value := mCxGridView.name + mfieldName; // fieldByName('Visible').value := false; // fieldByName('AddFlag').value := true; // // fieldByName('Width').value := 60; // fieldByName('ColumnOrder').value := 99; // // fieldByName('Valid').value := 0; // post; // end; // close; // end; // end; // result := true; // except // application.MessageBox('保存窗口表格信息时发生错误', '提示信息', 0); // end; //end; /// ///////////////////////////////////////////////// // /// /////////////////////////////////////////////////// /// //////////////////////////////////////////////////////////////// // 初始化控件的默认数据 设置了取数SQL的控件 /// //////////////////////////////////////////////////////////////// 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('初始化控件数据时发生错误!', '提示信息', 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; /// //////////////////////////////////////////////////////////////// // 打开表格设计窗口 // 0: mGridType 查询; 1:输入 /// ///////////////////////////////////////////////////////////////// procedure TWindowFormDeSign.OpenGridDesignWin(mCxGridView: TcxGridDBTableView); type TMyFunc = function(App: Tapplication; FormH: hwnd; FormID: integer; UID: pchar; UName: pchar; dataBase: pchar; Title: pchar; Parameters1: pchar; Parameters2: pchar): hwnd; stdcall; var Tf: TMyFunc; Tp: TFarProc; Th: Thandle; newh: hwnd; mGridType: integer; mdesignCode: string; mGridName: string; k: integer; client1:TClientDataSet; begin /// //////////////////////////////////// // 权限控制 mdesignCode := fFormName + '|' + intTostr(fFormId) + '|' + mCxGridView.name; mGridName := TcxGrid(TcxGridLevel(mCxGridView.level).Control).name; if not IsHasDesignRight(ADOQueryCmd,PWideChar(dcode)) then exit; ShowCxGridDesign(application, mCxGridView, getColumnRelation(mCxGridView),AdOQueryCmd,PWideChar(fFormName) ,PWideChar(mGridName),PWideChar(fDllFileName),fformId,0); CreateCxGridColumn(application, mCxGridView,ADOQueryTmp,PWideChar(mdesignCode)); 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; /// ////////////////////////////////////////////////////////////// // 设置toolbar按钮权限参数 /// ////////////////////////////////////////////////////////////// //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 = '关闭') or (mCaption = '退出') or (mCaption = '放弃') then // exit; // /// ////////////////////////// // if trim(mOperRight) = '查询' then // begin // if pos(mCaption, '查询,刷新,过滤,高级过滤,高级查询') > 0 then // ,查看,详细 // 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, '查询,刷新,过滤,高级过滤,高级查询') > 0) then // 查看, // begin // TToolBar(mParent).Buttons[i].Visible := true; // end // else // begin // TToolBar(mParent).Buttons[i].Visible := false; // end; // end; // end; // exit; // end; // /// //////////////////////////////////////////////// // if trim(mOperRight) = '查询' 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 = '查询') or (mCaption = '过滤') or (mCaption = '高级过滤') then // begin // Controls[i].Visible := true; // end // else // Controls[i].Visible := false; // end; // end; // end; // // except // application.MessageBox('初始化窗口按钮权限发生错误', '警告信息', 0); // end; //end; /// //////////////////////////////////////////////////////////// // /// //////////////////////////////////////////////////////////// function TWindowFormDeSign.getChgDefaultValue(mValue: string): string; begin if '$$USERNAME' = mValue then begin result := DName; end else result := mValue; end; /// //////////////////////////////////////////////////// // 查询数据增强 /// ///////////////////////////////////////////////////// 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 //这个if段是为了在行号处把把选中的行号跟别的区分开,可不用 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; end.