begin process at 2010 02 10 12:24:53
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Modules

 > ENREGISTRER L'IMAGE D'UN CONTRÔLE

ENREGISTRER L'IMAGE D'UN CONTRÔLE


 Information sur la source

Note :
Aucune note
Catégorie :Modules Classé sous :contrôle, image, ecran, position Niveau :Débutant Date de création :09/02/2008 Vu / téléchargé :5 242 / 324

Auteur : debutant VB

Ecrire un message privé
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Cette fonction enregistre l'image d'un contrôle
(bouton, Label, MSChart ...) dans un fichier image.
J'ai fait ce script à partir d'une question sur le forum :
http://www.vbfrance.com/infomsg_EXPORTER-GRAPHE- VERS-BITMAP_1072372.aspx#1
J'ai apporté quelques modifications à mon ancien code.
La fonction localise l'objet par rapport au bord de l'écran,
et fait une capture d'écran du contrôle,
qui peut être n'importe quoi pourvu qu'il ait les
propriétés .Width, .Height, .Left et .Top qui permettent
de le localiser.

Source

  • Option Explicit
  • Private Declare Function BitBlt Lib "gdi32.dll" ( _
  • ByVal hDestDC As Long, _
  • ByVal x As Long, _
  • ByVal y As Long, _
  • ByVal nWidth As Long, _
  • ByVal nHeight As Long, _
  • ByVal hSrcDC As Long, _
  • ByVal xSrc As Long, _
  • ByVal ySrc As Long, _
  • ByVal dwRop As Long) As Long
  • Private Declare Function GetDesktopWindow Lib _
  • "user32.dll" () As Long
  • Private Declare Function GetDC Lib "user32.dll" ( _
  • ByVal hWnd As Long) As Long
  • Private Const SRCCOPY As Long = &HCC0020
  • Public Sub SaveMSChart(ByRef Pic As PictureBox, _
  • ByRef mform As Form, ByVal mObj As Object, _
  • ByVal mFileName As String)
  • Pic.Visible = False
  • Pic.AutoRedraw = True
  • Pic.Cls
  • mform.ScaleMode = vbTwips
  • Dim Temp As Double
  • Dim XU As Double, YU As Double
  • Dim XD As Double, YD As Double
  • Temp = (mform.Width - mform.ScaleWidth) / 2
  • XU = mform.Left + Temp + mObj.Left
  • YU = mform.Top + (mform.Height - mform.ScaleHeight) - _
  • Temp + mObj.Top
  • XD = XU + mObj.Width
  • YD = YU + mObj.Height
  • Pic.Width = (XD - XU)
  • Pic.Height = (YD - YU)
  • XU = XU / Screen.TwipsPerPixelX
  • YU = YU / Screen.TwipsPerPixelY
  • XD = XD / Screen.TwipsPerPixelX
  • YD = YD / Screen.TwipsPerPixelY
  • BitBlt Pic.hDC, 0&, 0&, Screen.Width, _
  • Screen.Height, GetDC(GetDesktopWindow()), _
  • CLng(XU), CLng(YU), SRCCOPY
  • SavePicture Pic.Image, mFileName
  • End Sub
Option Explicit

Private Declare Function BitBlt Lib "gdi32.dll" ( _
        ByVal hDestDC As Long, _
        ByVal x As Long, _
        ByVal y As Long, _
        ByVal nWidth As Long, _
        ByVal nHeight As Long, _
        ByVal hSrcDC As Long, _
        ByVal xSrc As Long, _
        ByVal ySrc As Long, _
        ByVal dwRop As Long) As Long

Private Declare Function GetDesktopWindow Lib _
        "user32.dll" () As Long

Private Declare Function GetDC Lib "user32.dll" ( _
        ByVal hWnd As Long) As Long

Private Const SRCCOPY As Long = &HCC0020

