Solved

Why is a Print Menu Item so Difficult for PowerBuilder 7.0 to Do?

Posted on 2001-08-22
17
366 Views
Last Modified: 2013-12-26
Hi.

I'm trying to add a Print menu item to my m_menu object in a project using PowerBuilder 7.0.

I seem to have tried everything I could find on printing in the way of functions in the help and the online books.

I have only a few windows(sheets) in this project, but I wish to have the user be able to click on File | Print and have PB print out the active datawindow control with its associated data object. It seems it should be straightforward enough, but I haven't found this to be the case. To make matters more difficult, one of the sheets has 2 datawindow controls on it, 'dw_master' and 'dw_detail'.

I have tried to code the script behind the Print menu as:

Determine which is the active sheet using the PB function GetActiveSheet().

Choose Case w_activeSheet // datatype window
Case w_employee_main
PrintDataWindow(dw_master)

//dw_master is a datawindow control which was actually
//created on an ancester sheet named w_base

the compiler did not like this at all. One should be able
to determine which data one has based upon the sheet it's in.

I even tried using the PrintOpen with PrintClose. Nothing seems to work here.

Any suggestions??

JNowlin
0
Comment
Question by:jnowlin
  • 8
  • 4
  • 3
  • +1
17 Comments
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
You want to print from menu item Print.

You can get the active sheet, You should write for your Print the datwindow name (DW control name) with your active window name. You can use CHOOSE CASE or IF statement.

For exemple


IF w_activesheet = w_employee_main
     w_employee_main.dw_master.print()
ELSEIF
    ............
ELSE
    .............
END IF

You can also use CHOOSE CASE but I think CHOOSE CASE is slower then IF statement.


You should recognise the for  w_activesheet   w_employee_main and compiler should know which datawindow and from which window.

window.datawindow.print()


Try it
0
 
LVL 2

Expert Comment

by:Caseys95
Comment Utility
Try This:
...
Integer     li_Job

li_Job = PrintOpen("Datawindow Report")

Choose Case w_activeSheet // datatype window
     Case w_employee_main
     PrintDataWindow(li_Job, w_employee_main.dw_master)
     Case w_Payroll_main
     PrintDataWindow(li_Job, w_Payroll_main.dw_other)
...
End Choose

PrintClose(li_Job)
...

I do not have access to 7.0 documentation at the moment, but 6.5 documentation requires 2 perameters for the PrintDatawindow function. the first being the number of the printjob opened with PrintOpen()

Now for the bull:

I have a concept when programming in PB, "Let an object take care of its own buisness."
This means try to use "This." to prefix a function, property, event ...
If you can use encapsulation your work will become much easier.

Also, Windows is a messaging operating system, you should code that way.

I would add a common event to each sheet ue_printdw()
This works best if you have inherited each of your sheets from a common ancestor.
Also if the parent of the menu is your frame create an ue_PrintDW event there as well

Then in your menu script:
parent.triggerevent("ue_Printdw")  // Pass the print request to the controller (frame)

 I try to keep the menu code as simple as possible.

If you need the frame script for ue_printdw:

Prefered method:
uo_sheet   lo_sheet    /* Ancestor inherits from window and has an event ue_printDW */

lo_sheet = this.getactivesheet()

lo_sheet.event static trigger ue_printdw()    // Pass the message along to the sheet

Alternate method:
window   lo_sheet

lo_sheet = this.getactivesheet

lo_sheet.triggerevent("ue_printdw")  // Pass the message along to the sheet

Last in uo_sheet.ue_Event let the object take care of its own printing
// uo_Sheet.ue_printdw()

Integer li_Job

li_Job = PrintOpen("Print Job")

This.PrintDataWindow(li_Job, This.MyDW)

PrintClose(li_Job)
0
 

Author Comment

by:jnowlin
Comment Utility
Hi Caseys95,

I'm able to follow most of what you suggest, except for:

"uo_sheet   lo_sheet    /* Ancestor inherits from window and has an event ue_printDW */"

lo_sheet inherits from the window named uo_sheet and uo_sheet has the user event 'ue_printDW' on it?

Then, within the ue_printDW the code:

Integer li_Job

li_Job = PrintOpen("Print Job")

This.PrintDataWindow(li_Job, This.MyDW)

PrintClose(li_Job)

is placed? I guess I'm a little confused on the naming convention being used. This project has a window, 'w_base', on it and a datawindow control, 'dw_master', which is inherited from 'w_base' on other windows(sheets). Could the ue_printDW event be placed on this sheet?

Jim
0
 

Author Comment

by:jnowlin
Comment Utility
Ah, I thought of this...

What if the active sheet has more than one data window control placed upon it? I couldn't find a PB function to detect/count the number of data window objects there are.
Would one pop-up a messagebox saying "Which data selection do you wish to print?"

???? Another question to E.E. PB ??

JimNowlin
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Do you mean find the number of controls in window or number of datawindows in window?
0
 
LVL 2

Expert Comment

by:Caseys95
Comment Utility
Try

