Win32 API 日本語リファレンス
ホームGraphics.Gdi › DRAWTEXTPARAMS

DRAWTEXTPARAMS

構造体
サイズx64: 20 バイト / x86: 20 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
cbSizeDWORD4+0+0この構造体のサイズをバイト単位で指定する。
iTabLengthINT4+4+4タブ停止の間隔を平均文字幅単位で表す。
iLeftMarginINT4+8+8左マージンを論理単位で表す。
iRightMarginINT4+12+12右マージンを論理単位で表す。
uiLengthDrawnDWORD4+16+16実際に描画された文字数を受け取る出力フィールド。

各言語での定義

#include <windows.h>

// DRAWTEXTPARAMS  (x64 20 / x86 20 バイト)
typedef struct DRAWTEXTPARAMS {
    DWORD cbSize;
    INT iTabLength;
    INT iLeftMargin;
    INT iRightMargin;
    DWORD uiLengthDrawn;
} DRAWTEXTPARAMS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DRAWTEXTPARAMS
{
    public uint cbSize;
    public int iTabLength;
    public int iLeftMargin;
    public int iRightMargin;
    public uint uiLengthDrawn;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DRAWTEXTPARAMS
    Public cbSize As UInteger
    Public iTabLength As Integer
    Public iLeftMargin As Integer
    Public iRightMargin As Integer
    Public uiLengthDrawn As UInteger
End Structure
import ctypes
from ctypes import wintypes

class DRAWTEXTPARAMS(ctypes.Structure):
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("iTabLength", ctypes.c_int),
        ("iLeftMargin", ctypes.c_int),
        ("iRightMargin", ctypes.c_int),
        ("uiLengthDrawn", wintypes.DWORD),
    ]
#[repr(C)]
pub struct DRAWTEXTPARAMS {
    pub cbSize: u32,
    pub iTabLength: i32,
    pub iLeftMargin: i32,
    pub iRightMargin: i32,
    pub uiLengthDrawn: u32,
}
import "golang.org/x/sys/windows"

type DRAWTEXTPARAMS struct {
	cbSize uint32
	iTabLength int32
	iLeftMargin int32
	iRightMargin int32
	uiLengthDrawn uint32
}
type
  DRAWTEXTPARAMS = record
    cbSize: DWORD;
    iTabLength: Integer;
    iLeftMargin: Integer;
    iRightMargin: Integer;
    uiLengthDrawn: DWORD;
  end;
const DRAWTEXTPARAMS = extern struct {
    cbSize: u32,
    iTabLength: i32,
    iLeftMargin: i32,
    iRightMargin: i32,
    uiLengthDrawn: u32,
};
type
  DRAWTEXTPARAMS {.bycopy.} = object
    cbSize: uint32
    iTabLength: int32
    iLeftMargin: int32
    iRightMargin: int32
    uiLengthDrawn: uint32
struct DRAWTEXTPARAMS
{
    uint cbSize;
    int iTabLength;
    int iLeftMargin;
    int iRightMargin;
    uint uiLengthDrawn;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DRAWTEXTPARAMS サイズ: 20 バイト(x64)
dim st, 5    ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; iTabLength : INT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; iLeftMargin : INT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; iRightMargin : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; uiLengthDrawn : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DRAWTEXTPARAMS
    #field int cbSize
    #field int iTabLength
    #field int iLeftMargin
    #field int iRightMargin
    #field int uiLengthDrawn
#endstruct

stdim st, DRAWTEXTPARAMS        ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize