Page 1 of 1

Print Preview

Posted: Wed Mar 12, 2003 8:16 pm
by BackupUser
Code updated For 5.20+

Restored from previous forum. Originally posted by Num3.
Here it is....

Original code by fred + my own routines for printig

Code: Select all

Declare ycm(x.f)
Declare xcm(x.f)


Procedure xcm(x.f)
  
  result = x * (675/ 21)
  
  ProcedureReturn result
  
EndProcedure


Procedure ycm(x.f)
  
  result = x * (467 / 29.7)
  ProcedureReturn result
  
EndProcedure


Procedure WindowCallback(WindowID, Message, lParam, wParam)
  If Message = #WM_PAINT
    StartDrawing(WindowOutput(0))
    DrawImage(ImageID(0), 50, 50)
    StopDrawing()
  EndIf
  
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure


If OpenWindow(0, 100, 100, 600, 500, "PureBasic - Image", #PB_Window_SystemMenu)
  
  Gosub CreateImage
  SetWindowCallback(@WindowCallback())
  
  Repeat
    EventID = WaitWindowEvent()
  Until EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button
  
EndIf

End

CreateImage:

CreateImage(0, 657, 467) ; this is 1/10 of a 600dpi page
LoadFont(0, "Arial", ycm(1))
LoadFont(1, "Arial", ycm(0.5))
If StartDrawing(ImageOutput(0))
  
  
  FrontColor(RGB(255, 255, 255))
  Box(0, 0, 657, 467)
  
  FrontColor(RGB(0, 0, 0))
  DrawingFont(FontID(0))
  
  DrawText(xcm(1), ycm(1),"PureBasic Printer Test")
  
  DrawingFont(FontID(1))
  
  DrawText(xcm(5), ycm(16),"PureBasic Printer Test 2")
  
  ResizeImage(0,500,400)
  
  StopDrawing()
  
EndIf

Return

--
Kind Regards
Rui Carvalho

Old programmers never die... They branch into a subroutine...

Posted: Sat Mar 15, 2003 9:22 am
by BackupUser
Restored from previous forum. Originally posted by Num3.

For info on printing, check this topic:

viewtopic.php?t=5256

enjoy

--
Kind Regards
Rui Carvalho

Old programmers never die... They branch into a subroutine...