Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
Enum Equates Singular
IDC_Graphic = 500
IDC_Button25
IDC_Button50
IDC_Button100
IDC_Button200
IDC_Button400
End Enum
Global hDlg As Dword
Global Zoom As Single
Function PBMain() As Long
Local w,h As Long
Dialog New Pixels, 0, "PowerBASIC",300,300,350,300, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button25, "25%", 10,10,50,20
Control Add Button, hDlg, %IDC_Button50, "50%", 80,10,50,20
Control Add Button, hDlg, %IDC_Button100, "100%", 150,10,50,20
Control Add Button, hDlg, %IDC_Button200, "200%", 220,10,50,20
Control Add Button, hDlg, %IDC_Button400, "400%", 290,10,50,20
Zoom = 1 : w = Zoom * 8.5 * 96 : h = Zoom * 11 * 96 '816 x 1056
Control Add Graphic, hDlg, %IDC_Graphic, "", 10, 40, w,h, %WS_Border
PrintStuff
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local w,h As Long
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Button25
Zoom = 0.25 : w = Zoom * 8.5 * 96 : h = Zoom * 11 * 96 '816 x 1056
Control Set Size hDlg, %IDC_Graphic, w,h
PrintStuff
Case %IDC_Button50
Zoom = 0.5 : w = Zoom * 8.5 * 96 : h = Zoom * 11 * 96 '816 x 1056
Control Set Size hDlg, %IDC_Graphic, w,h
PrintStuff
Case %IDC_Button100
Zoom = 1.0 : w = Zoom * 8.5 * 96 : h = Zoom * 11 * 96 '816 x 1056
Control Set Size hDlg, %IDC_Graphic, w,h
PrintStuff
Case %IDC_Button200
Zoom = 2.0 : w = Zoom * 8.5 * 96 : h = Zoom * 11 * 96 '816 x 1056
Control Set Size hDlg, %IDC_Graphic, w,h
PrintStuff
Case %IDC_Button400
Zoom = 4.0 : w = Zoom * 8.5 * 96 : h = Zoom * 11 * 96 '816 x 1056
Control Set Size hDlg, %IDC_Graphic, w,h
PrintStuff
End Select
End Select
End Function
Sub PrintStuff
Local hFont As Dword
Local x,xx,y,yy,w,h As Long, L,T,R,B As Single
Font New "Tahoma", 10, 1 To hFont
XPrint Attach Default
XPrint Preview hDlg, %IDC_Graphic
XPrint Set Font hFont
XPrint Get Canvas To w,h ': ? Str$(w) + Str$(h)
XPrint Get Margin To L,T,R,B ': ? Str$(L) + Str$(T) + $CrLf + Str$(R) + Str$(B)
XPrint Get Scale To x,y,xx,yy ': ? Str$(x) + Str$(y) + $CrLf + Str$(xx) + Str$(yy)
XPrint Box (0,0)-(w,h)
XPrint Set Pos (0,0)
XPrint "First Control"
End Sub
' XPrint Scale (0,0)-(8.5*1200,11.0*1200)
'gbs_01359
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm