Bonjour,
J'ai besoin d'augmenter la taille d'un TPublicGraphicControl(imageFond) dont j'utilise le canvas comme Avant-Plan pour y tracer des trucs éphémères par dessus ce que je trace sur l'Arrière Plan constitué par imageFond.Picture.Bitmap et je galère après avoir essayé en vain de multiples ruses dont voici le code d'une des tentatives :
Le résultat obtenu avec ce code permet seulement de tracer dans la zone agrandie de l'arrière-plan c.à.d sur le Bmp de imageFond.Picture.Bitmap (la zone Client de la ScrollBox1 et l'image du fond s'agrandissent)
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 procedure TfrmGen.bOKNouvelleImageClick(Sender: TObject); var Bmp: TBitMap; W, H: integer; begin Bmp := TBitMap.Create; clFond := plCoulFond.Color; clFond := plCoulFond.Color; W := StrToIntDef(labedLargeurImage.text, 100); H := StrToIntDef(labedHauteurImage.text, 100); ScrollBox1.Align := alNone; ImageFond.Align := alClient; with ScrollBox1 do begin Width := W; Height := H; end; Bmp := TBitMap.Create; with Bmp do begin Width := W; Height := H; end; EffacerBmp(Bmp, clFond); ImageFond.Picture.Bitmap.Assign(Bmp); if TPublicGraphicControl(imageFond).CanResize(W, H) then begin ShowMessage('CanResize = True'); // ce ShowMessage s'affiche donc le CanResize est d'accord pour un redimensionnement //TPublicGraphicControl(imageFond).AdjustSize; // <- Ne marche pas !!! TPublicGraphicControl(imageFond).ConstrainedResize(W, H, W, H); // <- Ne marche pas non plus !!! ??? EffacerBmp(Bmp, clTranspa); CanAvP := TPublicGraphicControl(imageFond).Canvas; CopyBmpToCanvas(Bmp, CanAvP); end; ImageFond.Repaint; plNouvelleImage.Visible := False; Bmp.Free; end;
Mais la taille du Canvas d'avant-plan (CanAvP := TPublicGraphicControl(imageFond).Canvas) reste inchangée et égale à celle que le TImage imageFond avait lors du FormShow de la fiche qui occupe le plein écran.
Comment forcer l'agrandissement du Canvas d'avant-plan ??? S.V.P
A+.
Partager