Win32 API 日本語リファレンス
ホームUI.Controls › MARGINS

MARGINS

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

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

フィールド

フィールドサイズx64x86説明
cxLeftWidthINT4+0+0左余白の幅(ピクセル)。
cxRightWidthINT4+4+4右余白の幅(ピクセル)。
cyTopHeightINT4+8+8上余白の高さ(ピクセル)。
cyBottomHeightINT4+12+12下余白の高さ(ピクセル)。

各言語での定義

#include <windows.h>

// MARGINS  (x64 16 / x86 16 バイト)
typedef struct MARGINS {
    INT cxLeftWidth;
    INT cxRightWidth;
    INT cyTopHeight;
    INT cyBottomHeight;
} MARGINS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MARGINS
{
    public int cxLeftWidth;
    public int cxRightWidth;
    public int cyTopHeight;
    public int cyBottomHeight;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MARGINS
    Public cxLeftWidth As Integer
    Public cxRightWidth As Integer
    Public cyTopHeight As Integer
    Public cyBottomHeight As Integer
End Structure
import ctypes
from ctypes import wintypes

class MARGINS(ctypes.Structure):
    _fields_ = [
        ("cxLeftWidth", ctypes.c_int),
        ("cxRightWidth", ctypes.c_int),
        ("cyTopHeight", ctypes.c_int),
        ("cyBottomHeight", ctypes.c_int),
    ]
#[repr(C)]
pub struct MARGINS {
    pub cxLeftWidth: i32,
    pub cxRightWidth: i32,
    pub cyTopHeight: i32,
    pub cyBottomHeight: i32,
}
import "golang.org/x/sys/windows"

type MARGINS struct {
	cxLeftWidth int32
	cxRightWidth int32
	cyTopHeight int32
	cyBottomHeight int32
}
type
  MARGINS = record
    cxLeftWidth: Integer;
    cxRightWidth: Integer;
    cyTopHeight: Integer;
    cyBottomHeight: Integer;
  end;
const MARGINS = extern struct {
    cxLeftWidth: i32,
    cxRightWidth: i32,
    cyTopHeight: i32,
    cyBottomHeight: i32,
};
type
  MARGINS {.bycopy.} = object
    cxLeftWidth: int32
    cxRightWidth: int32
    cyTopHeight: int32
    cyBottomHeight: int32
struct MARGINS
{
    int cxLeftWidth;
    int cxRightWidth;
    int cyTopHeight;
    int cyBottomHeight;
}

HSP用 定義

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

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

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