|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Bartl
Joined: 16 Oct 2009 Posts: 58 Location: München
|
Posted: Wed Mar 13, 2013 8:40 am Post subject: call to open_Printer doesn't work |
|
|
Hello,
I have following problem(see code)
The line >kp=open_printer@(hnd1)< doesn't work.
If I delete the line above >call window_update@(control_var)< then it works.
What is wrong?
Johann
Code: |
winapp 0,0
program test
include<windows.ins>
integer*4 control_var,kp,hnd1,sel
character*25 zeile(2)
data hnd1/1/
data zeile(1) /' Ende '/
data zeile(2) /' call to printer_open '/
save control_var
external cb_func,iesc_monitor
i=winio@('%sz&',300,200)
i=winio@('%ww%bg[grey]%fn[ARIAL]&')
i=winio@('%ca[ Auswahlmenue]&')
i=winio@('%2nl&')
i=winio@('%ac[ESC]&' , iesc_monitor)
i=winio@('%^~25.2ls&',zeile,2L,sel,1,cb_func)
i=winio@('%ff%2nlAbbruch mit ESC Taste!%nl%nl')
if(sel.eq.1) stop
if(sel.eq.2) then
i=winio@('%ww[no_frame]%`lw',control_var)
i=winio@('%sz&',500,300)
i=winio@('This is a child window%2nl%ch&',control_var)
i=winio@('%ww[no_frame]%lw',control_var)
control_var = 0
call window_update@(control_var) ! >>>> I suppose this is the problem <<<<
kp=open_printer@(hnd1)
endif
stop
end
integer*4 function cb_func()
include <windows.ins>
cb_func = 0
end
integer*4 function iesc_monitor()
include <windows.ins>
iesc_monitor = 0
end
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7930 Location: Salford, UK
|
Posted: Wed Mar 13, 2013 9:40 am Post subject: |
|
|
Setting control_var to zero and then calling window_update@, closes the window.
You should probably leave out both statements then the window can be closed by user interaction. |
|
Back to top |
|
|
Bartl
Joined: 16 Oct 2009 Posts: 58 Location: München
|
Posted: Wed Mar 13, 2013 11:03 am Post subject: |
|
|
Hi Paul you are right.
But this is only a small test program to show the problem.
In my huge main program the call >open_printer< is nearly at the end of the program after a question if to print or not.
After a long search I found the reason why it doesn’t work (as shown in the code).
Therefore I would like to have the call >open_printer< after several open and close of child windows.
I don’t understand why the call >window_update< have an effect or a connection to the call >open_printer<.
Johann |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7930 Location: Salford, UK
|
Posted: Wed Mar 13, 2013 11:56 am Post subject: |
|
|
I have tested your code and for me the printer dialog is displayed.
I don't know of any reason why it should be different for me.
If you can run the program within the debugger, you might get some more information.
It might be helpful to read up on what OPEN_PRINTER@ does.
The native printer dialog returns a device context, so in the end you will need something to display in this context. |
|
Back to top |
|
|
Bartl
Joined: 16 Oct 2009 Posts: 58 Location: München
|
Posted: Wed Mar 13, 2013 4:34 pm Post subject: |
|
|
Hi Paul,
thank you for your quickly reply.
Problem is that I am no expert in using the debugger.
It seams, that after a call to a child window the open_printer doesn’t work.
This happens on my Computer with XP and also on 2 Laptops with Vista and Windows 7.
Now I tried to embed the open_printer call in a child windows call(see code) this seams to work but I don’t know why.
I have to make further tests, because my program has several child windows an several open_printer calls.
Johann
Code: |
winapp 0,0
program test
include<windows.ins>
integer*4 control_var,kp,hnd1,sel
character*25 zeile(2)
real*8 d, delta_d
data hnd1/1/
data zeile(1) /' Ende '/
data zeile(2) /' call to printer_open '/
save control_var
external cb_func,iesc_monitor
control_var=0
kp=0
sel=0
d= 0.0
delta_d = 0.0001
i=winio@('%sz&',300,200)
i=winio@('%ww%bg[grey]%fn[ARIAL]&')
i=winio@('%ca[ Auswahlmenue]&')
i=winio@('%2nl&')
i=winio@('%ac[ESC]&' , iesc_monitor)
i=winio@('%^~25.2ls&',zeile,2L,sel,1,cb_func)
i=winio@('%ff%2nlAbbruch mit ESC Taste!%nl%nl')
if(sel.eq.1) stop
if(sel.eq.2) then
i=winio@('%ww[no_frame]%`lw',control_var)
i=winio@('%sz&',500,300)
i=winio@('This is a child window%2nl%ch&',control_var)
i=winio@('%2nl%ta%20br&',d,RGB@(255,255,0))
i=winio@('%ww[no_frame]%lw',control_var)
do 100 k=1,10000
d = d + delta_d
100 call window_update@(d)
control_var = 0
call window_update@(control_var)
!-------- added --------------
i=winio@('%ww[no_frame]%`lw',control_var)
i=winio@('%ww[no_frame,no_caption]%ch&',control_var)
i=winio@('%ww[no_frame]%lw',control_var)
kp=open_printer@(hnd1)
control_var = 0
call window_update@(control_var)
endif
!-------- added --------------
stop
end
integer*4 function cb_func()
include <windows.ins>
cb_func = 0
end
integer*4 function iesc_monitor()
include <windows.ins>
iesc_monitor = 0
end
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7930 Location: Salford, UK
|
Posted: Wed Mar 13, 2013 4:59 pm Post subject: |
|
|
I have used Windows 7 (64 bit OS) for my test.
I am wondering how you plan to use OPEN_PRINTER@.
Do you have a graphics region that you have plotted to before calling this routine? |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed Mar 13, 2013 10:44 pm Post subject: |
|
|
I'm wondering too! Just to be sure, this is (a) something that you are trying for the first time, not (b) something you have used a lot, but now find that it doesn't work.
If it is case (a), then you have to generate all the graphics image, and then by using CLOSE_PRINTER@ or WINDOW_UPDATE@ the image is sent to the printer, and you probably haven't created any image!
Eddie |
|
Back to top |
|
|
Bartl
Joined: 16 Oct 2009 Posts: 58 Location: München
|
Posted: Thu Mar 14, 2013 9:25 am Post subject: |
|
|
Hi,
my solution to use open_printer results from the ftn95 online help.
I don’t have a graphics region plotted to before calling this routine.
When I want to send results or graphic to a printer, in my understanding, I have to call the open_printer@ command, then write all draw commands like call draw_characters@, call DRAW_ELLIPSE@ a.s.o and at least the close_printer@ command.
I would be happy if you could give me a better solution to open a standard printer menu with the possibility to choose a windows printer and to send results to this printer.
It’s difficult to explain my program because in the meantime it has about 30 subroutines.
The open_printer command mostly works, when I press the print button in my program two or three times.
Because this is not acceptable I searched for the reason and found it in my both examples.
In fact the first example from Mar 13, 2013 8:40 doesn’t work(no printer menu appeasrs) while the second example from Mar 13, 2013 4:34 pm works (on our 32 bit Computers) and I was sure that is the problem.
I am also sure that it is an error by myself but I don’t find it.
Johann |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7930 Location: Salford, UK
|
Posted: Thu Mar 14, 2013 12:50 pm Post subject: |
|
|
I suggest that you try creating a graphics region (and maybe draw to it) before calling OPEN_PRINTER@. You can do this without creating any windows.
If there is a problem then it may be that OPEN_PRINTER@ has some dependency on data associated with a window that has just closed. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Thu Mar 14, 2013 3:20 pm Post subject: |
|
|
Is this true that the only way to see your graphics work you always need a printer???? And you see your graphics not on screen but being printer on paper? What specific purpose of doing that, do you need super-resolutions?
Never used Open_printer or something of this sort related to the printer in soon 25 years of using this compiler. I do all graphics work in CWP using %gr or %og. Before CWP there also existed the way to plot on normal visible on screen graphics region. After that done you chose to print or not but again since the end of 80th i never printed anything on paper, everything is used in electronic form |
|
Back to top |
|
|
Bartl
Joined: 16 Oct 2009 Posts: 58 Location: München
|
Posted: Mon Mar 18, 2013 8:25 am Post subject: |
|
|
Hello
1. Our office is busy in design and dimension of steel and concrete structures.
The software is made for dimensions of steel constructions and makes separate proofs for each steel position.
I need one page for each position with a lot of text results and a small different graphic for each position in ranges of 1 position (=page) until 500 positions and more.
For the moment I have two possibilities to select and regard the results based on my actual knowledge about Fortran programing:
a) Write into a file without graphic and look at it with a text editor like TXTPAD
b) Print the results with graphic (normally) to the PDF-printer with creation a PDF document and look at it with Adobe Acrobat
Both possibilities work fine. When the PDF document is ok I can send it directly to the customer (without creating a lot of paper)
2. I started programming with Fortran 4 on DOS machines and changed to windows programming with ftn95 only about 4 years ago.
I am no professional in ftn95 and learned it mainly with the online help and now I am really happy to be able to create such helpful software with ftn95.
3. Now in the weekend a found by chance a topic in the ClearWin forum from 2008 from “wosl” about this problem. Now I know what you mean and understand how create graphic with %gr and select the screen or printer for graphic output.
You see it would be very very helpful to get simple working examples with source codes to know about the possibilities of clearwin in additional to the single descriptions in the online help.
4. But back to the problem.
Fact is, that in my first example the printer selection menu doesn’t appear and in the second example it appears. I suppose that this has to do with the control variable ctrl because it only happens after a call to %lw.
For the moment a use the second example and it works fine.
Is there anything to be said against using this solution until I have a better solution?
Johann |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Mar 18, 2013 12:15 pm Post subject: |
|
|
Bartl,
You never entirely master this subject!
If you have a %gr area on the screen, then you have a whole set of subroutine calls to draw to it. In my case, I have these wrapped up in a nested set of subroutines. Once you have opened the printer for graphics output, then basically all you have to do is to select the graphics object that is the printout, go through all the graphics commands again, and then update or close the printer. If all the graphics commands are obtained by calling the entry point to that nested set of subroutines, then it is in principle a very simple activity.
What makes it difficult is that the printer page contains a lot more pixels than the screen, and has a higher resolution. All printers are different, but there are fewer options for dots per inch (dpi).
Here is a code fragment:
Code: | IB = OPEN_PRINTER@ (jHDC)
IF (IB .EQ. 0) GO TO 5
CALL SET_CLEARWIN_STRING@(PRINTER_DOCUMENT, 'Bartl graphic')
CALL GET_CURRENT_DC@ (jHDC)
CALL USE_RGB_COLOURS@(0,1)
C CALL USE_RGB_COLOURS@(0,.true.) ! this is the same !
C
C This is a printer. It would like to use colour indices 0..15. To
C force it to use RGB colours, we need the above call. Now it is
C the same as the screen. (Not obvious!!!!) .
C
ixdpi = GetDeviceCaps(jHDC, LOGPIXELSX)
iydpi = GetDeviceCaps(jHDC, LOGPIXELSY)
jXRES = GetDeviceCaps(jHDC, HORZRES)
jYRES = GetDeviceCaps(jHDC, VERTRES)
C This is about very hi-res printers. Since the line thickness is
C specified in pixels, lines get very thin with 1200 or 1440 dpi
C modes. I haven't looked at all modes, but have gone for more
C than Epson 720 dpi mode. This should be OK for HP printers
C which have 150, 300, 600 and possibly 1200 dpi modes
C .
ISCALE = 1
IF (IXDPI .GT. 700) THEN
ISCALE = 5
ELSE IF (IXDPI .GT. 1100) THEN
ISCALE = 9
ENDIF
CALL SET_LINE_WIDTH@(ISCALE) ! one pixel lines are rubbish !
C At this point, you need to work out how many of the available
C pixels you want to use - all of them or is the image taking up
C only part of the page? At some point you need to work out the
C scaling factors (units per pixel) for this. There may be
C multiple scales e.g. m/pixel, kN/pixel etc
C ... New_Page@ flashes the image to the printer, as
C does Close_Printer@
CALL IMAGE (jHDC, jXRES, jYRES, SCALE) ! also add position
CALL CLOSE_PRINTER@ (jHDC)
CALL POPOK ('Image sent to printer')
Bitmap_FUNCTION=1
RETURN |
IMAGE is my routine for drawing an image. I find it useful to tell the user that the print has been done - after all, the printer might even be in a different room ...
Code: | SUBROUTINE POPOK(TEXT)
C ----------------------
INCLUDE <WINDOWS.INS>
CHARACTER*(*) TEXT
IA=WINIO@('%ca[For Information]&')
IA=WINIO@('%bg[white]&')
IA = WINIO@('%cn%si*'//TEXT//'&')
IA=WINIO@('%2nl%cn%`7bt[OK]')
RETURN
END |
I'll post the continuation in a new post ... |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Mon Mar 18, 2013 5:27 pm Post subject: |
|
|
Bartl,
Can you post some visual examples of what you are doing and how ideally in your wildest dream you want it to look? |
|
Back to top |
|
|
|
|
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
|