縦書き例:はがき印刷 <TOP>
縦書き表示例。ついでにはがきを印刷してみます。フォントの変更も可能です。
初期状態はMS ゴシックに設定されています。フォント変更時@の付いたフォントおよびプロポーショナルフォントは選択しないでください。
フォーム設計
宛先の郵便番号はMS ゴシック固定です。宛先郵便番号、宛名、差出人名前および電話番号の部分は均等割付をしています。
スタンプ(50円)はSTAMP.BMPをロードしていますが、ない場合は50円切手と表示されます。
文字サイズはプログラム上で指定していますので無効です。
if choosefont(ffont, 0, 0, 0) then の場合
if choosefont(ffont, rgbcolor, -1, 0) then の場合
if choosefont(ffont, rgbcolor, -1, -1) then の場合
'================================================================ '= 縦書き一例・はがき印刷 '================================================================ #include "Windows.bi" Var Shared MAINFORM As Object Var Shared PRT As Object Var Shared BITMAP As Object Var Shared F_NAME$ As String 'フォント名 Var Shared F_POINT As single '文字ポイント Var Shared F_SPACE As single '文字間隔(通常はフォントサイズ) Var Shared F_FRAME As single '均等割付時の文字枠長 Var Shared FFONT As FONT 'フォント構造体 Var Shared LM As Integer '文字列長さ Var Shared PRM As PRINTPARAM Var Shared ATENA$(3) As String Var Shared SEnd$(4) As String Var Shared TXT$ As String Var Shared XPOS As Integer Var Shared YPOS As Integer Var Shared CARDW As Integer Var Shared CARDH As Integer Var Shared LX As Integer Var Shared LY As Integer def fnWD(X) = F_POINT/72*254 '文字ポイントを1/10o(MAPMODE=2)に合わす PRINTERObject PRT BITMAPObject BITMAP Declare Sub MAINFORM_START edecl () Declare Sub POSTCARD_DRAW edecl () Declare Sub ATENA_DRAW edecl () Declare Sub TATEGAKI_DRAW edecl () Declare Sub YOKOGAKI_DRAW edecl () Declare Sub MNUFONTSEL_ON edecl () Declare Sub MNUEXIT_ON edecl () Declare Sub MAINFORM_QUERYCLOSE edecl (CANCEL%,ByVal MODE%) '================================================================ '= '================================================================ Sub MAINFORM_START() If PREVINSTANCE Then RES = MESSAGEBOX(GETWINDOWTEXT, "このアプリケーションは実行中です!", 0, 0) : End End If ATENA$(0) = "佐々木 小次郎" ATENA$(1) = "064-0923" ATENA$(2) = "北海道札幌市中央区南12条西34丁目5-6" ATENA$(3) = "巌流マンション803" SEnd$(0) = "阪神 虎之助" SEnd$(1) = "654-0103" SEnd$(2) = "兵庫県神戸市須磨区黒山台5丁目67-8" SEnd$(3) = "タイガーハイツ603" SEnd$(4) = "電話・FAX078-789-0123" SETWINDOWTEXT "縦書例:はがき印刷" CARDW = 1000 CARDH = 1480 SETMAPMODE 2 SETWINDOWSIZE CARDW+60, CARDH+170 MOVEWINDOW 50, 50 SHOWWINDOW -1 F_NAME$ = "MS ゴシック" FFONT.FFNAME = F_NAME$ POSTCARD_DRAW ATENA_DRAW End Sub '================================================================ '= '================================================================ Sub POSTCARD_DRAW() on error goto *ER_TRAP LX = 20 LY = 20 line(LX, LY)-(LX+CARDW, LY+CARDH),,15,bf For X = 435 To 575 step 70 line(X+LX, 120+LY)-(X+60+LX, 200+LY),,5,b line(X+LX+2, 120+LY+2)-(X+60+LX-2, 200+LY-2),,5,b Next For X = 650 To 860 step 70 line(X+LX, 120+LY)-(X+60+LX, 200+LY),,5,b Next line(635+LX, 160+LY)-(650+LX, 160+LY),,5 BITMAP.LOADFILE "STAMP.BMP" STRETCHBITMAP BITMAP, 90+LX, 110+LY, 180, 250 BITMAP.DELETEObject Exit Sub *ER_TRAP 'STAMP.BMPがない場合 line(90+LX, 110+LY)-(270+LX, 360+LY),preset,8,bf SETFONTNAME "MS ゴシック" SETFONTSIZE 12 SETFONTBOLD -1 symbol(135+LX, 180+LY),"50円",1,1,15 symbol(135+LX, 230+LY),"切手",1,1,15 resume Next End Sub '================================================================ '= F_FRAME:均等割付の長さ '================================================================ Sub ATENA_DRAW() ' 郵便番号(3桁部) F_POINT = 12 TXT$ = akcnv$(Left$(ATENA$(1),instr(ATENA$(1),"-") - 1)) LM = KLen(TXT$) F_FRAME = 180 F_SPACE = fnWD(F_POINT) + ((F_FRAME - LM * fnWD(F_POINT)) / (LM-1)) XPOS = 450 YPOS = 145 YOKOGAKI_DRAW ' 郵便番号(4桁部) TXT$ = akcnv$(Mid$(ATENA$(1),instr(ATENA$(1),"-") + 1)) LM = KLen(TXT$) F_FRAME = 240 F_SPACE = fnWD(F_POINT) + ((F_FRAME - LM * fnWD(F_POINT)) / (LM-1)) XPOS = 665 YPOS = 145 YOKOGAKI_DRAW ' 住所1 F_POINT = 12 TXT$ = akcnv$(ATENA$(2)) LM = KLen(TXT$) F_SPACE = fnWD(F_POINT) XPOS = 880 YPOS = 270 TATEGAKI_DRAW ' 住所2 TXT$ = akcnv$(ATENA$(3)) LM = KLen(TXT$) F_SPACE = fnWD(F_POINT) XPOS = 800 YPOS = 320 TATEGAKI_DRAW ' 名前 & 敬称 TXT$ = akcnv$(ATENA$(0))+" 様" If LM < 15 Then F_POINT = 16 Else F_POINT = 14 F_FRAME = 840 F_SPACE = fnWD(F_POINT) + ((F_FRAME - LM * fnWD(F_POINT)) / (LM-1)) XPOS = 620 YPOS = 350 TATEGAKI_DRAW ' 差出人郵便番号 F_POINT = 8 TXT$ = "〒" & akcnv$(SEnd$(1)) LM = KLen(TXT$) F_SPACE = fnWD(F_POINT) XPOS = 280 YPOS = 650 TATEGAKI_DRAW ' 住所1 F_POINT = 9 TXT$ = akcnv$(SEnd$(2)) LM = KLen(TXT$) F_SPACE = fnWD(F_POINT) XPOS = 240 YPOS = 700 TATEGAKI_DRAW ' 住所2 TXT$ = akcnv$(SEnd$(3)) LM = KLen(TXT$) F_SPACE = fnWD(F_POINT) XPOS = 200 YPOS = 750 TATEGAKI_DRAW ' 名前 TXT$ = akcnv$(SEnd$(0)) LM = KLen(TXT$) F_POINT = 11 F_FRAME = 500 F_SPACE = fnWD(F_POINT) + ((F_FRAME - LM * fnWD(F_POINT)) / (LM-1)) XPOS = 160 YPOS = 820 TATEGAKI_DRAW ' 電話・FAX TXT$ = akcnv$(SEnd$(4)) LM = KLen(TXT$) F_POINT = 8 F_FRAME = 480 F_SPACE = fnWD(F_POINT) + ((F_FRAME - LM * fnWD(F_POINT)) / (LM-1)) XPOS = 110 YPOS = 840 TATEGAKI_DRAW End Sub '================================================================ '= 縦書き表示 '================================================================ Sub TATEGAKI_DRAW() If LM = 0 Then Exit Sub FFONT.FFNAME = "@"+FFONT.FFNAME SETFONT FFONT SETFONTSIZE F_POINT For I = 1 To LM ZZZ$ = kMid$(TXT$, I, 1) If ZZZ$ = "−" Then ZZZ$ = "ー" Else If ZZZ$ = "1" Then ZZZ$ = "一" Else If ZZZ$ = "2" Then ZZZ$ = "二" Else If ZZZ$ = "3" Then ZZZ$ = "三" Else If ZZZ$ = "4" Then ZZZ$ = "四" Else If ZZZ$ = "5" Then ZZZ$ = "五" Else If ZZZ$ = "6" Then ZZZ$ = "六" Else If ZZZ$ = "7" Then ZZZ$ = "七" Else If ZZZ$ = "8" Then ZZZ$ = "八" Else If ZZZ$ = "9" Then ZZZ$ = "九" End If symbol(XPOS+LX, YPOS+LY), ZZZ$, 1, 1, , 3 YPOS = YPOS + F_SPACE Next FFONT.FFNAME = Mid$(FFONT.FFNAME, 2) End Sub '================================================================ '= 横書き表示 '================================================================ Sub YOKOGAKI_DRAW() If LM = 0 Then Exit Sub SETFONTNAME "MS ゴシック" SETFONTSIZE F_POINT For I = 1 To LM ZZZ$ = kMid$(TXT$, I, 1) symbol(XPOS+LX, YPOS+LY), ZZZ$, 1, 1 XPOS = XPOS + F_SPACE Next End Sub '================================================================ '= EPSON PX-V700:LX=-25/LY=-15 '================================================================ Declare Sub MNUPRINT_ON edecl () Sub MNUPRINT_ON() LX = -25 '左余白調整 LY = -15 '上余白調整 PRT.SETUPPRINTERMODE "SETUPPRINTER:", 11, 1 ' If PRT.PRINTDLG(PRM) <> 0 Then PRT.SETMAPMODE 2 PRT.STARTDOC "Sample" PRT.STARTPAGE PRT.ATENA_DRAW PRT.ENDPAGE PRT.ENDDOC PRT.CLOSEPRINTER End If End Sub '================================================================ '= フォント指定 '================================================================ Sub MNUFONTSEL_ON() FFONT.FFNAME = F_NAME$ If CHOOSEFONT(FFONT,0,0,0) Then F_NAME$ = FFONT.FFNAME End If FFONT.FFNAME = F_NAME$ POSTCARD_DRAW ATENA_DRAW End Sub '================================================================ '= 終了処理 '================================================================ Sub MAINFORM_QUERYCLOSE(CANCEL%,ByVal MODE%) CANCEL% = MESSAGEBOX(GETWINDOWTEXT, "終了しますか?", 1, 1 ) If CANCEL% = 0 Then End End Sub Sub MNUEXIT_ON() RES = MESSAGEBOX(GETWINDOWTEXT, "終了しますか?", 1, 1 ) If RES = 0 Then End End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End