Page 1 of 1
Printing TextGadget with NewLine
Posted: Mon Aug 27, 2012 7:48 pm
by VB6_to_PBx
Printing TextGadget with NewLine
the TextGadget correctly displays 2 lines of Text
but it only prints 1 line of Text
how can i Print the 2 lines of text like it shows in the TextGadget ??
Code: Select all
; TextGadget_with_NewLine_Math_Printing__v1
LoadFont(1,"Verdana",10)
SetGadgetFont(#PB_Default,FontID(1))
CrLf$ = Chr(13)+ Chr(10)
X.D = 123.456 * 2
txt$ = "TextGadget " + CrLf$ + StrD(X.D,5)
OpenWindow(0, 0, 0, 270, 160, "TextGadget_with_NewLine", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(1, 30, 10, 250, 40, txt$)
PrintRequester()
StartPrinting("")
LoadFont(2, "Arial", 80)
StartDrawing(PrinterOutput())
DrawingFont(FontID(2))
DrawText(100, 800, txt$,RGB(0,0,255),RGB(255,255,255))
StopDrawing()
StopPrinting()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Printing TextGadget with NewLine
Posted: Mon Aug 27, 2012 9:43 pm
by HeX0R
You have to do it on your own, like this:
Code: Select all
; TextGadget_with_NewLine_Math_Printing__v1
Procedure MyDrawText(x, y, Text$, FrontColor, BackColor)
Protected i, yPosAdd
For i = 0 To CountString(Text$, #LF$)
DrawText(x, y + yPosAdd, StringField(Text$, i + 1, #LF$), FrontColor, BackColor)
yPosAdd + TextHeight(StringField(Text$, i + 1, #LF$))
Next i
EndProcedure
LoadFont(1,"Verdana",10)
SetGadgetFont(#PB_Default,FontID(1))
X.D = 123.456 * 2
txt$ = "TextGadget " + #LF$ + StrD(X.D,5)
OpenWindow(0, 0, 0, 270, 160, "TextGadget_with_NewLine", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(1, 30, 10, 250, 40, txt$)
PrintRequester()
StartPrinting("")
LoadFont(2, "Arial", 80)
StartDrawing(PrinterOutput())
DrawingFont(FontID(2))
MyDrawText(100, 800, txt$,RGB(0,0,255),RGB(255,255,255))
StopDrawing()
StopPrinting()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Printing TextGadget with NewLine
Posted: Mon Aug 27, 2012 9:46 pm
by hichem
something like this :
Code: Select all
LoadFont(1,"Verdana",10)
SetGadgetFont(#PB_Default,FontID(1))
; CrLf$ = Chr(13)+ Chr(10)
X.D = 123.456 * 2
txt$ = "TextGadget " + #CRLF$ + StrD(X.D,5)
OpenWindow(0, 0, 0, 270, 160, "TextGadget_with_NewLine", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(1, 30, 10, 250, 40, txt$)
PrintRequester()
StartPrinting("")
LoadFont(2, "Arial", 80)
StartDrawing(PrinterOutput())
DrawingFont(FontID(2))
For ii = 1 To CountString(txt$,#CRLF$)+1
DrawText(100, 800+((ii-1)*TextHeight("gM")), StringField(txt$,ii,#CRLF$),RGB(0,0,255),RGB(255,255,255))
Next
StopDrawing()
StopPrinting()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
haven't seen your replay HeX0R sorry.
Re: Printing TextGadget with NewLine
Posted: Mon Aug 27, 2012 10:03 pm
by IdeasVacuum
I think you have to send the text as two printable lines.
If you want to do any serious amount of printing on Windows, use ABBKlaus's lib:
Printer Lib
However, I tested your example in the lib and two lines of output are still required:
Code: Select all
sOPT.s = "Orientation=" + Str(#DMORIENT_PORTRAIT) + ","
sOPT + "Papersize=" + Str(#DMPAPER_A4)
If Print_OpenPrinter("",sOPT)
Print_StartPrinting("My Print")
Print_Font("Arial",14,#PB_Font_HighQuality + 1)
Print_SetTextColor(RGB(0,0,255))
Print_Text(100,100,"TextGadget")
Print_Text(100,106,StrD(X.D,5))
Print_StopPrinting()
EndIf
Re: Printing TextGadget with NewLine
Posted: Tue Aug 28, 2012 9:05 pm
by VB6_to_PBx
thanks IdeasVacuum, for Link to Printer library
also thanks :
HeX0R
hichem
for solutions !