Hello all the specialists
The following code prints the bitmaps loaded in the window properly,
but not the texts. Does someone know the reasen ?
I cant figure it out since 4 days and I'm done ! :'(
Reinhard
window w_print,w_main
int run,screen_x,screen_y, pic_1, pic_2
string reportstring_11 = "reportstring_11", reportstring_12 = "reportstring_12", reportstring_21 = "reportstring_21", reportstring_22 = "reportstring_22"
'=========================================================================
SUB mainhandler(),int
SELECT @MESSAGE
CASE @IDCREATE
CONTROL w_main,@BUTTON,"make content", 30,30,200,30,0,1
CONTROL w_main,@BUTTON,"print window",260,30,200,30,0,2
CASE @IDCONTROL
SELECT @CONTROLID
CASE 1
OPENWINDOW w_print,0,0,screen_x,screen_x*300/210 ,@NOAUTODRAW|@MINBOX|@CAPTION|@MINIMIZED,0,"Print",&printhandler
' create a window sized like A4 portrait paperformat, about 2560 x 3622 on my screen
' noautodraw to get the whole window printed, autodraw would only print the visible aera
' minimized to hide it for the user
create_content()
CASE 2
PRINtWINDOW w_print
CLOSEWINDOW w_print
endselect
CASE @IDCLOSEWINDOW
run = 0
ENDSELECT
RETURN 0
endsub
'=========================================================================
sub create_content(),int
SHOWIMAGE w_print,pic_1,@IMGSCALABLE ,200, 200 ,400,400
move w_print, 200, 800 : print reportstring_11
move w_print,1200, 800 : print reportstring_12
' commands above here should produce printing in the visible aera of the window
' the image does, the text not
' commands below here not, but should be printed
SHOWIMAGE w_print,pic_2,@IMGSCALABLE ,200,2400 ,400,400
move w_print, 200, 3000 : print reportstring_21
move w_print,1200, 3000 : print reportstring_22
' the image does, the text not
return 0
endsub
'=========================================================================
SUB printhandler(),int
SELECT @MESSAGE
CASE @IDCREATE
setfont w_print,"Arial",16,800
frontpen w_print,rgb(0,0,0)
backpen w_print,rgb(255,255,255)
CASE @IDPAINT
create_content()
CASE @IDMOUSEMOVE
SETFONT w_print, "courier", 10, 400
move w_print, 700, 10
print w_print,using("x= #### y= ####", @MOUSEX,@MOUSEY)
setfont w_print,"Arial",16,800
CASE @IDCLOSEWINDOW
deleteimage pic_1,@IMGSCALABLE
deleteimage pic_2,@IMGSCALABLE
run = 0
ENDSELECT
RETURN 0
endsub
'=========================================================================
'here starts the mainline
getscreensize screen_x,screen_y
OPENWINDOW w_main,200,200,490,200 ,@CAPTION,0,"MAIN",&mainhandler ' a tiny userinterface
pic_1 = loadimage "pr_anypic1.bmp",@IMGSCALABLE
pic_2 = loadimage "pr_anypic2.bmp",@IMGSCALABLE
run = 1
waituntil run = 0
CLOSEWINDOW w_main
deleteimage pic_1,@IMGSCALABLE
deleteimage pic_2,@IMGSCALABLE
END
Hi Reinhard,
I haven't fully worked through your program, but at the point in sub create_content(), where you print your text, you haven't specified which window to print to .. :)
It needs to be something like ..
SHOWIMAGE w_print,pic_1,@IMGSCALABLE ,200, 200 ,400,400
move w_print, 20, 600 : print w_print,reportstring_11
move w_print,120, 700 : print w_print,reportstring_12
I've temporarily altered the position co-ordinates so that I could check the text was displaying in the window - I only run 1024 X 768 ::)
best wishes, :)
Graham
This shows both pictures and reportstring_22, but not the other 3. Also, reportstring_22 is not in the same location in the print out.
sub create_content(),int
SHOWIMAGE w_print,pic_1,@IMGSCALABLE ,200, 200 ,400,400
move w_print, 200, 100 : print w_print, reportstring_11
move w_print, 800, 100 : print w_print, reportstring_12
' commands above here should produce printing in the visible area of the window
' the image does, the text not
' commands below here not, but should be printed
SHOWIMAGE w_print,pic_2,@IMGSCALABLE ,800, 200 ,400,400
move w_print, 200, 700 : print w_print, reportstring_21
move w_print, 800, 700 : print w_print, reportstring_22
' the image does, the text not
return 0
endsub
Will keep playing, but at least this got 1 piece of text onto the print out.
Bill
At first, thank You all for Your help.
I was playing around too and figured out the same.
Only the last string is printed out and is not on the Position it should be. :o
I have attached a modified version of the program for better Debugging.
(No more pics needed, just "rect" and "print", and autoscaling to the screen running on.)
If you look in the print window, You can see all 4 strings on the right position. :D
On the printout not. :(
in expectant hope ;)
Reinhard
window w_print,w_main
int run,screendx,screendy,ccx,ccy,cdx,cdy
def string_11:string:string_11 = "11"
def string_12:string:string_12 = "12"
def string_21:string:string_21 = "21"
def string_22:string:string_22 = "22"
'=========================================================================
sub makeprintwindow(),int ' open a window sized like A4 portrait paperformat. Now visible for debugging, later HIDDEN to hide it for the user
OPENWINDOW w_print,650,0,screendx*100/100,screendx*143/100 ,@NOAUTODRAW|@FIXEDSIZE|@MINBOX|@CAPTION,0,"Print",&printhandler '
frontpen w_print, rgb(1,2,3)
backpen w_print, rgb(251,252,253)
getclientsize w_print,ccx,ccy,cdx,cdy
move w_main,30,330 : print w_main, using("getclientsize : dx = ###,### dy = ###,###",cdx,cdy)
RETURN 0
endsub
'=========================================================================
sub create_content(),int ' only put the content in the print window with rect and print
rect w_print, 10, 10, cdx- 20, cdy - 20,rgb(255,0,0),rgb(255,0,0)
rect w_print, 40, 40, cdx- 80, cdy - 80,rgb(0,255,0),rgb(0,255,0)
rect w_print, 80, 80, cdx-160, cdy - 160,rgb(0,0,255),rgb(128,128,128)
rect w_print,cdx/8*2-4,cdy/8*2-4, 25, 28 ' in here should be string_22
move w_print, cdx/8*1, cdy/8*1
print w_print,string_12
move w_print, cdx/8*1, cdy/8*2
print w_print,string_11
move w_print, cdx/8*2, cdy/8*1
print w_print,string_21
move w_print, cdx/8*2, cdy/8*2
print w_print,string_22
return 0
endsub
'=========================================================================
SUB mainhandler(),int
SELECT @MESSAGE
CASE @IDCREATE
CONTROL w_main,@BUTTON,"make content 1", 25, 25,200,25,0, 1
CONTROL w_main,@BUTTON,"print window", 250, 25,200,25,0, 9
CONTROL w_main,@BUTTON,"exit", 250,200,200,25,0,999
CASE @IDCONTROL
SELECT @CONTROLID
CASE 1
makeprintwindow()
create_content()
CASE 9
PRINtWINDOW w_print
CLOSEWINDOW w_print
CASE 999
CLOSEWINDOW w_main
run = 0
endselect
CASE @IDCLOSEWINDOW
CLOSEWINDOW w_main
run = 0
ENDSELECT
RETURN 0
endsub
'=========================================================================
SUB printhandler(),int
SELECT @MESSAGE
CASE @IDCREATE
create_content()
CASE @IDPAINT
create_content()
CASE @IDCLOSEWINDOW
CLOSEWINDOW w_print
ENDSELECT
RETURN 0
endsub
'=========================================================================
'here starts the mainline
getscreensize screendx,screendy
OPENWINDOW w_main,0,0,600,400 ,@CAPTION,0,"MAIN",&mainhandler ' a tiny userinterface
run = 1
waituntil run = 0
CLOSEWINDOW w_main
END
There are numerous things wrong with your program but issue at hand is you have added the @NOAUTODRAW flag to the window you want to print. That disables all the hidden drawing functionality that IWBasic normally takes care of in the background so you don't have to. Windows uses "device contexts" for displaying information /drawing on the screen/printer etc. There's a whole section in the API on device contexts. There is a conversion that takes place when you go from the screen to the printer between two device contexts.
The bottom line is that by using the @NOAUTODRAW flag you said "I'll take care of properly constructing and supplying information to the device context for the display at the proper time and that when I'm ready to print I will do the proper conversion between the display and selected printer device contexts." And you didn't do that.
Do this:
remove the @NOAUTODRAW| entry
comment out the 3 lines that print the color rectangles (to save ink)
compile and run your same program
you should see that the 4 numbers are there and in their proportional places; it scaled your image to fit on the page.
then you can un-comment your colored rectangles and compile and run again and it should be right.
As for other problems I noticed.
You are opened the same window over and over again in multiple places and even in a @IDPAINT handler.
You do that in a "real" in will have random crashes for no apparent reasons.
Reinhard
Maybe if you tell us what kind of application you are trying to write we can help you out better.
You are the best !
My application shall visualise the result of a voting.
The voting data ( e.g. 7x yes, 23x no,9 aban, 3x no vote) will be received via Network, not yet implemented.
But there is a simulation possibility in the main window.
You can choose "random vote" or pull the faders as you want and click "fader vote".
Then click "make Report".
With the Combos the user can select common texts for his Report, still in beta (more Omega)
Now click "print" and then you can see my Problem on the printout (not in the window !)
There is a Debugging window below the main window where You can see what happens in the Subs.
Printing is made in the xf_reporting.inc, the 6th Sub.
Thank You and Good luck
I forgot to mention :
I still use the old netlib.dll for Networking.
It is in the zip, named xx_netlib.dll and I have createtd an Import lib of it.