Welcome, Guest
Username: Password: Remember me
This forum is the place to discuss issues related to ReportPro, Xs2Ado, Vo2Ado, bBrowser and other 3rd party products
  • Page:
  • 1

TOPIC:

ReportPro3 in X# initialization and deinitialization of report preview issues 15 Oct 2021 07:52 #19921

  • Michal Rajnoha
  • Michal Rajnoha's Avatar
  • Topic Author


  • Posts: 12
  • Greetings XSharp developers.

    In our company, we're trying out possibiblities of migrating from VO2.8SP4 to XSharp using XIDE.
    We've already managed to convert one of our programs and make it run along with bBrowser, but we still have two issues with ReportPro3 3.60 using classmate:

    1. The ReportPro3 preview always starts up in the background behind the window of the calling application. We tried to make the report window modal, but we can't figure out how.

    2. If the ReportPro3 throws an exception, our program captures it just fine, and even tries to perform cleanup/uninitialization, but the report preview window stays visible and frozen anyway and can't be closed unless manually terminated.


    Referenced libraries:

    Classmate.Function.dll
    Classmate.Gui.dll
    ReportPro3.Designer.dll
    ReportPro3.Rdd.dll
    VOGUIClasses
    VOSQLClasses
    VOWin32APILibrary
    XSharp.Core
    XSharp.RT
    XSharp.VO

    The rest of the ReportPro3 libraries are copied from the "redist" folder inside the ReportPro3 installation folder.


    The code itself goes as follows:
    CLASS RP3Report
    
    PROTECT _Report AS ReportPro3.rpReport
    
    CONSTRUCTOR()
    
    METHOD PrintReport(pOwnerWindow AS VO.ShellWindow, sqlConnection AS VO.SQLConnection, reportFormPath AS STRING, reportFormCaption AS STRING, reportFormPrintMessage AS STRING, sqlFilter AS STRING, sqlOrder AS STRING, reportFormHeader AS STRING, parameters AS ARRAY)
    
    	LOCAL app AS classmate.cApp
    	LOCAL ownerWindow AS classmate.cWindow
    
    	LOCAL nSection AS LONGINT
    	LOCAL cTableName AS STRING
    	LOCAL nSections	AS LONGINT
    	LOCAL nLen AS INT
    	LOCAL nLp AS INT
    	
    	LOCAL errorMessage AS STRING
    	
    	errorMessage := ""
    	
    	TRY
    		
    		IF !File(reportFormPath)
    			
    			THROW Exception{"Error - "+reportFormPath+" does not exist."}
    	      
    		ENDIF
    	    
    	    ownerWindow := classmate.cWindow{pOwnerWindow:Handle()}
    	    
        	app := classmate.cApp{}
    		app:AppName := ownerWindow:Caption		
    	    
    		cmGUIDLLInit(app)
    		ReportProInit()
    	
    		IF !Empty(pOwnerWindow)
    			
    			UpdateWindow(pOwnerWindow:Handle(0))
    			
    			SELF:_Report := ReportPro3.rpReport{ownerWindow}
    		    
    		ELSE
    			
    			THROW Exception{"Owner window can't be null."}
    		   
    		ENDIF
    
    		SELF:_Report:LoadReport(reportFormPath)
    	
    		IF SELF:_Report:IsValid
    
    			SELF:_Report:SetReportStringAttribute(RP_PRINT_ATTR_PREVIEW_CAPTION, reportFormCaption)
    			SELF:_Report:SetReportStringAttribute(RP_PRINT_ATTR_PRINT_MESSAGE1, reportFormPrintMessage)
    
    //not sure how modal is supposed to work since modal attribute is a logic type, but none of these actually do anything anyway
    //?			SELF:_Report:SetReportIntAttribute(RP_PRINT_ATTR_PREVIEW_MODAL, 1)
    //?			SELF:_Report:SetReportStringAttribute(RP_PRINT_ATTR_PREVIEW_MODAL, "TRUE")
    //?			SELF:_Report:Printer:PreviewModal := TRUE
    	
    			//...
    			<setting section attributes and variables code goes here>
    			//...
    	        
    			SELF:_Report:Preview()
    	
    		ENDIF
    	
    	CATCH Ex AS XSharp.Internal.WrappedException
    		
    		errorMessage += Ex:Value:ToString():Substring(0, Ex:Value:ToString():IndexOf(Chr(13)+Chr(10))) 
    		errorMessage += Chr(13)+Chr(10)+Chr(13)+Chr(10)
    
    	CATCH Ex AS Exception
    		
    		errorMessage += Ex:Message
    		errorMessage += Chr(13)+Chr(10)+Chr(13)+Chr(10)
    		errorMessage += Ex:StackTrace
    	
    	FINALLY
    		
    //this cleanup doesn't work if an exception is thrown, the ReportPro3 preview stays hanging and can't be closed unless forcefully terminated
    //if SELF:_Report:Close() and/or SELF:_Report:ClosePreview() is called, the entire program freezes up
    		SELF:_Report := NULL
    		ownerWindow := NULL
    		app := NULL
            
            ReportProUnInit()
    		cmGUIDLLUnInit()
    		
    	END TRY
    
    //there seems to be no reason to close the report from withing the code, since we require user interaction to finish the printing or aborting the process	
    //	SELF:_Report:Close()
    	
    	IF !Empty(errorMessage)
    		
    		THROW Exception{errorMessage}
    		
    	ENDIF
    
    RETURN NULL
    
    END CLASS

    Please Log in or Create an account to join the conversation.

    ReportPro3 in X# initialization and deinitialization of report preview issues 15 Oct 2021 11:21 #19924

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Michael,

    Can you please try creating a repro sample? Start with a new standard (empty) mdi app, add references to the RP3 and classmate dlls as in your real app and also add the report creating code. Do the problems still happen with it? If not, it means that there's something else in your real app that is interfering, and we need to find what that is. If it does, then can you please zip and send the project so we can have a look?

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    ReportPro3 in X# initialization and deinitialization of report preview issues 15 Oct 2021 13:37 #19925

    • Michal Rajnoha
    • Michal Rajnoha's Avatar
    • Topic Author


  • Posts: 12
  • I'm actually testing it in the most simple app and the behavior is the same. I will send a sample as soon as I will be able to.

    Please Log in or Create an account to join the conversation.

    ReportPro3 in X# initialization and deinitialization of report preview issues 15 Oct 2021 19:02 #19931

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Michael,

    Thanks for the sample, I see that the preview window is shown underneath the Shell, looks like it is first shown on top, but then the Shell gets brought back on top, a moment later. I am not really familiar with how classmate works, but I just gave it a try to bring the Shell on top manually before showing the preview, and this has a bit surprisingly seemed to fix the problem here! I just added this:

    ownerWindow:SetFocus()

    before the call to

    SELF:_Report:Preview()

    Can you please try it as well? Maybe this is indeed enough to take care of the issue?

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    ReportPro3 in X# initialization and deinitialization of report preview issues 15 Oct 2021 19:19 #19932

    • Michal Rajnoha
    • Michal Rajnoha's Avatar
    • Topic Author


  • Posts: 12
  • Yes, that seems to work. Still don't know how to possibly make the window modal, but we can work with a nonmodal one as well.

    So the first issue is fixed, now only the second one remains.

    Please Log in or Create an account to join the conversation.

    ReportPro3 in X# initialization and deinitialization of report preview issues 16 Oct 2021 08:37 #19934

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Michael,

    On what kind of RP3 errors does this happen?
    Does it help if you issue a SELF:_Report:Close() when you catch the exception?

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    ReportPro3 in X# initialization and deinitialization of report preview issues 16 Oct 2021 08:41 #19935

    • Michal Rajnoha
    • Michal Rajnoha's Avatar
    • Topic Author


  • Posts: 12
  • We've only tried SQL errors.

    In the sample I've sent inside "Standard shell.prg" file of Tester application, METHOD FileOpen(), there is a line:
    //sqlOrder := "sqlexception"
    Just uncomment it and it should generate such an error.

    Chris wrote: Hi Michael,
    Does it help if you issue a SELF:_Report:Close() when you catch the exception?
    .

    No, it actually tends to make the entire program hang.

    Please Log in or Create an account to join the conversation.

    Last edit: by Michal Rajnoha.

    ReportPro3 in X# initialization and deinitialization of report preview issues 16 Oct 2021 16:29 #19937

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Michael,

    OK, I need to find a machine with some sql engine installed, because when I installed for testing just a dbf ODBC for this test, I got no internal dbf exception and the report window is visible and closeable with no issues. Will get back to you about this.

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    ReportPro3 in X# initialization and deinitialization of report preview issues 16 Oct 2021 19:02 #19938

    • FFF
    • FFF's Avatar


  • Posts: 1419
  • www.enterprisedb.com/postgresql-tutorial...ces-training?cid=924

    Will give you the Postgres14 installer for Win64 - get it, and 5min later you'll have your SQL engine running ;)
    Faster than searching...
    Regards
    Karl (X# 2.15.0.3; Xide 2.15; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    ReportPro3 in X# initialization and deinitialization of report preview issues 17 Oct 2021 18:39 #19942

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Karl, thanks, I did so, but it seems it does not provide a way to create an ODBC driver for it?
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    ReportPro3 in X# initialization and deinitialization of report preview issues 17 Oct 2021 21:01 #19943

    • FFF
    • FFF's Avatar


  • Posts: 1419
  • Didn't the installer start at the end the"Stackbuilder"? There it suggests 32 and 64 drivers...
    Regards
    Karl (X# 2.15.0.3; Xide 2.15; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    ReportPro3 in X# initialization and deinitialization of report preview issues 18 Oct 2021 08:45 #19944

    • Frank Müßner
    • Frank Müßner's Avatar


  • Posts: 259
  • Please Log in or Create an account to join the conversation.

    ReportPro3 in X# initialization and deinitialization of report preview issues 18 Oct 2021 08:59 #19945

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Thanks a lot guys, got it to work now! And I see the issue with the report preview window freezing when there's an error, look into it...

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    ReportPro3 in X# initialization and deinitialization of report preview issues 18 Oct 2021 09:17 #19946

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Michael,

    Please try issuing this, when you detect an exception in RP3 when printing, does it solve the problem?

    IF SELF:_Report:Printer:PrintWindow != NULL
    	CloseWindow(SELF:_Report:Printer:PrintWindow:Handle(0))
    ENDIF


    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    ReportPro3 in X# initialization and deinitialization of report preview issues 18 Oct 2021 09:27 #19947

    • Michal Rajnoha
    • Michal Rajnoha's Avatar
    • Topic Author


  • Posts: 12
  • It minimizes the preview window, but it stays open and hanging.

    Please Log in or Create an account to join the conversation.

    Last edit: by Michal Rajnoha.

    ReportPro3 in X# initialization and deinitialization of report preview issues 18 Oct 2021 09:32 #19948

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Michal Rajnoha wrote: It minimizes the preview window, but it stays open and hanging.


    Ah right, I didn't notice it in the task bar. Please use DestroyWindow() instead, this seems to be taking care of it for good.

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    ReportPro3 in X# initialization and deinitialization of report preview issues 18 Oct 2021 09:37 #19949

    • Michal Rajnoha
    • Michal Rajnoha's Avatar
    • Topic Author


  • Posts: 12
  • OK, that seems to work, thank you Chris.

    Please Log in or Create an account to join the conversation.

    ReportPro3 in X# initialization and deinitialization of report preview issues 18 Oct 2021 09:39 #19950

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • Hi Michael,

    Nice, that's great to hear! I also learned a few things because of this..(thanks Karl and Frank btw)
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1