3) Empiler la forme ou le contrôle de l'image
Prenez une image de formulaire ou de contrôle, c'est-à-dire pour utiliser un nouveau formulaire2, voir "Delphi Image Intercept Programming Exemple (7)"
Ajoutez Capture2 dans les utilisations de l'implémentation de l'unité principale.
[Capture Windows ou Controls] Événement d'action pour un formulaire ou une capture de contrôle
Procédure tmainform.cptwindowSexecute (expéditeur: tobject);
var p: tpoint; manche: hwnd;
Commencer
Inc (capturénum, 1);
application.minimize;
Retard (500);
FileName: = 'Capture' + intToStr (CaptureNum);
FileName: = DefaultDirectory + FileName;
avec tform2.create (application) faire
essayer
Si showmodal = MROK alors
Commencer
CreateMdichild (nom de fichier, true);
Statusbar.simpletext: = nom de fichier;
Retard (500);
Abitmap: = tbitmap.create;
GetCursorpos (P);
Poignées: = windowFRompIval (p);
Abitmap: = capturewindowImage (poignées);
Child.image1.picture.bitmap: = abitmap;
Child.clientwidth: = child.image1.picture.width;
Child.clientheight: = child.image1.picture.height;
Child.horzscrollbar.range: = child.image1.picture.width;
Child.vertscrollbar.range: = child.image1.picture.height;
Child.image1.hint: = 'hauteur:' + inttoStr (child.image1.picture.height) + 'pixels'
+ 'Largeur:' + intToStr (child.image1.picture.width) + 'pixels';
Abitmap.free;
fin;
Enfin
Gratuit;
Application.Restore;
fin;
fin;
4) Pictures d'icône de crawl
Prenez une image d'icône, c'est-à-dire pour utiliser un nouveau formulaire3, voir "Delphi Image Intercept Programming Exemple (8)"
Ajoutez Capture3 dans les utilisations de l'implémentation de l'unité principale.
Ajouter le processus privé CaptureIcon dans l'unité principale:
procédure tmainform.captureicon;
Commencer
avec tform3.create (application) faire
essayer
Si showmodal = MROK alors
avec Frect commence
si (droite> gauche) et (en bas> en haut) alors commencez
Retard (300);
Abitmap: = tbitmap.create;
Abitmap.assign (capturesCreenRect (Frect));
Child.image1.picture.bitmap: = abitmap;
Child.horzscrollbar.range: = child.image1.picture.width;
Child.vertscrollbar.range: = child.image1.picture.height;
Abitmap.free;
fin d'autre commence
Messagedlg ('Erreur de sélection des bordures, réessayez!', MTinformation, [MBOK], 0);
Child.close;
Form3.Free;
sortie;
fin;
fin;
Enfin
Gratuit;
fin;
fin;
[Icône de capture] Événement d'action pour les images de capture d'icônes
procédure tmainform.cptiConExECUTE (expéditeur: tobject);
Commencer
Application.minimize;
Retard (400);
Inc (capturénum, 1);
FileName: = 'Capture' + intToStr (CaptureNum);
FileName: = DefaultDirectory + FileName;
CreateMdichild (nom de fichier, true);
Statusbar.simpletext: = nom de fichier;
Captureicon;
Child.clientwidth: = child.image1.picture.width;
Child.clientheight: = child.image1.picture.height;
Child.horzscrollbar.range: = child.image1.picture.width;
Child.vertscrollbar.range: = child.image1.picture.height;
Child.image1.hint: = 'hauteur:' + inttoStr (child.image1.picture.height) + 'pixels'
+ 'Largeur:' + intToStr (child.image1.picture.width) + 'pixels';
Application.Restore;
fin;