Comment detecter la fermeture d'une fenetre crystal report?

vblover Messages postés 57 Date d'inscription mardi 25 février 2003 Statut Membre Dernière intervention 27 janvier 2011 - 9 juin 2006 à 17:54
vblover Messages postés 57 Date d'inscription mardi 25 février 2003 Statut Membre Dernière intervention 27 janvier 2011 - 17 juin 2006 à 21:36
Quelqu'un peut il m'indiquer comment detecter la fermeture d'une fenetre de crystal report?
En effet j'imprime un document rpt dans une loop, mais je ne voudrais pas que la boucle s'execute avant que l'utilisateur n'ait fermé la fenetre.
Merci

vblover

2 réponses

vblover Messages postés 57 Date d'inscription mardi 25 février 2003 Statut Membre Dernière intervention 27 janvier 2011
17 juin 2006 à 21:36
Declaration à ajouter à l’entete de votre programme principal



Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long<?xml:namespace prefix o ns "urn:schemas-microsoft-com:office:office" /?>





Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long,   ByVal lpClassName As String,  ByVal nMaxCount As Long) As Long





Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long





Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long,






                                                        lpdwProcessId As Long) As Long





Declare Function SendMessageArray Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long,  ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long





 





Public Const LB_SETTABSTOPS = &H192





Public Const MAX_PATH = 260




Public ProcessName(500) As String


Public ProcessItemNumber As Integer


 


 


 


 


 


 


 


Ajouter ces functions  dans un module de functions définies par l’utlisateur



Public Function IsCrystalReportActive() As Boolean





Dim index As Integer





Dim TexteRecherche As String





Dim Trouve As Boolean





 






    TexteRecherche = "BrahmaPrintWindow"






    Call fEnumWindows






    Trouve = False






    For index = 1 To ProcessItemNumber






        If LTrim(RTrim(ProcessName(index))) = TexteRecherche Then






            Trouve = True






            Exit For






        End If






    Next






    IsCrystalReportActive = Trouve





 





End Function





 





 





Public Function fEnumWindowsCallBack(ByVal hwnd As Long, _






                                     ByVal lpData As Long) As Long





Dim lResult    As Long





Dim lThreadId  As Long





Dim lProcessId As Long





Dim sWndName   As String





Dim sClassName As String






    '






    ' This callback function is called by Windows (from the EnumWindows






    ' API call) for EVERY window that exists.  It populates the aWindowList






    ' array with a list of windows that we are interested in.






    '






    fEnumWindowsCallBack = 1






    sClassName = Space$(MAX_PATH)






    sWndName = Space$(MAX_PATH)






    lResult = GetClassName(hwnd, sClassName, MAX_PATH)






    sClassName = Left$(sClassName, lResult)






    lResult = GetWindowText(hwnd, sWndName, MAX_PATH)






    sWndName = Left$(sWndName, lResult)






    lThreadId = GetWindowThreadProcessId(hwnd, lProcessId)






    ProcessItemNumber = ProcessItemNumber + 1






    ProcessName(ProcessItemNumber) = sClassName






    ''Form1.lstWindows.AddItem CStr(hwnd) & vbTab & sClassName & ''    vbTab & CStr(lProcessId) & vbTab & CStr(lThreadId) & ''    vbTab & sWndName





 





End Function





 





 





Public Function fEnumWindows() As Boolean





Dim hwnd As Long





 





 






    '






    ' The EnumWindows function enumerates all top-level windows






    ' on the screen by passing the handle of each window, in turn,






    ' to an application-defined callback function. EnumWindows






    ' continues until the last top-level window is enumerated or






    ' the callback function returns FALSE.






    '






    Call EnumWindows(AddressOf fEnumWindowsCallBack, hwnd)




End Function


 


De l’utlisation de la fonction iscrystalreportactive




    With mainmenu.CrystalReport1






                    .PrinterCopies = int_NombreDePage






                    .Destination = 0






                    .ReportFileName =  "votre nom de fichier.rpt"






                   

