Win32 API 日本語リファレンス
ホームGraphics.Gdi › RedrawWindow

RedrawWindow

関数
フラグに従ってウィンドウの指定領域を更新・再描画する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// USER32.dll
#include <windows.h>

BOOL RedrawWindow(
    HWND hWnd,   // optional
    const RECT* lprcUpdate,   // optional
    HRGN hrgnUpdate,   // optional
    REDRAW_WINDOW_FLAGS flags
);

パラメーター

名前方向
hWndHWNDinoptional
lprcUpdateRECT*inoptional
hrgnUpdateHRGNinoptional
flagsREDRAW_WINDOW_FLAGSin

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll
#include <windows.h>

BOOL RedrawWindow(
    HWND hWnd,   // optional
    const RECT* lprcUpdate,   // optional
    HRGN hrgnUpdate,   // optional
    REDRAW_WINDOW_FLAGS flags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool RedrawWindow(
    IntPtr hWnd,   // HWND optional
    IntPtr lprcUpdate,   // RECT* optional
    IntPtr hrgnUpdate,   // HRGN optional
    uint flags   // REDRAW_WINDOW_FLAGS
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function RedrawWindow(
    hWnd As IntPtr,   ' HWND optional
    lprcUpdate As IntPtr,   ' RECT* optional
    hrgnUpdate As IntPtr,   ' HRGN optional
    flags As UInteger   ' REDRAW_WINDOW_FLAGS
) As Boolean
End Function
' hWnd : HWND optional
' lprcUpdate : RECT* optional
' hrgnUpdate : HRGN optional
' flags : REDRAW_WINDOW_FLAGS
Declare PtrSafe Function RedrawWindow Lib "user32" ( _
    ByVal hWnd As LongPtr, _
    ByVal lprcUpdate As LongPtr, _
    ByVal hrgnUpdate As LongPtr, _
    ByVal flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RedrawWindow = ctypes.windll.user32.RedrawWindow
RedrawWindow.restype = wintypes.BOOL
RedrawWindow.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND optional
    ctypes.c_void_p,  # lprcUpdate : RECT* optional
    wintypes.HANDLE,  # hrgnUpdate : HRGN optional
    wintypes.DWORD,  # flags : REDRAW_WINDOW_FLAGS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
RedrawWindow = Fiddle::Function.new(
  lib['RedrawWindow'],
  [
    Fiddle::TYPE_VOIDP,  # hWnd : HWND optional
    Fiddle::TYPE_VOIDP,  # lprcUpdate : RECT* optional
    Fiddle::TYPE_VOIDP,  # hrgnUpdate : HRGN optional
    -Fiddle::TYPE_INT,  # flags : REDRAW_WINDOW_FLAGS
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn RedrawWindow(
        hWnd: *mut core::ffi::c_void,  // HWND optional
        lprcUpdate: *const RECT,  // RECT* optional
        hrgnUpdate: *mut core::ffi::c_void,  // HRGN optional
        flags: u32  // REDRAW_WINDOW_FLAGS
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, uint flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_RedrawWindow' -Namespace Win32 -PassThru
# $api::RedrawWindow(hWnd, lprcUpdate, hrgnUpdate, flags)
#uselib "USER32.dll"
#func global RedrawWindow "RedrawWindow" sptr, sptr, sptr, sptr
; RedrawWindow hWnd, varptr(lprcUpdate), hrgnUpdate, flags   ; 戻り値は stat
; hWnd : HWND optional -> "sptr"
; lprcUpdate : RECT* optional -> "sptr"
; hrgnUpdate : HRGN optional -> "sptr"
; flags : REDRAW_WINDOW_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global RedrawWindow "RedrawWindow" sptr, var, sptr, int
; res = RedrawWindow(hWnd, lprcUpdate, hrgnUpdate, flags)
; hWnd : HWND optional -> "sptr"
; lprcUpdate : RECT* optional -> "var"
; hrgnUpdate : HRGN optional -> "sptr"
; flags : REDRAW_WINDOW_FLAGS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL RedrawWindow(HWND hWnd, RECT* lprcUpdate, HRGN hrgnUpdate, REDRAW_WINDOW_FLAGS flags)
#uselib "USER32.dll"
#cfunc global RedrawWindow "RedrawWindow" intptr, var, intptr, int
; res = RedrawWindow(hWnd, lprcUpdate, hrgnUpdate, flags)
; hWnd : HWND optional -> "intptr"
; lprcUpdate : RECT* optional -> "var"
; hrgnUpdate : HRGN optional -> "intptr"
; flags : REDRAW_WINDOW_FLAGS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procRedrawWindow = user32.NewProc("RedrawWindow")
)

// hWnd (HWND optional), lprcUpdate (RECT* optional), hrgnUpdate (HRGN optional), flags (REDRAW_WINDOW_FLAGS)
r1, _, err := procRedrawWindow.Call(
	uintptr(hWnd),
	uintptr(lprcUpdate),
	uintptr(hrgnUpdate),
	uintptr(flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function RedrawWindow(
  hWnd: THandle;   // HWND optional
  lprcUpdate: Pointer;   // RECT* optional
  hrgnUpdate: THandle;   // HRGN optional
  flags: DWORD   // REDRAW_WINDOW_FLAGS
): BOOL; stdcall;
  external 'USER32.dll' name 'RedrawWindow';
result := DllCall("USER32\RedrawWindow"
    , "Ptr", hWnd   ; HWND optional
    , "Ptr", lprcUpdate   ; RECT* optional
    , "Ptr", hrgnUpdate   ; HRGN optional
    , "UInt", flags   ; REDRAW_WINDOW_FLAGS
    , "Int")   ; return: BOOL
●RedrawWindow(hWnd, lprcUpdate, hrgnUpdate, flags) = DLL("USER32.dll", "bool RedrawWindow(void*, void*, void*, dword)")
# 呼び出し: RedrawWindow(hWnd, lprcUpdate, hrgnUpdate, flags)
# hWnd : HWND optional -> "void*"
# lprcUpdate : RECT* optional -> "void*"
# hrgnUpdate : HRGN optional -> "void*"
# flags : REDRAW_WINDOW_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。