Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Dec 09, 2019 6:07 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Getting printer setup problem with Windows 7
PostPosted: Sat Aug 06, 2011 6:58 pm 
Offline

Joined: Fri Jun 02, 2006 1:43 pm
Posts: 209
Location: Santa Ynez, CA
I have been unable to get the printer setup data for a printer other than the default printer when using Windows 7. It worked fine under XP because you could select a printer from the PageSetupDialog. When I try to use the OpenPrinterDialog to select a different printer, then call PageSetupDialog, the options are those of the default printer, not those of the printer just selected. Looking at the resulting PrinterSetup.SetupString confirms that it is still set up for the default printer.

The only work around I have found is to make the selected printer the default, run the PageSetupDialog, then switch restore the original default printer back to default. That's not very user friendly for my users. Is there a better way?


Top
 Profile  
Reply with quote  
 Post subject: Re: Getting printer setup problem with Windows 7
PostPosted: Sat Aug 06, 2011 9:30 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
You've got it backwards. Call PageSetupDialog before you call OpenPrinterDialog.


Top
 Profile  
Reply with quote  
 Post subject: Re: Getting printer setup problem with Windows 7
PostPosted: Sat Aug 06, 2011 11:42 pm 
Offline

Joined: Fri Jun 02, 2006 1:43 pm
Posts: 209
Location: Santa Ynez, CA
Calling PageSetupDialog first get the settings for the default printer. After calling OpenPrinterDialog and selecting a different printer, the SetupString still has the default printer data. This is the code in my FileSelectPrinter menu handler:
dim g As Graphics, ps As new PrinterSetup, rs As RecordSet
g = OpenPrinterDialog(nil)
if g <> nil then
MsgBox "Set top and side margins to one inch for best results"
if not ps.PageSetupDialog Then MsgBox "Invoices and reports may not print properly. Try again."
ps.MaxVerticalResolution = 300
ps.MaxHorizontalResolution = 300
rs = app.SetupDB.SQLSelect("SELECT * FROM Setups WHERE Name = 'PtrSetup'")
if rs <> nil and rs.RecordCount > 0 then
rs.Edit
rs.Field("Value").StringValue = ps.SetupString
rs.Update
app.SetupDB.Commit
end if
g = nil
end if

At one time I read the old PrinterSetup out of the database before calling the OpenPrinterDialog, but that did not work either.


Top
 Profile  
Reply with quote  
 Post subject: Re: Getting printer setup problem with Windows 7
PostPosted: Sun Aug 07, 2011 5:09 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
Quote:
Calling PageSetupDialog first get the settings for the default printer. After calling OpenPrinterDialog and selecting a different printer, the SetupString still has the default printer data.


Doesn't look like thats what you are doing.

How about this?

dim g As Graphics
ps As new PrinterSetup
rs As RecordSet
if ps = nil then exit sub //major problems if this occurs
ps.MaxVerticalResolution = 300
ps.MaxHorizontalResolution = 300
MsgBox "Set top and side margins to one inch for best results"
if not ps.PageSetupDialog Then
MsgBox "Invoices and reports may not print properly. If you have trouble, try again."
end if

rs = app.SetupDB.SQLSelect("SELECT * FROM Setups WHERE Name = 'PtrSetup'")
if rs <> nil then
if rs.RecordCount > 0 then
rs.Edit
rs.Field("Value").StringValue = ps.SetupString
rs.Update
app.SetupDB.Commit

else

//create a new PtrSetup record here, since there is not one already

end if
else
msgbox "Nil recordset: can not save the settings"
end if

end if

//if you intend to print using these settings, and ONLY if you are going to print:
//because if you get g and it goes out of scope, you WILL see a blank page eject

g = OpenPrinterDialog(ps)


Top
 Profile  
Reply with quote  
 Post subject: Re: Getting printer setup problem with Windows 7
PostPosted: Sun Aug 07, 2011 5:26 pm 
Offline

Joined: Fri Jun 02, 2006 1:43 pm
Posts: 209
Location: Santa Ynez, CA
What I am trying to do is select a printer other than the default printer. These suggestions all get the PrinterSetup for the default printer. Virtually every Windows program I have ever used allows me to choose any available printer using something similar to the OpenPrinterDialog. It does not appear it is possible to do this with Real Studio on Windows 7 (and probably Vista). Perhaps someone has figured out how to do this with Declares to the Windows API and be willing to share it.


Top
 Profile  
Reply with quote  
 Post subject: Re: Getting printer setup problem with Windows 7
PostPosted: Sun Aug 07, 2011 6:20 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Quote:
g = OpenPrinterDialog(nil)

Here you are severing any tie from ps to the printer you select. MInimally, it should b
g = OpenPrinterDialog(ps)

Otherwise, ps knows nothing about the printer the user selected.

I call PrinterSetupDialog and then OpenPrinterDialog in Windows 7 and have never had a problem. I suppose it might work in reverse, as long as you pass your printersetup variable into OpenPrinterDialog.


Top
 Profile  
Reply with quote  
 Post subject: Re: Getting printer setup problem with Windows 7
PostPosted: Sun Aug 07, 2011 8:39 pm 
Offline

Joined: Fri Jun 02, 2006 1:43 pm
Posts: 209
Location: Santa Ynez, CA
That sounds good in theory, and it works in XP. It doesn't work in Windows 7. The ps you get back is for the default printer, even if you selected a different one.


Top
 Profile  
Reply with quote  
 Post subject: Re: Getting printer setup problem with Windows 7
PostPosted: Sun Aug 07, 2011 11:08 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Have you tried it the way I first suggested, by calling PrinterSetupDialog first? Yes, that will return info related to the default printer, but the important bits of info are the margins and orientation. The printer will be replaced by the call to OpenPrinterDialog, leaving you with a printersetup that combines the two - the printer from OpenPrinterDialog, and the margins, etc., from PrinterSetupDialog.

And make sure you pass the printersetup object to OpenPrinterDialog.


Top
 Profile  
Reply with quote  
 Post subject: Re: Getting printer setup problem with Windows 7
PostPosted: Mon Aug 08, 2011 5:57 pm 
Offline

Joined: Fri Jun 02, 2006 1:43 pm
Posts: 209
Location: Santa Ynez, CA
Bingo. Now it works like it should and I'm not sure I can duplicate what was happening before.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group