.Action = 1






  
 End With






  
 Do






   
    
            ProcessItemNumber = 0






       
   
   
 
     Bl_CrystalActive = IsCrystalReportActive()






          
   
 
 
    DoEvents






    Loop While Bl_CrystalActive










vblover
0
vblover Messages postés 57 Date d'inscription mardi 25 février 2003 Statut Membre Dernière intervention 27 janvier 2011
17 juin 2006 à 21:36
Declaration à ajouter à l’entete de votre programme principal



Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long<?xml:namespace prefix o ns "urn:schemas-microsoft-com:office:office" /?>





Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long,   ByVal lpClassName As String,  ByVal nMaxCount As Long) As Long





Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long





Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long,






                                                        lpdwProcessId As Long) As Long





Declare Function SendMessageArray Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long,  ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long





 





Public Const LB_SETTABSTOPS = &H192





Public Const MAX_PATH = 260




Public ProcessName(500) As String


Public ProcessItemNumber As Integer


 


 


 


 


 


 


 


Ajouter ces functions  dans un module de functions définies par l’utlisateur



Public Function IsCrystalReportActive() As Boolean





Dim index As Integer





Dim TexteRecherche As String





Dim Trouve As Boolean





 






    TexteRecherche = "BrahmaPrintWindow"






    Call fEnumWindows






    Trouve = False






    For index = 1 To ProcessItemNumber






        If LTrim(RTrim(ProcessName(index))) = TexteRecherche Then






            Trouve = True






            Exit For






        End If






    Next






    IsCrystalReportActive = Trouve





 





End Function





 





 





Public Function fEnumWindowsCallBack(ByVal hwnd As Long, _






                                     ByVal lpData As Long) As Long





Dim lResult    As Long





Dim lThreadId  As Long





Dim lProcessId As Long





Dim sWndName   As String





Dim sClassName As String






    '






    ' This callback function is called by Windows (from the EnumWindows






    ' API call) for EVERY window that exists.  It populates the aWindowList






    ' array with a list of windows that we are interested in.






    '






    fEnumWindowsCallBack = 1






    sClassName = Space$(MAX_PATH)






    sWndName = Space$(MAX_PATH)






    lResult = GetClassName(hwnd, sClassName, MAX_PATH)






    sClassName = Left$(sClassName, lResult)






    lResult = GetWindowText(hwnd, sWndName, MAX_PATH)






    sWndName = Left$(sWndName, lResult)






    lThreadId = GetWindowThreadProcessId(hwnd, lProcessId)






    ProcessItemNumber = ProcessItemNumber + 1






    ProcessName(ProcessItemNumber) = sClassName






    ''Form1.lstWindows.AddItem CStr(hwnd) & vbTab & sClassName & ''    vbTab & CStr(lProcessId) & vbTab & CStr(lThreadId) & ''    vbTab & sWndName





 





End Function





 





 





Public Function fEnumWindows() As Boolean





Dim hwnd As Long





 





 






    '






    ' The EnumWindows function enumerates all top-level windows






    ' on the screen by passing the handle of each window, in turn,






    ' to an application-defined callback function. EnumWindows






    ' continues until the last top-level window is enumerated or






    ' the callback function returns FALSE.






    '






    Call EnumWindows(AddressOf fEnumWindowsCallBack, hwnd)




End Function


 


De l’utlisation de la fonction iscrystalreportactive




    With mainmenu.CrystalReport1






                    .PrinterCopies = int_NombreDePage






                    .Destination = 0






                    .ReportFileName =  "votre nom de fichier.rpt"






                   

.Action = 1






  
 End With






  
 Do






   
    
            ProcessItemNumber = 0






       
   
   
 
     Bl_CrystalActive = IsCrystalReportActive()






          
   
 
 
    DoEvents






    Loop While Bl_CrystalActive










vblover
0
Rejoignez-nous