codemorphis.com Forum Index codemorphis.com
Software development: pure and simple.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Printing from a grid

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    codemorphis.com Forum Index -> Visual Programming Forum
View previous topic :: View next topic  
Author Message
gavin



Joined: 08 Sep 2004
Posts: 28

PostPosted: Sat Nov 13, 2004 2:05 am    Post subject: Printing from a grid Reply with quote

Hi,

Me again Very Happy .

I need help with printing from a grid to a printer. I have a grid filled from a database and would want to print it to a printer once a print button is pressed.

Thanks

Gavin
Back to top
View user's profile Send private message Send e-mail
michaelforkner



Joined: 04 Aug 2004
Posts: 12

PostPosted: Sat Nov 13, 2004 10:01 am    Post subject: Printing From A Grid Reply with quote

Hi Gavin,

One way to accomplish this task would be to create a document from this grid of information, then print the document. To do this, you would interrogate each field (you may or may not need a Header Row for field deliniation) of the grid and place it into a text doc, or create a form with a text box (a basic word processor) so you can control fonts etc from Synopsis, then fill that form's textbox with the data from the grid, then print that.

Regards,
Michael Forkner
Back to top
View user's profile Send private message Visit poster's website
CodeMorphis



Joined: 02 Dec 2003
Posts: 252

PostPosted: Sat Nov 13, 2004 7:11 pm    Post subject: Reply with quote

Great to see Synopsis users helping each other! Thanks to both of you for posting.

Another method you might like to check out:

The Windows Form component has two printing services:


  • Print: Allows you to print the contents of the form to a printer
  • Print preview: Allows you to print preview the contents of the form

Both services allow you the option of bringing up a print setup dialog prior to actual printing or previewing.

There is a also a "Page setup" service that opens the page setup dialog for settings that apply to the "Print and "Print preview" services.

Some related services that can also help you to accomplish this goal in certain situations are the screen grab services, which you can read about in a previous prgramming article:

http://www.codemorphis.com/forums/viewtopic.php?t=24
Back to top
View user's profile Send private message Send e-mail Visit poster's website
michaelforkner



Joined: 04 Aug 2004
Posts: 12

PostPosted: Sat Nov 13, 2004 9:34 pm    Post subject: Printing Reply with quote

Hi,

My second suggestion in the reply to Gavin was alluding to the print service of the winform component, but you have given me a new question to ask since I haven't actually gotten around to trying my own advice.

When printing a form with the service from the form component, does the entire form print ( buttons, etc) or just a textbox or whatever? Also, if the grid is larger than the data view, does the print service print the entire data region or just the viewable region?

I actually just did pause and try this with the SuperStore grid, but I had refilled my inkjet two days ago and get only a gray rectangle.

OK, paused again...

I edited the service to let me go with the 'print preview', but my print preview is also a gray rectangle.


Regards,
Michael Forkner
Back to top
View user's profile Send private message Visit poster's website
CodeMorphis



Joined: 02 Dec 2003
Posts: 252

PostPosted: Sun Nov 14, 2004 1:39 am    Post subject: Reply with quote

Here is the SuperStore datagrid program with a slight modification for print previewing:



The program is the same as the sample program "SuperStore datagrid.vpd" found in the "Sample Programs" directory of the Synopsis installation except for one additional component. Note the Service Call component "Serv Call 4" referencing the Windows Form component and set to the "Print preview" service. The component is connected in the Windows event loop so as to receive process control everytime you click in the form but not on the "Quit" button.

You can see the result of the print preview - it shows the form as it would be printed on paper with the "Print" service".

Here is the corresponding VPD source file :

http://www.codemorphis.com/articles/ans_111304/SuperStore_datagrid_printpreview.vpd

When printing or print previewing a form the entire contents of the form are formatted to the current page settings, which can be altered by the user via the "Page settings" service. If the datagrid is larger than the size of the target page (i.e. the physical size of the paper) then in the print or print preview result it will be clipped. The current window view size does not matter. To see this, run the program and scale down the size of the form. Then click somewhere inside the form and you will see that the print preview window shows the datagrid in full size. This is because the paper size is used to determine the clipping region.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gavin



Joined: 08 Sep 2004
Posts: 28

PostPosted: Sun Nov 14, 2004 4:50 am    Post subject: Reply with quote

Hi,

Ok, it works, however if I have created a report in access can I call or open the report in my program?

Gavin
Back to top
View user's profile Send private message Send e-mail
CodeMorphis



Joined: 02 Dec 2003
Posts: 252

