OVH Cloud OVH Cloud

print screen

3 réponses
Avatar
John Smith
Bonjour,

J'ai une fonction pour la prise en charge des erreurs qui affiche un msgbox.
Je voudrais prendre une print screen.
Le problème
Public Function Err_Handler(ByVal ModuleName As String, ByVal ProcName As
String, ByVal ErrorDesc As String) As Boolean

'le msgbox
MsgBox "ERREUR:" & vbNewLine & "Module: " & ModuleName & vbNewLine &
"Function: " & ProcName & vbNewLine & "Description: " & ErrorDesc,
vbCritical
'le print screen
SaveScreen readfile & "erreur.bmp"
Err_Handler = True
End Function
Si je place mon print screen je n'ai pas le msgbox dans l'image à cause que
le msgbox arrete le code...

Quelqu'un a une idée

3 réponses

Avatar
jean-marc
"John Smith" wrote in message
news:WHexf.27539$
Bonjour,

J'ai une fonction pour la prise en charge des erreurs qui affiche un


msgbox.
Je voudrais prendre une print screen.
Le problème
Public Function Err_Handler(ByVal ModuleName As String, ByVal ProcName As
String, ByVal ErrorDesc As String) As Boolean

'le msgbox
MsgBox "ERREUR:" & vbNewLine & "Module: " & ModuleName & vbNewLine &
"Function: " & ProcName & vbNewLine & "Description: " & ErrorDesc,
vbCritical
'le print screen
SaveScreen readfile & "erreur.bmp"
Err_Handler = True
End Function
Si je place mon print screen je n'ai pas le msgbox dans l'image à cause


que
le msgbox arrete le code...



Hello,

tu places un timer sur ta form (actif tous les 500 millisecondes par
exemple)
dans ce timer, tu fais un truc du genre:

' doit on faire une copie d'ecran ?
If Glob_Must_Print Then

' dormir 1 seconde,
' pour attendre la msgbox si nécessaire
Sleep (1000)

SaveScreen readfile & "erreur.bmp"

' hop, on ne le refait plus
Glob_Must_Print = False
Endif

dans ta fonction Erreur Handler, tu fais:

Glob_Must_Print = True
MsgBox "ERREUR:" & vbNewLine & "Module: " & ModuleName & vbNewLine &
"Function: " & ProcName & vbNewLine & "Description: " & ErrorDesc,
vbCritical

If Glob_Must_Print = False Then
' voila, la copie d'écran est faite.
endif

Avec Glob_Must_Print étant une variable Globale
booléenne de ta forme.

Comme ça, le tour est joué.

--
Jean-marc
Avatar
John Smith
Petit ajout
la function msgbox arrete le timer...il faut utiliser l'api
Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal
hwnd As _
Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As
Long) As Long


MessageBox me.hwnd, "Le Timer ne s'arrête pas.", "API MsgBox", vbOKOnly +
vbExclamation
avec cette fonction le print screen marche numéro 1

Merci

"jean-marc" wrote in message
news:43c64b24$0$29455$
"John Smith" wrote in message
news:WHexf.27539$
Bonjour,

J'ai une fonction pour la prise en charge des erreurs qui affiche un


msgbox.
Je voudrais prendre une print screen.
Le problème
Public Function Err_Handler(ByVal ModuleName As String, ByVal ProcName As
String, ByVal ErrorDesc As String) As Boolean

'le msgbox
MsgBox "ERREUR:" & vbNewLine & "Module: " & ModuleName & vbNewLine &
"Function: " & ProcName & vbNewLine & "Description: " & ErrorDesc,
vbCritical
'le print screen
SaveScreen readfile & "erreur.bmp"
Err_Handler = True
End Function
Si je place mon print screen je n'ai pas le msgbox dans l'image à cause


que
le msgbox arrete le code...



Hello,

tu places un timer sur ta form (actif tous les 500 millisecondes par
exemple)
dans ce timer, tu fais un truc du genre:

' doit on faire une copie d'ecran ?
If Glob_Must_Print Then

' dormir 1 seconde,
' pour attendre la msgbox si nécessaire
Sleep (1000)

SaveScreen readfile & "erreur.bmp"

' hop, on ne le refait plus
Glob_Must_Print = False
Endif

dans ta fonction Erreur Handler, tu fais:

Glob_Must_Print = True
MsgBox "ERREUR:" & vbNewLine & "Module: " & ModuleName & vbNewLine &
"Function: " & ProcName & vbNewLine & "Description: " & ErrorDesc,
vbCritical

If Glob_Must_Print = False Then
' voila, la copie d'écran est faite.
endif

Avec Glob_Must_Print étant une variable Globale
booléenne de ta forme.

Comme ça, le tour est joué.

--
Jean-marc




Avatar
Jean-Marc
Merci de la précision John!

--
Jean-marc
Tester mon serveur (VB6) => http://myjmnhome.dyndns.org
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;


"John Smith" a écrit dans le message de
news:MBsxf.28646$
Petit ajout
la function msgbox arrete le timer...il faut utiliser l'api
Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA"


(ByVal
hwnd As _
Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType


As
Long) As Long


MessageBox me.hwnd, "Le Timer ne s'arrête pas.", "API MsgBox",


vbOKOnly +
vbExclamation
avec cette fonction le print screen marche numéro 1

Merci

"jean-marc" wrote in message
news:43c64b24$0$29455$
> "John Smith" wrote in message
> news:WHexf.27539$
>> Bonjour,
>>
>> J'ai une fonction pour la prise en charge des erreurs qui affiche


un
> msgbox.
>> Je voudrais prendre une print screen.
>> Le problème
>> Public Function Err_Handler(ByVal ModuleName As String, ByVal


ProcName As
>> String, ByVal ErrorDesc As String) As Boolean
>>
>> 'le msgbox
>> MsgBox "ERREUR:" & vbNewLine & "Module: " & ModuleName & vbNewLine


&
>> "Function: " & ProcName & vbNewLine & "Description: " & ErrorDesc,
>> vbCritical
>> 'le print screen
>> SaveScreen readfile & "erreur.bmp"
>> Err_Handler = True
>> End Function
>> Si je place mon print screen je n'ai pas le msgbox dans l'image à


cause
> que
>> le msgbox arrete le code...
>
> Hello,
>
> tu places un timer sur ta form (actif tous les 500 millisecondes par
> exemple)
> dans ce timer, tu fais un truc du genre:
>
> ' doit on faire une copie d'ecran ?
> If Glob_Must_Print Then
>
> ' dormir 1 seconde,
> ' pour attendre la msgbox si nécessaire
> Sleep (1000)
>
> SaveScreen readfile & "erreur.bmp"
>
> ' hop, on ne le refait plus
> Glob_Must_Print = False
> Endif
>
> dans ta fonction Erreur Handler, tu fais:
>
> Glob_Must_Print = True
> MsgBox "ERREUR:" & vbNewLine & "Module: " & ModuleName &


vbNewLine &
> "Function: " & ProcName & vbNewLine & "Description: " &


ErrorDesc,
> vbCritical
>
> If Glob_Must_Print = False Then
> ' voila, la copie d'écran est faite.
> endif
>
> Avec Glob_Must_Print étant une variable Globale
> booléenne de ta forme.
>
> Comme ça, le tour est joué.
>
> --
> Jean-marc
>
>