replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - CALLing PRINTER_OPEN
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CALLing PRINTER_OPEN

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Richard Besemer



Joined: 18 Apr 2009
Posts: 8

PostPosted: Wed Apr 22, 2009 11:10 pm    Post subject: CALLing PRINTER_OPEN Reply with quote

hi,

Is there a way to use 'PRINTER_OPEN@' without having to use winio@ to call it? The problem with using winio@ is that it draws an unused box then brings in the standard printer selection window. I would like to CALL the function if possable. A very short progran just using that function would be very helpfull.

Thanks
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Thu Apr 23, 2009 11:15 am    Post subject: Reply with quote

I do not recall a PRINTER_OPEN@. There is a PRINTER_OPEN callback that must be used in a winio@ context. There is also an OPEN_PRINTER@ that is used for graphical output in ClearWin+.

The problem is that the standard Microsoft "Open Printer" dialog only returns a handle to the device context for the printer and this is not immediately useful for the Fortran programmer.

It would probably be easier to hide the box that is causing you a problem.

Post a simple program for me and I will see if the offending box can be hidden.
Back to top
View user's profile Send private message AIM Address
Richard Besemer



Joined: 18 Apr 2009
Posts: 8

PostPosted: Thu Apr 23, 2009 9:06 pm    Post subject: Reply with quote

Here is a short program where a meaningless box appears. Thanks very much for your help.

Program Test6
INTEGER i, j, winio@
EXTERNAL test
i= winio@( '%sc', 'PRINTER_OPEN', 20, test)
WRITE (2,*) i
END

INTEGER FUNCTION test()
INTEGER k
do 15 k = 1,10
WRITE (20, *) k
15 END DO
test = 1
CLOSE (20)
RETURN
END
Back to top
View user's profile Send private message
Richard Besemer



Joined: 18 Apr 2009
Posts: 8

PostPosted: Thu Apr 23, 2009 10:27 pm    Post subject: Reply with quote

In the above sample program I modified the function to return a -1 instead of 1 and at least it gets rid of the box (blank button). It still appears under the printer selection window which is ugly but at least its gone. If there is a way to do this without opening the button (or hideing it so it never appears) that would be great.

Thanks for the help.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Fri Apr 24, 2009 9:39 am    Post subject: Reply with quote

I have not solved the problem completely but the following is OK except when you click on the Cancel button in the Printer dialog, in which case a hidden window is left open.

Code:
WINAPP
Program Test6
INCLUDE <windows.ins>
INTEGER i,hwnd,ictrl,test
EXTERNAL test
i=winio@('%hw&',hwnd)
i=winio@('%sc&', 'PRINTER_OPEN', 20, test)
i=winio@('%lw', ictrl)
call set_control_visibility@(hwnd,0)
END

INTEGER FUNCTION test()
INTEGER k
do 15 k = 1,10
WRITE (20, *) k
15 END DO
CLOSE (20)
test = 0
END
Back to top
View user's profile Send private message AIM Address
Richard Besemer



Joined: 18 Apr 2009
Posts: 8

PostPosted: Fri Apr 24, 2009 11:20 pm    Post subject: Reply with quote

Hi Paul,

Thanks so much for your help.

I found that the above also left the process running (linker hates that). I added a: ictrl = 2
CALL window_update@(ictrl)
Plus a loop to reprint. This kills the process but leaves the window (called OUTPUT) open. Here is what I have so far:

WINAPP
Program Test6
INCLUDE <windows.ins>
INTEGER i,hwnd,ictrl,test,prev_opened
CHARACTER*1 ians
EXTERNAL test
COMMON prev_opened
prev_opened = 0
ians = 'n'
10 IF( prev_opened .eq. 0) then
i=winio@('%hw&',hwnd)
i=winio@('%sc&', 'PRINTER_OPEN', 20, test)
i=winio@('%lw', ictrl)
CALL set_control_visibility@(hwnd,0)
write( 2, *) ' '
ELSE
i=winio@('%hw&',hwnd)
i=winio@('%sc&', 'PRINTER_OPEN1', 20, test)
i=winio@('%lw', ictrl)
CALL set_control_visibility@(hwnd,0)

END IF
ictrl = 2
CALL window_update@(ictrl)
Write (2, *) 'Do Another?'
READ (1,*) ians
IF( ians .eq. 'y') go to 10
END

INTEGER FUNCTION test()
INTEGER k, prev_opened, ictrl
COMMON prev_opened
do 15 k = 1,10
WRITE (20, *) k
15 END DO
CLOSE (20)
test = -1
prev_opened = 1
RETURN
END
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2402
Location: Yateley, Hants, UK

PostPosted: Sat Apr 25, 2009 1:34 pm    Post subject: Reply with quote

Richard,

In the event that your project is a console application - i.e. runs in a command prompt box - AND you have a printer connected to the parallel port (if your computer still has one) AND it is a printer that can accept a stream of ASCII characters and print them (i.e. is not a "Win printer"), then

OPEN (UNIT=99, FILE='LPT1:')

works, as indeed, it did decades ago under DOS. (In fact, even if it isn't a console application, provided the other two things apply, it works). You can buy a parallel to USB converter if you have a USB printer (not a USB to parallel!) and that might work.

It seems to me that you don't want to write a Windows application, but nevertheless (because the only way you can realistically run your program is under Windows) want to use Windows' services to select a printer and print.

May I suggest going the whole way and turning your program into a proper Windows application? If you send me a private message with an e mail address, I will send you my multipage "tutorial", with some source code and icons to get you started.

Regards

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group