ホーム › 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 | ソースモードのピクセル形式を指定する DISPLAYCONFIG_PIXELFORMAT 列挙型の値。 |
| position | POINTL | 8 | +12 | +12 | このソースサーフェスの左上隅のデスクトップ座標空間における位置を指定する POINTL 構造体。(0, 0) に位置するソースサーフェスは常にプライマリのソースサーフェスです。 |
公式ドキュメント
DISPLAYCONFIG_SOURCE_MODE 構造体は、2 次元空間における点またはオフセットを表します。
解説(Remarks)
デスクトップ上のソースサーフェスの配置は position メンバーによって制御されます。このメンバーは、ソースサーフェスの左上隅のデスクトップ座標での位置を指定します。(0, 0) に配置されたソースサーフェスはプライマリと見なされます。GDI には、デスクトップ空間においてソースサーフェスをどのように配置できるかについて厳密な規則があります。たとえば、ソースサーフェス間に隙間があってはならず、重なりがあってもいけません。
SetDisplayConfig 関数は、これらのレイアウト規則を強制するためにソースサーフェスの再配置を試みます。GDI はレイアウト規則を強制するために未定義の方法でソースを再配置するため、呼び出し元はソースサーフェスを正しく配置するようあらゆる努力をしなければなりません。結果として得られるレイアウトは、呼び出し元が意図したものにならない可能性があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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