ホーム › Graphics.Gdi › PAINTSTRUCT
PAINTSTRUCT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| hdc | HDC | 8/4 | +0 | +0 | 描画に使用するデバイスコンテキストのハンドル。 |
| fErase | BOOL | 4 | +8 | +4 | 背景を消去すべきかを示すフラグ。TRUEならアプリ側で消去が必要。 |
| rcPaint | RECT | 16 | +12 | +8 | 再描画が必要な領域(更新矩形)を表すRECT構造体。 |
| fRestore | BOOL | 4 | +28 | +24 | システム予約フィールド。値は無視される。 |
| fIncUpdate | BOOL | 4 | +32 | +28 | システム予約フィールド。値は無視される。 |
| rgbReserved | BYTE | 32 | +36 | +32 | システム使用のための予約バイト配列。 |
各言語での定義
#include <windows.h>
// RECT (x64 16 / x86 16 バイト)
typedef struct RECT {
INT left;
INT top;
INT right;
INT bottom;
} RECT;
// PAINTSTRUCT (x64 72 / x86 64 バイト)
typedef struct PAINTSTRUCT {
HDC hdc;
BOOL fErase;
RECT rcPaint;
BOOL fRestore;
BOOL fIncUpdate;
BYTE rgbReserved[32];
} PAINTSTRUCT;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PAINTSTRUCT
{
public IntPtr hdc;
[MarshalAs(UnmanagedType.Bool)] public bool fErase;
public RECT rcPaint;
[MarshalAs(UnmanagedType.Bool)] public bool fRestore;
[MarshalAs(UnmanagedType.Bool)] public bool fIncUpdate;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] rgbReserved;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PAINTSTRUCT
Public hdc As IntPtr
<MarshalAs(UnmanagedType.Bool)> Public fErase As Boolean
Public rcPaint As RECT
<MarshalAs(UnmanagedType.Bool)> Public fRestore As Boolean
<MarshalAs(UnmanagedType.Bool)> Public fIncUpdate As Boolean
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> Public rgbReserved() As Byte
End Structureimport ctypes
from ctypes import wintypes
class RECT(ctypes.Structure):
_fields_ = [
("left", ctypes.c_int),
("top", ctypes.c_int),
("right", ctypes.c_int),
("bottom", ctypes.c_int),
]
class PAINTSTRUCT(ctypes.Structure):
_fields_ = [
("hdc", ctypes.c_void_p),
("fErase", wintypes.BOOL),
("rcPaint", RECT),
("fRestore", wintypes.BOOL),
("fIncUpdate", wintypes.BOOL),
("rgbReserved", ctypes.c_ubyte * 32),
]#[repr(C)]
pub struct RECT {
pub left: i32,
pub top: i32,
pub right: i32,
pub bottom: i32,
}
#[repr(C)]
pub struct PAINTSTRUCT {
pub hdc: *mut core::ffi::c_void,
pub fErase: i32,
pub rcPaint: RECT,
pub fRestore: i32,
pub fIncUpdate: i32,
pub rgbReserved: [u8; 32],
}import "golang.org/x/sys/windows"
type RECT struct {
left int32
top int32
right int32
bottom int32
}
type PAINTSTRUCT struct {
hdc uintptr
fErase int32
rcPaint RECT
fRestore int32
fIncUpdate int32
rgbReserved [32]byte
}type
RECT = record
left: Integer;
top: Integer;
right: Integer;
bottom: Integer;
end;
PAINTSTRUCT = record
hdc: Pointer;
fErase: BOOL;
rcPaint: RECT;
fRestore: BOOL;
fIncUpdate: BOOL;
rgbReserved: array[0..31] of Byte;
end;const RECT = extern struct {
left: i32,
top: i32,
right: i32,
bottom: i32,
};
const PAINTSTRUCT = extern struct {
hdc: ?*anyopaque,
fErase: i32,
rcPaint: RECT,
fRestore: i32,
fIncUpdate: i32,
rgbReserved: [32]u8,
};type
RECT {.bycopy.} = object
left: int32
top: int32
right: int32
bottom: int32
PAINTSTRUCT {.bycopy.} = object
hdc: pointer
fErase: int32
rcPaint: RECT
fRestore: int32
fIncUpdate: int32
rgbReserved: array[32, uint8]struct RECT
{
int left;
int top;
int right;
int bottom;
}
struct PAINTSTRUCT
{
void* hdc;
int fErase;
RECT rcPaint;
int fRestore;
int fIncUpdate;
ubyte[32] rgbReserved;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PAINTSTRUCT サイズ: 64 バイト(x86)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; hdc : HDC (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; fErase : BOOL (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; rcPaint : RECT (+8, 16byte) varptr(st)+8 を基点に操作(16byte:入れ子/配列)
; fRestore : BOOL (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; fIncUpdate : BOOL (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; rgbReserved : BYTE (+32, 32byte) varptr(st)+32 を基点に操作(32byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PAINTSTRUCT サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; hdc : HDC (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; fErase : BOOL (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; rcPaint : RECT (+12, 16byte) varptr(st)+12 を基点に操作(16byte:入れ子/配列)
; fRestore : BOOL (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; fIncUpdate : BOOL (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; rgbReserved : BYTE (+36, 32byte) varptr(st)+36 を基点に操作(32byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global RECT
#field int left
#field int top
#field int right
#field int bottom
#endstruct
#defstruct global PAINTSTRUCT
#field intptr hdc
#field bool fErase
#field RECT rcPaint
#field bool fRestore
#field bool fIncUpdate
#field byte rgbReserved 32
#endstruct
stdim st, PAINTSTRUCT ; NSTRUCT 変数を確保
st->fErase = 100
mes "fErase=" + st->fErase