Link to home
Start Free TrialLog in
Avatar of jnowlin
jnowlin

asked on

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

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
Avatar of Bhatti
Bhatti

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
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)
Avatar of jnowlin

ASKER

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
Avatar of jnowlin

ASKER

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
Do you mean find the number of controls in window or number of datawindows in window?
Try

Datawindow     lo_DW

For liX = 1 to w_Mywin.Control


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
Avatar of jnowlin

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Bhatti
Bhatti

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jnowlin

ASKER

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
Avatar of jnowlin

ASKER

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
Avatar of jnowlin

ASKER

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
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
Avatar of jnowlin

ASKER

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
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.
https://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.  https://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.
https://www.experts-exchange.com/questions/Q.20163545.html
https://www.experts-exchange.com/questions/Q.20172364.html
https://www.experts-exchange.com/questions/Q.20266218.html
https://www.experts-exchange.com/questions/Q.20266220.html
https://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 https://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
Avatar of jnowlin

ASKER

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
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.
https://www.experts-exchange.com/jsp/memberProfile.jsp?mbr=jnowlin
:)
Moondancer - EE Moderator