unit ucadIndices; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Buttons, System.UITypes, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, umstCadastro, Data.DB, Vcl.Grids, Vcl.DBGrids, Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.StdCtrls, Vcl.Mask, Vcl.ComCtrls, System.ImageList, Vcl.ImgList, ZAbstractRODataset, ZAbstractDataset, ZDataset; type THackDBNavigator = class(TDBNavigator); type TcadIndices = class(TmstCadastro) dbgrd_indices: TDBGrid; ImageList1: TImageList; GroupBox1: TGroupBox; dblulb_indices: TDBLookupListBox; procedure FormCreate(Sender: TObject); procedure dtsDBStateChange(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure dbgrd_indicesTitleClick(Column: TColumn); private procedure SetupHackedNavigator(const Navigator: TDBNavigator; const Glyphs: TImageList; S: string); procedure WMMoving(var Msg: TWMMoving); message WM_MOVING; { Private declarations } public { Public declarations } end; var cadIndices: TcadIndices; implementation {$R *.dfm} uses udtmSystem; procedure TcadIndices.dbgrd_indicesTitleClick(Column: TColumn); begin inherited; dtmSystem.OrganizaPorColuna(dbgrd_indices.DataSource.DataSet,Column); end; procedure TcadIndices.dtsDBStateChange(Sender: TObject); begin inherited; dblulb_indices.Enabled := not (dtsDB.DataSet.State in [dsEdit,dsInsert]); end; procedure TcadIndices.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; cadIndices := nil; end; procedure TcadIndices.FormCreate(Sender: TObject); begin inherited; SetupHackedNavigator(navPrincipal, ImageList1, 's'); end; procedure TcadIndices.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin inherited; if Key = VK_ESCAPE then begin Key := 0; Close; end; end; procedure TcadIndices.SetupHackedNavigator(const Navigator: TDBNavigator; const Glyphs: TImageList; S: string); const Captions: array [TNavigateBtn] of string = ('Primeiro', 'Anterior', 'Próximo', 'Último', 'Adicionar', 'Excluir', 'Alterar', 'Confirmar', 'Cancelar', 'Atualizar', 'Aplicar Atualizações', 'Cancelar Atualizãções'); (* Captions : array[TNavigateBtn] of string = ('First', 'Prior', 'Next', 'Last', 'Insert', 'Delete', 'Edit', 'Post', 'Cancel', 'Refresh'); *) Hints: array [TNavigateBtn] of string = ('Primeiro', 'Anterior', 'Próximo', 'Último', 'Adicionar', 'Apagar', 'Modificar', 'Confirmar', 'Cancelar', 'Atualizar', 'Aplicar Atualizações', 'Cancelar Atualizãções'); var btn: TNavigateBtn; begin // função propriamente dita para "hackear" o navigator for btn := Low(TNavigateBtn) to High(TNavigateBtn) do with THackDBNavigator(Navigator).Buttons[btn] do begin // from the Captions const array Hint := Hints[btn]; if S = 's' then begin Caption := Captions[btn]; end; // the number of images in the Glyph property NumGlyphs := 1; // Remove the old glyph. Glyph := nil; // Assign the custom one Glyphs.GetBitmap(Integer(btn), Glyph); // gylph above text Layout := blGlyphTop; Font.Style := Font.Style - [fsbold]; end; end; procedure TcadIndices.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.