Public Sub SaveMSChart(ByRef Pic As PictureBox, _
        ByRef mform As Form, ByVal mObj As Object, _
        ByVal mFileName As String)
    Pic.Visible = False
    Pic.AutoRedraw = True
    Pic.Cls
    mform.ScaleMode = vbTwips
    Dim Temp As Double
    Dim XU As Double, YU As Double
    Dim XD As Double, YD As Double
    Temp = (mform.Width - mform.ScaleWidth) / 2
    XU = mform.Left + Temp + mObj.Left
    YU = mform.Top + (mform.Height - mform.ScaleHeight) - _
            Temp + mObj.Top
    XD = XU + mObj.Width
    YD = YU + mObj.Height
    Pic.Width = (XD - XU)
    Pic.Height = (YD - YU)
    XU = XU / Screen.TwipsPerPixelX
    YU = YU / Screen.TwipsPerPixelY
    XD = XD / Screen.TwipsPerPixelX
    YD = YD / Screen.TwipsPerPixelY
    BitBlt Pic.hDC, 0&, 0&, Screen.Width, _
            Screen.Height, GetDC(GetDesktopWindow()), _
            CLng(XU), CLng(YU), SRCCOPY
    SavePicture Pic.Image, mFileName
End Sub


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source avec Zip Source avec une capture EDITEUR DE FICHIERS .X (DIRECTX) 3D
Source avec Zip MSN DÉGRADÉS DE COULEURS
Source avec Zip Source avec une capture COURBE PASSANT PAR DES POINTS DÉFINIS
Source avec Zip Source avec une capture PETIT LABYRINTHE

 Sources de la même categorie

GÉNÉRATEUR DE MAIL LOTUS NOTES AVEC MISE EN FORME VIA UNE SY... par 8Tnerolf8
Source avec Zip Source avec une capture VB6 ADDIN - FAITES DISPARAITRE LES MSGBOX D'ERREUR IDE par EBArtSoft
MODULE DE COMMUNICATION ENTRE APPLICATION par PROTEUS91
REGISTRE WINDOWS par Duke49
Source avec Zip Source avec une capture LECTURE / ÉCRITURE SUR LE PORT PARALLÈLE FACILEMENT AVEC INP... par Moritus

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture PROGRAMME DE DESSIN À LA SOURIS AVEC OUVERTURE ET ENREGISTRE... par SnkVrt
Source avec Zip Source avec une capture ÉCRIRE SUR LE WALLPAPER par Rafale71
Source avec Zip Source avec une capture GESTION DE LA POSITION DE LA SOURIS par Dav76df
Source avec Zip CHANGER RÉGULIÈREMENT LE FOND D'ÉCAN par bb
POSITION DE N'IMPORTE QUEL CONTROLE CORRIGE par CodeCodeCodac

Commentaires et avis

Commentaire de Renfield le 12/02/2008 15:37:06 administrateur CS

XU / Screen.TwipsPerPixelX

pas top ce genre de chose... part du principe que l'on est en Twips

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Créer un contrôle image dynamiquement [ par Fred ] Salut,je voudrais faire un gestionnaire d'albums photos. Sachant qu'un album peut contenir un nombre d'images indéfini, il me faut créer (et afficher) Image <-> Contrôle [ par Loulou ] Comment je peux lier une image dans ma base de donnée avec un controle. ( par exemple une picturebox ou une imagelist ) ?Je remercie d'avance celui qu Comment imprimer l'image d'1 contrôle ShockwaveFlash ?? [ par Remy75 ] Pour les besoins de mon appli, j'ai ajouté un contrôle pour afficher des images Flash (.swf).A l'écran, tout se passe bien, mais impossible de trouver Image de fond dans un contrôle RTF [ par Sreizine ] Quelqu'un aurait-il une idée pour placer une image au fond d'un contrôle RTF? Image de fond dans un contrôle RTF [ par Sreizine ] Quelqu'un aurait-il une idée pour placer une image au fond d'un controle RTF? inserez image dans un contrôle [ par maje ] Bonjour,Comment pourrait-on faire pour créer un bouton qui permette d'inserez une image dans une controle ?Ex: renseignement sur une société, l'utilis Instancier un contrôle image ? [ par Surfurax ] Salut, Je voudrais savoir si il est possible de dupliquer un nombre n de fois un contrôle de type image; je sais que c'est possible de le faire avec position fenetre getOpenFilename [ par phileas ] Bonjour,Dans mon code VB6 j'utilise la commande application.getOpenFilename pour faire apparaitre la fenetre de selection d'un fichier. Probleme la fe Afficher une image dans un contrôle RichTextBox [ par FredBrunet ] Comment faire par programmation pour afficher une image dans un contrôle RichTextBox ? Position d'un contrôle en pixels [ par benedict ] Comment déterminer les coordonnées X et Y d'un contrôle en pixels par rapport à l'écran (ou à la feuille) ?Merci de votre aide.Benedict<img src=/imgs2


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,827 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales