Bonjour
J'ai un TFrame dans le quel je place une TDBGrid.
Ce TFrame est posé sur un TForm.
Dans le code du Tframe, j'ajoute :
J'exécute mon programme, je clique sur le titre de la première colonne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 type TDBGrid = class(Vcl.DBGrids.TDBGrid) procedure TitleClick(Column: TColumn);override; end; TFrame4 = class(TFrame) DBGrid1: TDBGrid; end; implementation {$R *.dfm} procedure TDBGrid.TitleClick(Column: TColumn); var W: TWinControl; FromForm, FromFrame: Boolean; FrameName, FormName, FrameUnit, FormUnit: string; begin inherited; FromForm := False; FrameName := '?'; FormName := '?'; FrameUnit := '?'; FormUnit := '?'; W := Self.Parent; while not FromForm do begin FromFrame := W.InheritsFrom(TFrame); FromForm := W.InheritsFrom(TForm); if FromFrame then begin FrameUnit := TFrame(W).UnitName; FrameName := TFrame(W).Name; end; if FromForm then begin FormUnit := TForm(W).UnitName; FormName := TForm(W).Name; end; W := W.Parent; end; ShowMessageFmt('%s -> %s === %s -> %s', [FormUnit, FormName, FrameUnit, FrameName]); end;
[Window Title]
Project2
[Content]
Unit3 -> Form3 === Unit4 -> Frame41
[OK]
Youpi !
Sauf que ....
Je crée un nouveau fichier UDBGrid dans lequel je déplace le code additionnel et j'y fais référence dans mon TFrame.
A la compilation, Delphi qu'il ne peut pas compiler parce qu'il n'a pas le DFM.
Si j'enlève le fichier du projet et que je demande à le rajouter, j'obtiens la même erreur :
[Window Title]
Erreur
[Content]
Erreur à la création de la fiche : Impossible d'ouvrir le fichier "C:\Classes\UDBGrid.dfm". Le fichier spécifié est introuvable.
[OK]
Voilà le code du fichier
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 unit UDBGrid; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.DBGrids; type TDBGrid = class(Vcl.DBGrids.TDBGrid) procedure TitleClick(Column: TColumn);override; end; implementation {$R *.dfm} { TDBGrid } procedure TDBGrid.TitleClick(Column: TColumn); var W: TWinControl; FromForm, FromFrame: Boolean; FrameName, FormName, FrameUnit, FormUnit: string; begin inherited; FromForm := False; FrameName := '?'; FormName := '?'; FrameUnit := '?'; FormUnit := '?'; W := Self.Parent; while not FromForm do begin FromFrame := W.InheritsFrom(TFrame); FromForm := W.InheritsFrom(TForm); if FromFrame then begin FrameUnit := TFrame(W).UnitName; FrameName := TFrame(W).Name; end; if FromForm then begin FormUnit := TForm(W).UnitName; FormName := TForm(W).Name; end; W := W.Parent; end; ShowMessageFmt('%s -> %s === %s -> %s', [FormUnit, FormName, FrameUnit, FrameName]); end; end.
Je ne vois pas pourquoi il me réclame un DFM :-(
Si c'est visible et que j'ai rien vu, merci de votre coup d'oeil avisé :-)
Partager