Bonjour,
j'essaie de dessiner à main levée sur un TPanel :
Je vois le dessin apparaître quand le TPanel perd le focus. Je ne vois pas où est le problème. Une suggestion peut-être ?
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 var Form1: TForm1; Brush : TStrokeBrush; MousePos : TPointF; bFlagDraw : Boolean; [...] procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); begin bFlagDraw := False; end; procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); var MouseService: IFMXMouseService; begin bFlagDraw := False; with Canvas do begin if TPlatformServices.Current.SupportsPlatformService(IFMXMouseService, IInterface(MouseService)) then begin //On initialise la position de la souris MousePos := MouseService.GetMousePos; bFlagDraw := True; end; end; end; procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); var MouseService: IFMXMouseService; begin if ssLeft in Shift then begin if bFlagDraw then begin Brush := TStrokeBrush.Create(TBrushKind.Solid, TAlphaColors.Black); Brush.Thickness:= 2; if TPlatformServices.Current.SupportsPlatformService(IFMXMouseService, IInterface(MouseService)) then begin with Canvas do begin BeginScene; DrawLine(MousePos, MouseService.GetMousePos, 1, Brush); EndScene; //On réinitialise la position de la souris MousePos := MouseService.GetMousePos; end; end; end; end else if bFlagDraw then bFlagDraw := false; end;
Merci. Gilles
Partager