Date: 02-16-2022
Return to Index
created by gbSnippets
'This uses a 39 barcode font. The font is separately installed
'and is simply used by this program
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_ButtonCreate = 500 : %IDC_ButtonPrint = 501 : %IDC_Graphic = 502
Global hDlg, hGraphic As DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,250,150, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_ButtonCreate,"Create Barcode", 20,10,100,20
Control Add Button, hDlg, %IDC_ButtonPrint,"Print Barcode", 140,10,100,20
Control Add Graphic, hDlg, %IDC_Graphic,"", 25,40,200,100, %WS_Border
Graphic Attach hDlg, %IDC_Graphic
Graphic Color %Black, %White
Graphic Clear
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local hFont, hFontBarCode As DWord
Local PrinterPPIx, PrinterPPIy, ScreenPPIx, ScreenPPIy As Long
Local ScaleX, ScaleY As Single
Select Case CB.Msg
Case %WM_Command
Select Case CB.Ctl
Case %IDC_ButtonCreate
Font New "Arial", 10, 0 To hFont
Font New "Free 3 of 9", 40, 0 To hFontBarCode
Graphic Set Font hFont
Graphic Set Pos (10,10)
Graphic Print "ABC123"
Graphic Set Pos (10,30)
Graphic Set Font hFontBarCode
Graphic Print "*ABC123*"
Case %IDC_ButtonPrint
XPrint Attach Default
XPrint Get PPI To PrinterPPIx,PrinterPPIy
Graphic Get PPI To ScreenPPIx,ScreenPPIy
ScaleX = PrinterPPIx/ScreenPPIx
ScaleY = PrinterPPIy/ScreenPPIy
XPrint Stretch hDlg, %IDC_Graphic, (0,0)-(200,100) To (0,0)-(200*ScaleX,100*ScaleY)
XPrint FormFeed
XPrint Close
End Select
End Select
End Function
'gbs_00573
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm