1. Mike Kochevar
  2. PowerBuilder
  3. Thursday, 8 April 2021 18:21 PM UTC

Hello,

We have recently upgraded our powerbuilder app to PB2019 and upgraded out PFC libraries to PFC2019. One change in the PFC libraries is hindering our ability to print when using File\Print from the menu bar. With the upgrade to PFC2019 the pfc_print event has been added to the pfc_w_master object this has added the event to all windows inherited from pfc_w_master. When File\Print is clicked the pfc_messagerouter event is called on pfc_w_master the line of code (underlined and bold) below succeeds and the print window is not opened. Before the upgrade to PFC2019 the pfc_print event was not on the descendant window and the line below would fail and the print dialog would open...

 

graphicobject lgo_focus

// Check argument
If IsNull (as_message) or Len (Trim (as_message)) = 0 Then
Return -1
End If

// Try sending the message to this window, if successful exit event.
If This.TriggerEvent (as_message) = 1 Then Return 1

// Try sending the message to the current control, if successful exit event.
lgo_focus = GetFocus()
If IsValid (lgo_focus) Then
If lgo_focus.TriggerEvent (as_message) = 1 Then Return 1
End If

// Try sending the message to the last active datawindow, if successful exit event.
If IsValid (idw_active) Then
If idw_active.TriggerEvent (as_message) = 1 Then Return 1
End If

// No objects recognized the message
Return 0

 

From what I have read if the event that is being triggered does not contain any code the TriggerEvent() should return -1 but that is not happening in this case. I have tried to force a -1 return but that still does not work.

 

I know that PFC is not supported by Appeon, I was wondering if anyone else had encountered this problem, any suggestions would be helpful.

 

Thank you,

Mike

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Friday, 9 April 2021 05:05 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Mike,

Yes, it is an old and IMHO very bad change to the PFC.

Someone thought it would be a good idea to implement calls to pfc_preprint and pfc_postprint events without knowing it destroys messagerouter logic. 

A I know you can't override an event and leave it empty as John recommended.

I removed the code in pfc_print event in pfc_w_master in my application to get back the correct behaviour.

Regards,

René

 

Comment
  1. Tracy Lamb
  2. Tuesday, 29 March 2022 16:14 PM UTC
I'm upgrading to PB 2021 and latest version of PFC.  I followed Renee's advice, also had to delete the code in pfc_printimmediate in pfc_w_master.  Everything works like a charm now!



~~~Tracy
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 23 April 2021 10:16 AM UTC
  2. PowerBuilder
  3. # 1

Hi.

The main issue with changes made in pfc_print, is that it will never print, as other stated. That's because  pfc_w_master pfc_print event does nothing. It simply returns 0. And I haven't found any pfc window that inherits from pfc_w_master and uses that event for print. I guess that this change was made to give us in the future the possibility to print the window itself, but remained incomplete.

The bad thing is that triggerevent cannot handle return values from events they call. It handles if the command succed. So if the event exists, triggerevent will return 1. Then it will not try to print anything else (for example active datawindow). If those changes are realy needed (pre and post events), then some redesign will be required.

For the momment, what I did (which I know is not 100% correct), I extended pfc_print event in the pfe layer. There I added the following code:

graphicobject lgo_focus

lgo_focus = GetFocus()
If IsValid (lgo_focus) Then
	If lgo_focus.TriggerEvent ("pfc_print") = 1 Then Return 1
End If

If IsValid (idw_active) Then
	If idw_active.event pfc_print() = 1 Then Return 1
End If

return ancestorreturnvalue

Actually this is the equivallent code the messageroute event would execute if it could catch that the pfc_print event on the window returned something different than 1.

Andreas.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 8 April 2021 23:04 PM UTC
  2. PowerBuilder
  3. # 2

It looks like this was changed circa v12.5, so your previous libraries must have been older than that.

I assume you do not have any descendant windows that now contain code in the pfc_print event?

It should be relatively simple for you to correct in the w_master (pfemain.pbl) descendant of pfc_w_master:

You can try overriding the ancestor script, but do not put ANY code (even a comment) in the w_master's pfc_print event. ANY code (not just executable statements) in the event script will result in the TriggerEvent(as_message) function call returning 1.

If that does not work, then using the "message router" code as a guide, perform in w_master's pfc_print event script the same subsequent logic that the message router used to perform, beginning after the "//Try sending the message to the last active datawindow, if successful exit event." comment . You'll need to make some adjustments in the code, but conceptually this should work well.

Good luck!

Comment
  1. Miguel Leeuwe
  2. Friday, 9 April 2021 05:08 AM UTC
Hi John,

Not sure if I understand:

As far as I know, there's no way in which you can override a script, without putting in at least a comment. As soon as you delete the comment, you override is gone.

regards
  1. Helpful
  1. John Fauss
  2. Friday, 9 April 2021 05:21 AM UTC
You are right, Miguel. I didn't have an opportunity to test that, but what you say makes perfect sense.... that's why I also described transferring the message router logic to the pfc_print event in w_master. Rene's approach is the cleanest solution, of course (correct the faulty code in pfc_w_master), but I really do not like recommending someone change code in the PFC-layer objects unless there is no other solution. Thank you (and to Rene, also) for catching my faux pas regarding the empty override. P.S.: Don't you ever sleep? :-)
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 9 April 2021 05:51 AM UTC
Ok, I thought I was missing something :) Yes your second solution is a nice one.

To be honest, I've given up on "not being allowed" to change anything in the PFCs. Luckily I can do whatever I want in this place. For some funny reason, in our mdi menus, previous and current programmers like to open sheets by using:

Message.StringParm = "w_feature_guides"

of_SendMessage("pfc_open")



I had to rename this function "pfc_open" on the "pfc_u_rte":



---------- Search: Searching Target batch_cq for '_wtf' (06:45:18)

---------- 2 Matches Found On "_wtf":

pfcmain.pbl(pfc_u_rte).pfc_u_rte: event type integer pfc_open_wtf ( )

pfcmain.pbl(pfc_u_rte)pfc_open_wtf.0003: // Event: pfc_open_wtf // v3, mjl, 03/12/20: had to rename this one, since it makes it impossible to open another window from mdi menu when focus is on rte

---------- Done 2 Matches Found On "_wtf":

---------- Finished Searching Target batch_cq for '_wtf' (06:45:18)



Less work than changing everything.

As long as I use correct comments for those changes, I can always apply the same changes when switching to a newer PFC version. (also using Araxis Merge or any other folder/file comparision tool).

regards
  1. Helpful
There are no comments made yet.
Mike Kochevar Accepted Answer Pending Moderation
  1. Friday, 9 April 2021 15:50 PM UTC
  2. PowerBuilder
  3. # 3

Hello Everyone,

Thank you for all of the great suggestions on how to solve my problem.

I went with Rene option to remove all code from the pfc_w_master::pfc_print event and everything worked great.

 

Thanks again,

Mike

Comment
  1. Miguel Leeuwe
  2. Friday, 9 April 2021 16:40 PM UTC
Very well said Armeen!
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 9 April 2021 16:41 PM UTC
(Thanks to that article I've actually used GitHub with PB, something I'd never imagine!)

LOL
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 9 April 2021 16:44 PM UTC
So, yes we should all try to contribute to the PFC classes. At least the ones of us who use them. I'm sure Chris was only joking, but Armeen made a very good point.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.