PostPosted: Sun Nov 14, 2004 7:51 pm    Post subject: Reply with quote

Gavin,

Your original question sounded like you wanted to print a datagrid. Hopefully, this thread answered your question.

Of course, accessing and printing Microsoft Access reports externally is not a standard Windows programming feature. Nevertheless, we will try to add this extra feature into Synopsis for convenience.

You can create an Access macro to print or preview your report and then invoke the macro on startup of Access. This call can be made from the Launch Program component (System tab of Component Tray). We refer you to the Microsoft Access Help documentation for usage of macros and startup options.

Also, if you have external functions in DLLs - either custom code or perhaps an add-on product that you have purchased that does Access reporting - then you can call this code using the DLL Func Call component.

Of course, seamless integration for reporting is better and a set of business database and reporting tools is slated for development.

Please take advantage of this opportunity to tell us about all the kinds of features and capabilities that you would like to see in such tools.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gavin



Joined: 08 Sep 2004
Posts: 28

PostPosted: Mon Nov 15, 2004 1:26 am    Post subject: Reply with quote

Printing directly from the datagrid was what I was looking for and the explanation you provided was sufficient in assisting me to do just that, thank you. The reason for me asking if it is possible to print from a access report is because the access reports layout is without the buttons (ie. the whole page) and only includes the data that is needed. I understand that the user can adjust and make their own settings of what is required to print, however the access report just looks more professional and easier for the user unless you have another suggestion of printing directly from the grid without the entire page?

If you could give me a couple of days I will look into giving you feedback on features that you could include.

Thanks

Gavin
Back to top
View user's profile Send private message Send e-mail
CodeMorphis



Joined: 02 Dec 2003
Posts: 252

PostPosted: Mon Nov 15, 2004 2:33 pm    Post subject: Reply with quote

There are the two methods mentionned that are available. Another possibility is to use the screen grab utilities to print out a specific region of the form.

As mentionned, extra features for additional report generation are being considered. This might actually be a relatively simple task and if possible we will include it in a forthcoming update.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CodeMorphis



Joined: 02 Dec 2003
Posts: 252

PostPosted: Thu Nov 18, 2004 5:30 am    Post subject: Reply with quote

Some new report services have been added to the Access Database component in update 1.1.5

The new services are:

  • Num reports: Gets the number of reports in the connected database.
  • Report name: Returns the name of a report in the connected database given a report index (offset from 0).
  • Run report: Accepts the name of a report in the connected database in input data port 0, opens Microsoft Access and runs the given report.
  • Print report: Accepts the name of a report in the connected database in input data port 0, runs the given report and then prints it.
  • HTML report: Accepts the name of report in the connected database in input data port 0, runs the given report and saves it in HTML format to the file path specified in input data port 1.

You can use the "Num reports" and "Report name" services to query the list of report names in a given database. Call the "Num reports" service first to retrieve the list of report names and then use the "Report name" to get indexed names.

You can run a report in three manners:

  • The "Run report" service opens Access and automatically runs a given report
  • The "Print report" service quietly runs the report and then sends the results to the default printer.
  • The "HTML report" service quietly runs the report and then saves it as an HTML file that you specify.

As an example, let's look at the following program that creates an HTML report and then opens the resulting HTML file in the default internet browser (in this case IE):



In the Access Database component which is set to the "Connect" service (the component with the name "Access DB 1"), we are connecting to a database that has a report that we created. We select the database file in input data port 1 of component "Access DB 1".

In our example, we modified the example SuperStore database. You can download this modified database file here:

http://www.codemorphis.com/articles/ans_111804/SuperStore_report.mdb

If you run the program, component "Serv Call 2" will use the "HTML report" service of the Access Database component to generate an HTML file called c:\htmlreport.html for the report named "Inventoryreport", which is saved in the Access database file. You can see these arguments in the Input Argument Editor dialog shown.

Here is the result of the report as shown in the IE browser window:



The displaying of the report results is handled by the "Launch Program" component, which opens the generated report file.

You can download this program here:

http://www.codemorphis.com/articles/ans_111804/SuperStore_report.vpd

Before running the program, you should select the database file in input data port 1 of the "Access DB 1" component.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gavin



Joined: 08 Sep 2004
Posts: 28

PostPosted: Thu Nov 18, 2004 5:39 am    Post subject: Reply with quote

Wow! That was fast. Thank's a million, it looks great.

Gavin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    codemorphis.com Forum Index -> Visual Programming Forum All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group