ホーム › Devices.Display › DISPLAYCONFIG_SOURCE_MODE
DISPLAYCONFIG_SOURCE_MODE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| width | DWORD | 4 | +0 | +0 | ソース(デスクトップ)の幅(ピクセル)。 |
| height | DWORD | 4 | +4 | +4 | ソース(デスクトップ)の高さ(ピクセル)。 |
| pixelFormat | DISPLAYCONFIG_PIXELFORMAT | 4 | +8 | +8 | ソースのピクセルフォーマット(8/16/24/32bpp等)。 |
| position | POINTL | 8 | +12 | +12 | 仮想デスクトップ上のソース左上座標(POINTL)。 |
各言語での定義
#include <windows.h>
// POINTL (x64 8 / x86 8 バイト)
typedef struct POINTL {
INT x;
INT y;
} POINTL;
// DISPLAYCONFIG_SOURCE_MODE (x64 20 / x86 20 バイト)
typedef struct DISPLAYCONFIG_SOURCE_MODE {
DWORD width;
DWORD height;
DISPLAYCONFIG_PIXELFORMAT pixelFormat;
POINTL position;
} DISPLAYCONFIG_SOURCE_MODE;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINTL
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DISPLAYCONFIG_SOURCE_MODE
{
public uint width;
public uint height;
public int pixelFormat;
public POINTL position;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINTL
Public x As Integer
Public y As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DISPLAYCONFIG_SOURCE_MODE
Public width As UInteger
Public height As UInteger
Public pixelFormat As Integer
Public position As POINTL
End Structureimport ctypes
from ctypes import wintypes
class POINTL(ctypes.Structure):
_fields_ = [
("x", ctypes.c_int),
("y", ctypes.c_int),
]
class DISPLAYCONFIG_SOURCE_MODE(ctypes.Structure):
_fields_ = [
("width", wintypes.DWORD),
("height", wintypes.DWORD),
("pixelFormat", ctypes.c_int),
("position", POINTL),
]#[repr(C)]
pub struct POINTL {
pub x: i32,
pub y: i32,
}
#[repr(C)]
pub struct DISPLAYCONFIG_SOURCE_MODE {
pub width: u32,
pub height: u32,
pub pixelFormat: i32,
pub position: POINTL,
}import "golang.org/x/sys/windows"
type POINTL struct {
x int32
y int32
}
type DISPLAYCONFIG_SOURCE_MODE struct {
width uint32
height uint32
pixelFormat int32
position POINTL
}type
POINTL = record
x: Integer;
y: Integer;
end;
DISPLAYCONFIG_SOURCE_MODE = record
width: DWORD;
height: DWORD;
pixelFormat: Integer;
position: POINTL;
end;const POINTL = extern struct {
x: i32,
y: i32,
};
const DISPLAYCONFIG_SOURCE_MODE = extern struct {
width: u32,
height: u32,
pixelFormat: i32,
position: POINTL,
};type
POINTL {.bycopy.} = object
x: int32
y: int32
DISPLAYCONFIG_SOURCE_MODE {.bycopy.} = object
width: uint32
height: uint32
pixelFormat: int32
position: POINTLstruct POINTL
{
int x;
int y;
}
struct DISPLAYCONFIG_SOURCE_MODE
{
uint width;
uint height;
int pixelFormat;
POINTL position;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DISPLAYCONFIG_SOURCE_MODE サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; width : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; height : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; pixelFormat : DISPLAYCONFIG_PIXELFORMAT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; position : POINTL (+12, 8byte) varptr(st)+12 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global POINTL
#field int x
#field int y
#endstruct
#defstruct global DISPLAYCONFIG_SOURCE_MODE
#field int width
#field int height
#field int pixelFormat
#field POINTL position
#endstruct
stdim st, DISPLAYCONFIG_SOURCE_MODE ; NSTRUCT 変数を確保
st->width = 100
mes "width=" + st->width