VB6.0用掲示板の過去のログ(No.1)−VBレスキュー(花ちゃん)
[記事リスト] [新規投稿] [新着記事] [ワード検索] [過去ログ] [管理用]

投稿日: 2002/09/14(Sat) 00:06
投稿者花ちゃん
Eメール
URL
タイトルRe^3: プリンタの余白の取得

下記を試して見て下さい。

Private Declare Function GetDeviceCaps Lib "gdi32" _
    (ByVal hdc As Long, ByVal nIndex As Long) As Long
                                
Private Const PHYSICALHEIGHT = 111  
Private Const PHYSICALWIDTH = 110  
Private Const PHYSICALOFFSETX = 112
Private Const PHYSICALOFFSETY = 113


Private Sub Command1_Click()
    Dim LeftMargin As Long
    Dim TopMargin  As Long
    Dim PhysHeight As Long
    Dim PhysWidth  As Long
    
    LeftMargin = (GetDeviceCaps(Printer.hdc, PHYSICALOFFSETX) _
                    * Printer.TwipsPerPixelX / 56.7)
    TopMargin = (GetDeviceCaps(Printer.hdc, PHYSICALOFFSETY) _
                    * Printer.TwipsPerPixelY / 56.7)
    PhysWidth = (GetDeviceCaps(Printer.hdc, PHYSICALWIDTH) _
                    * Printer.TwipsPerPixelX / 56.7)
    PhysHeight = (GetDeviceCaps(Printer.hdc, PHYSICALHEIGHT) _
                    * Printer.TwipsPerPixelY / 56.7)
    
    Label1.Caption = "プリンター用紙印刷余白(左) :   " & LeftMargin & " mm"
    Label2.Caption = "プリンター用紙印刷余白(上) :   " & TopMargin & " mm"
    Label3.Caption = "プリンター用紙サイズ(幅)   : " & PhysWidth & " mm"
    Label4.Caption = "プリンター用紙サイズ(高さ) : " & PhysHeight & " mm"
End Sub


- 関連一覧ツリー (★ をクリックするとツリー全体を一括表示します)

- 返信フォーム (この記事に返信する場合は下記フォームから投稿して下さい)

- Web Forum -