Datawindow     lo_DW

For liX = 1 to w_Mywin.Control


0
 
LVL 2

Expert Comment

by:Caseys95
Comment Utility
Sorry

Try

Integer        liX, liY
Datawindow     lo_DW[]

For liX = 1 to Upperbound(w_Mywin.Control)

      IF w_Mywin.Control[liX].TypeOf() = Datawindow! THEN
         liY++
         lo_DW[liY] = w_Mywin.Control[liX]
          ... // Some processing
      END IF

NEXT
0
 

Author Comment

by:jnowlin
Comment Utility
Bhatti,

I have a window (sheet) with two data window controls on it, dw_main and dw_detail. In the future, I may have 1 or 2 addtional data window controls on this sheet. It looks as though Caseys95 is on the right track using an array of data window control.

JNowlin
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 4

Accepted Solution

by:
Bhatti earned 150 total points
Comment Utility
Hello Jim,

You want to print datawindow or all datawindows?

Caseys95 is on right track. But you need also to know  the name of the datawindow the classname.
So you need to use the funtion classname().

string the_class[]
windowobject the_object[]
integer i

FOR i = 1 TO UpperBound(windowname.control[])
    the_object[i] = control[i]
    the_class[i] = the_object[i].ClassName()
    IF the_class[i] = 'dw_master' THEN
          //print the datawindow
         // as mentioned above PrintDatawindow(ll_job, windowname.dw_master)
    END IF
NEXT


TypeOf() tell you the type of the object, is it checkbox , button or datawindow and classname return you the class of the object as dw_master, cb_save, st_1 etc.

I think if you want to know the class name to do some action on it then you need classname() function to get the right class for right action for this class.

Please let me know is it so?

THANKS
0
 

Author Comment

by:jnowlin
Comment Utility
Hey,

So very much good stuff here. I believe I am now beginning to understand. I won't get a chance to try it until Thursday.

This has been such a problem for newbie me.

Meanwhile, I must increase point value. Also, I may need to split points between you both.

Jim
0
 

Author Comment

by:jnowlin
Comment Utility
It's going to take longer than expected to work with you on this question.

Thsi past Thursday, I was told I must vacate my appartment by no later than October 1, 2001.
I will need to use more time to look for a place to live.
Please bear with me.
Thank-you.

Jim
0
 

Author Comment

by:jnowlin
Comment Utility
Hello all,

I'm back and living elsewhere. It's quiet. It's good.

I think I will keep this question open/active for now, as I will get back to this soon.

JimNowlin
0
 
LVL 4

Expert Comment

by:Bhatti
Comment Utility
Hallo Jim,

Nice to hear from you and you have now an appartment. I wrote in my latest comments please have a view, I am writing it again, and if you have any question please write me to know.

FOR i = 1 TO UpperBound(windowname.control[])
        the_object[i] = control[i]
        the_class[i] = the_object[i].ClassName()
        IF the_class[i] = 'dw_master' THEN
                //print the datawindow
               // as mentioned above PrintDatawindow(ll_job, windowname.dw_master)
        END IF
NEXT

Bhatti
0
 

Author Comment

by:jnowlin
Comment Utility
I am ever so sorry for forgetting about this question.
I should be back up and ready to go at it soon. I went away to help a friend of a friend who has cancer, and I've been dealing with an obnoxious boss who, after many complaints in the Equal Opportunity Office (including a sexual harrasment complaint), Personnel Dept., managed to get an early retirement from the Commonwealth of Massachusetts. We were all "thrilled". His last day is 03/15/02.

I just upgraded to a refurbished Dell Dimension PC. I had a few minor glitches to contend with, but, after a few more days, I should be ready to get back into the show here. I know it sounds like excuses, perhaps some of it is. But, another, better person, would have abandoned his/her nightmare manager (not to mention, nightmare landlord) long ago.

Once again, please accept my appologies and my rambling on. Once I get my PowerBuilder/Oracle connections again (and my bearings), I intend to continue my best to insure that I am a lively participant, just as I was before.

Jim Nowlin
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> You cannot delete a question with comments, special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20163545.html
http://www.experts-exchange.com/questions/Q.20172364.html
http://www.experts-exchange.com/questions/Q.20266218.html
http://www.experts-exchange.com/questions/Q.20266220.html
http://www.experts-exchange.com/questions/Q.20275267.html




PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange
0
 

Author Comment

by:jnowlin
Comment Utility
Thank you Bhatti,

I *still* have not tried, because I've been working on a VB application.
I feel awfull that I have held this question up for so long. So,
I accept your answer now and I will post aditional questions as they come up regarding the Print menu.
Again, please accept my apologies.

JimNowlin
Leicester, Massachusetts
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Thank you Jim, for returning and finalizing this.  A quick way to help maintain your questions here is to keep the following link handy, and click to View your question history and find all open/locked questions easily.
http://www.experts-exchange.com/jsp/memberProfile.jsp?mbr=jnowlin
:)
Moondancer - EE Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now