1. Thomas Stewart
  2. PowerBuilder
  3. Monday, 17 December 2018 19:15 PM UTC

We are currently migrating from PB12.5 to PB12.6 along with the PFC 12.6 that we got from GIT.  One of the issues we are having is before we would call pfc_printdlg to set up the Print to File by calling: 

if GetFileSaveName("Print to File", + &
    is_pathname, ls_filename, "txt", + &
    "Text File--Tab Delimited (*.txt), *.txt," + &
    "Text File--Comma Delimited (*.csv), *.csv," + &
    "HTML Table (*.htm), *.htm," + &
    "Excel File (*.xls), *.xls," + &
    "PSR File (*.psr), *.psr") <= 0 then
   return

Now we are calling the native Print(true,true), but we are needing to have the same dropdown list when the user clicks Print to File. Any help would greatly be appreciated.

Thank, 

Kevin Ridley Accepted Answer Pending Moderation
  1. Monday, 17 December 2018 19:44 PM UTC
  2. PowerBuilder
  3. # 1

I'm a little confused, sounds like you have migrated and got the 12.6 version of the pfc also, but you are no longer using the pfc_printdlg?  You switched to the standard Print(true, true) - second argument is actually the showprintdlg.  So you want to trap the selection from the showprintdlg only when it's File?  I'm confused why you wouldn't just go back to the pfc_printdlg?  Are you mixing some pfc and some non pfc?

 

That being said, what you could potentially do (yuk!) is override the Print(bool, bool) function in your dw ancestor and "roll your own" version of that method, eventually using the code you mentioned above.

 

This falls under:

"If it ain't broke, don't fix it"

Comment
There are no comments made yet.
Thomas Stewart Accepted Answer Pending Moderation
  1. Monday, 17 December 2018 20:29 PM UTC
  2. PowerBuilder
  3. # 2

The PFC 12.6 pfc_u_dw no longer includes pfc_printdlg event.  The function call:

function long PFC_PrintDlg (ulong hwnd, ref s_printdlgattrib printstruct) library "pbvm80.dll" is no longer compatible with 12.6.

That is correct, I want to capture the selection for the showprintdlg only when the users want to Print to File. The rest of the Print works.  If the users printed to a PRN file, this wouldn't be an issue.   I was wondering what the new call is or how do I code it now with the datawindow print function showing the print dialog box.

Thanks for you quick response. 

Comment
  1. Thomas Stewart
  2. Tuesday, 18 December 2018 19:05 PM UTC
Has the call to PFC_PrintDlg changed? It use to be:



FUNCTION long PFC_PrintDlg (ulong hwnd, ref s_printdlgattrib printstruct) library "pbvm120.dll"



of_printdlg (ref s_printdlgattrib astr_printdlg, window aw_obj )

long ll_hwnd

ll_hwnd = handle (aw_obj)

if ll_hwnd = 0 then

return -1

end if

astr_printdlg.s_printer = Space ( 90 )

return pfc_printdlg (ll_hwnd, astr_printdlg)



s_printdlgattrib:

global type s_printdlgattrib from structure

boolean b_allpages

boolean b_pagenums

boolean b_selection

boolean b_disablepagenums

boolean b_disableselection

boolean b_collate

long l_copies

boolean b_printtofile

boolean b_disableprinttofile

boolean b_hideprinttofile

long l_frompage

long l_topage

long l_minpage

long l_maxpage

string s_printer

end type



The reason I'm asking is that when I call the function, I get an error opening DLL library.



Thanks for your help,

Tom.

  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 18 December 2018 19:11 PM UTC
  2. PowerBuilder
  3. # 3
 
Hi Thomas;

    FWIW: The library for PB 12.6 in the PFC external function declaration should be: "pbvm126.dll", if you follow the PB naming convention.

Regards ... Chris
Comment
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Wednesday, 19 December 2018 13:22 PM UTC
  2. PowerBuilder
  3. # 4

I didn't realize the pfc got rid of the pfc_printdlg.  Sounds like your best bet would be to make the user decide if they were printing to a file or printer first, then if it's file, call your GetFileSaveName, then SaveAs, and if it's to the printer, just call the Print(true, false) to not display the dialogue if needed.

Comment
  1. Thomas Stewart
  2. Wednesday, 19 December 2018 14:43 PM UTC
But I still need the dialog box if they decide to print the datawindow. the dialog box works fine. If the user clicks the Print to File I would like to trap that or find out if they selected that option then run the GetFileSaveName and SaveAs. Side question what is a PRN file? The file that is saved when the Print to File is selected, a bunch of garbage.
  1. Helpful
  1. Kevin Ridley
  2. Wednesday, 19 December 2018 15:59 PM UTC
What I'm suggesting is a UI solution where you have the user select printing to a file or printer (or other) BEFORE you call the dw.Print(). If they select Print to Printer and you still need the dialogue, then you use dw.Print(true, true). If they select Print to File, then you call your GetFileSaveName, then SaveAs. It can be as simple as using 2 different menu options for Print or 2 different buttons, but the type of print is already selected before making the Print function call.

Hopefully that makes sense.
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Thursday, 20 December 2018 16:38 PM UTC
  2. PowerBuilder
  3. # 5

FYI:

Yes, Sybase removed the PFC_PRINTDLG() function from PBv10.
No, I've no idea why they thought this was a good idea.
Personally, I'd like a third boolean flag in the pfc_print() funtion that when TRUE will present the Print Dialog to the user. Or maybe a new callable function in PB2017 (hint, hint).


The easy way to restore this is to get a copy of the PBVM90.dll and include it in your library list.
This is NOT the recommended approach as you are using an obsolete DLL, and it's ANSI instead of UNICODE.


Another method is to call the Windows API directly. I was not able to get this working, but I stopped fighting with it because I just switched to the pfc_print (true,true) call.

From an old post:
   I'm trying to replace the call to the "PBVM90u.dll, pfc_printdlg ()"
function with a direct call to the Windows API function. Here's what I
have declared in the Local External Function section of the
PFC_N_CST_PLATFORMUNICODE object:

   Function long PrintDialog (ref s_printdlgattrib printstruct) library
"comdlg32.dll"



Olan

 

Comment
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.