Win32 API 日本語リファレンス
ホームMedia.Audio.DirectMusic › RGNHEADER

RGNHEADER

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

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

フィールド

フィールドサイズx64x86説明
RangeKeyRGNRANGE4+0+0リージョンが対応するキー(音高)の範囲を示すRGNRANGE。
RangeVelocityRGNRANGE4+4+4リージョンが対応するベロシティの範囲を示すRGNRANGE。
fusOptionsWORD2+8+8リージョンのオプションフラグ。
usKeyGroupWORD2+10+10リージョンが属するキーグループ番号。

各言語での定義

#include <windows.h>

// RGNRANGE  (x64 4 / x86 4 バイト)
typedef struct RGNRANGE {
    WORD usLow;
    WORD usHigh;
} RGNRANGE;

// RGNHEADER  (x64 12 / x86 12 バイト)
typedef struct RGNHEADER {
    RGNRANGE RangeKey;
    RGNRANGE RangeVelocity;
    WORD fusOptions;
    WORD usKeyGroup;
} RGNHEADER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RGNRANGE
{
    public ushort usLow;
    public ushort usHigh;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RGNHEADER
{
    public RGNRANGE RangeKey;
    public RGNRANGE RangeVelocity;
    public ushort fusOptions;
    public ushort usKeyGroup;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RGNRANGE
    Public usLow As UShort
    Public usHigh As UShort
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RGNHEADER
    Public RangeKey As RGNRANGE
    Public RangeVelocity As RGNRANGE
    Public fusOptions As UShort
    Public usKeyGroup As UShort
End Structure
import ctypes
from ctypes import wintypes

class RGNRANGE(ctypes.Structure):
    _fields_ = [
        ("usLow", ctypes.c_ushort),
        ("usHigh", ctypes.c_ushort),
    ]

class RGNHEADER(ctypes.Structure):
    _fields_ = [
        ("RangeKey", RGNRANGE),
        ("RangeVelocity", RGNRANGE),
        ("fusOptions", ctypes.c_ushort),
        ("usKeyGroup", ctypes.c_ushort),
    ]
#[repr(C)]
pub struct RGNRANGE {
    pub usLow: u16,
    pub usHigh: u16,
}

#[repr(C)]
pub struct RGNHEADER {
    pub RangeKey: RGNRANGE,
    pub RangeVelocity: RGNRANGE,
    pub fusOptions: u16,
    pub usKeyGroup: u16,
}
import "golang.org/x/sys/windows"

type RGNRANGE struct {
	usLow uint16
	usHigh uint16
}

type RGNHEADER struct {
	RangeKey RGNRANGE
	RangeVelocity RGNRANGE
	fusOptions uint16
	usKeyGroup uint16
}
type
  RGNRANGE = record
    usLow: Word;
    usHigh: Word;
  end;

  RGNHEADER = record
    RangeKey: RGNRANGE;
    RangeVelocity: RGNRANGE;
    fusOptions: Word;
    usKeyGroup: Word;
  end;
const RGNRANGE = extern struct {
    usLow: u16,
    usHigh: u16,
};

const RGNHEADER = extern struct {
    RangeKey: RGNRANGE,
    RangeVelocity: RGNRANGE,
    fusOptions: u16,
    usKeyGroup: u16,
};
type
  RGNRANGE {.bycopy.} = object
    usLow: uint16
    usHigh: uint16

  RGNHEADER {.bycopy.} = object
    RangeKey: RGNRANGE
    RangeVelocity: RGNRANGE
    fusOptions: uint16
    usKeyGroup: uint16
struct RGNRANGE
{
    ushort usLow;
    ushort usHigh;
}

struct RGNHEADER
{
    RGNRANGE RangeKey;
    RGNRANGE RangeVelocity;
    ushort fusOptions;
    ushort usKeyGroup;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; RGNHEADER サイズ: 12 バイト(x64)
dim st, 3    ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; RangeKey : RGNRANGE (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; RangeVelocity : RGNRANGE (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; fusOptions : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; usKeyGroup : WORD (+10, 2byte)  wpoke st,10,値  /  値 = wpeek(st,10)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global RGNRANGE
    #field short usLow
    #field short usHigh
#endstruct

#defstruct global RGNHEADER
    #field RGNRANGE RangeKey
    #field RGNRANGE RangeVelocity
    #field short fusOptions
    #field short usKeyGroup
#endstruct

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