Silverfrost Forums

Welcome to our forums

CALLing PRINTER_OPEN

22 Apr 2009 10:10 #4460

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

23 Apr 2009 10:15 #4462

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.

23 Apr 2009 8:06 #4464

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

23 Apr 2009 9:27 #4465

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.

24 Apr 2009 8:39 #4466

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.

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
24 Apr 2009 10:20 #4467

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

25 Apr 2009 12:34 #4468

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

Please login to reply.