Win32 API 日本語リファレンス
ホームUI.Accessibility › WindowPattern_SetWindowVisualState

WindowPattern_SetWindowVisualState

関数
Windowパターンでウィンドウの最大化・最小化状態を設定する。
DLLUIAutomationCore.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT WindowPattern_SetWindowVisualState(
    HUIAPATTERNOBJECT hobj,
    WindowVisualState state
);

パラメーター

名前方向説明
hobjHUIAPATTERNOBJECTinWindowPatternを表すパターンオブジェクトハンドル。
stateWindowVisualStatein設定するウィンドウの表示状態(通常・最大化・最小化)を示すWindowVisualState値。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WindowPattern_SetWindowVisualState(
    HUIAPATTERNOBJECT hobj,
    WindowVisualState state
);
[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int WindowPattern_SetWindowVisualState(
    IntPtr hobj,   // HUIAPATTERNOBJECT
    int state   // WindowVisualState
);
<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function WindowPattern_SetWindowVisualState(
    hobj As IntPtr,   ' HUIAPATTERNOBJECT
    state As Integer   ' WindowVisualState
) As Integer
End Function
' hobj : HUIAPATTERNOBJECT
' state : WindowVisualState
Declare PtrSafe Function WindowPattern_SetWindowVisualState Lib "uiautomationcore" ( _
    ByVal hobj As LongPtr, _
    ByVal state As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WindowPattern_SetWindowVisualState = ctypes.windll.uiautomationcore.WindowPattern_SetWindowVisualState
WindowPattern_SetWindowVisualState.restype = ctypes.c_int
WindowPattern_SetWindowVisualState.argtypes = [
    wintypes.HANDLE,  # hobj : HUIAPATTERNOBJECT
    ctypes.c_int,  # state : WindowVisualState
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('UIAutomationCore.dll')
WindowPattern_SetWindowVisualState = Fiddle::Function.new(
  lib['WindowPattern_SetWindowVisualState'],
  [
    Fiddle::TYPE_VOIDP,  # hobj : HUIAPATTERNOBJECT
    Fiddle::TYPE_INT,  # state : WindowVisualState
  ],
  Fiddle::TYPE_INT)
#[link(name = "uiautomationcore")]
extern "system" {
    fn WindowPattern_SetWindowVisualState(
        hobj: *mut core::ffi::c_void,  // HUIAPATTERNOBJECT
        state: i32  // WindowVisualState
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("UIAutomationCore.dll")]
public static extern int WindowPattern_SetWindowVisualState(IntPtr hobj, int state);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UIAutomationCore_WindowPattern_SetWindowVisualState' -Namespace Win32 -PassThru
# $api::WindowPattern_SetWindowVisualState(hobj, state)
#uselib "UIAutomationCore.dll"
#func global WindowPattern_SetWindowVisualState "WindowPattern_SetWindowVisualState" sptr, sptr
; WindowPattern_SetWindowVisualState hobj, state   ; 戻り値は stat
; hobj : HUIAPATTERNOBJECT -> "sptr"
; state : WindowVisualState -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "UIAutomationCore.dll"
#cfunc global WindowPattern_SetWindowVisualState "WindowPattern_SetWindowVisualState" sptr, int
; res = WindowPattern_SetWindowVisualState(hobj, state)
; hobj : HUIAPATTERNOBJECT -> "sptr"
; state : WindowVisualState -> "int"
; HRESULT WindowPattern_SetWindowVisualState(HUIAPATTERNOBJECT hobj, WindowVisualState state)
#uselib "UIAutomationCore.dll"
#cfunc global WindowPattern_SetWindowVisualState "WindowPattern_SetWindowVisualState" intptr, int
; res = WindowPattern_SetWindowVisualState(hobj, state)
; hobj : HUIAPATTERNOBJECT -> "intptr"
; state : WindowVisualState -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
	procWindowPattern_SetWindowVisualState = uiautomationcore.NewProc("WindowPattern_SetWindowVisualState")
)

// hobj (HUIAPATTERNOBJECT), state (WindowVisualState)
r1, _, err := procWindowPattern_SetWindowVisualState.Call(
	uintptr(hobj),
	uintptr(state),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WindowPattern_SetWindowVisualState(
  hobj: THandle;   // HUIAPATTERNOBJECT
  state: Integer   // WindowVisualState
): Integer; stdcall;
  external 'UIAutomationCore.dll' name 'WindowPattern_SetWindowVisualState';
result := DllCall("UIAutomationCore\WindowPattern_SetWindowVisualState"
    , "Ptr", hobj   ; HUIAPATTERNOBJECT
    , "Int", state   ; WindowVisualState
    , "Int")   ; return: HRESULT
●WindowPattern_SetWindowVisualState(hobj, state) = DLL("UIAutomationCore.dll", "int WindowPattern_SetWindowVisualState(void*, int)")
# 呼び出し: WindowPattern_SetWindowVisualState(hobj, state)
# hobj : HUIAPATTERNOBJECT -> "void*"
# state : WindowVisualState -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "uiautomationcore" fn WindowPattern_SetWindowVisualState(
    hobj: ?*anyopaque, // HUIAPATTERNOBJECT
    state: i32 // WindowVisualState
) callconv(std.os.windows.WINAPI) i32;
proc WindowPattern_SetWindowVisualState(
    hobj: pointer,  # HUIAPATTERNOBJECT
    state: int32  # WindowVisualState
): int32 {.importc: "WindowPattern_SetWindowVisualState", stdcall, dynlib: "UIAutomationCore.dll".}
pragma(lib, "uiautomationcore");
extern(Windows)
int WindowPattern_SetWindowVisualState(
    void* hobj,   // HUIAPATTERNOBJECT
    int state   // WindowVisualState
);
ccall((:WindowPattern_SetWindowVisualState, "UIAutomationCore.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Int32),
      hobj, state)
# hobj : HUIAPATTERNOBJECT -> Ptr{Cvoid}
# state : WindowVisualState -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WindowPattern_SetWindowVisualState(
    void* hobj,
    int32_t state);
]]
local uiautomationcore = ffi.load("uiautomationcore")
-- uiautomationcore.WindowPattern_SetWindowVisualState(hobj, state)
-- hobj : HUIAPATTERNOBJECT
-- state : WindowVisualState
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('UIAutomationCore.dll');
const WindowPattern_SetWindowVisualState = lib.func('__stdcall', 'WindowPattern_SetWindowVisualState', 'int32_t', ['void *', 'int32_t']);
// WindowPattern_SetWindowVisualState(hobj, state)
// hobj : HUIAPATTERNOBJECT -> 'void *'
// state : WindowVisualState -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("UIAutomationCore.dll", {
  WindowPattern_SetWindowVisualState: { parameters: ["pointer", "i32"], result: "i32" },
});
// lib.symbols.WindowPattern_SetWindowVisualState(hobj, state)
// hobj : HUIAPATTERNOBJECT -> "pointer"
// state : WindowVisualState -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WindowPattern_SetWindowVisualState(
    void* hobj,
    int32_t state);
C, "UIAutomationCore.dll");
// $ffi->WindowPattern_SetWindowVisualState(hobj, state);
// hobj : HUIAPATTERNOBJECT
// state : WindowVisualState
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Uiautomationcore extends StdCallLibrary {
    Uiautomationcore INSTANCE = Native.load("uiautomationcore", Uiautomationcore.class);
    int WindowPattern_SetWindowVisualState(
        Pointer hobj,   // HUIAPATTERNOBJECT
        int state   // WindowVisualState
    );
}
@[Link("uiautomationcore")]
lib LibUIAutomationCore
  fun WindowPattern_SetWindowVisualState = WindowPattern_SetWindowVisualState(
    hobj : Void*,   # HUIAPATTERNOBJECT
    state : Int32   # WindowVisualState
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WindowPattern_SetWindowVisualStateNative = Int32 Function(Pointer<Void>, Int32);
typedef WindowPattern_SetWindowVisualStateDart = int Function(Pointer<Void>, int);
final WindowPattern_SetWindowVisualState = DynamicLibrary.open('UIAutomationCore.dll')
    .lookupFunction<WindowPattern_SetWindowVisualStateNative, WindowPattern_SetWindowVisualStateDart>('WindowPattern_SetWindowVisualState');
// hobj : HUIAPATTERNOBJECT -> Pointer<Void>
// state : WindowVisualState -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WindowPattern_SetWindowVisualState(
  hobj: THandle;   // HUIAPATTERNOBJECT
  state: Integer   // WindowVisualState
): Integer; stdcall;
  external 'UIAutomationCore.dll' name 'WindowPattern_SetWindowVisualState';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WindowPattern_SetWindowVisualState"
  c_WindowPattern_SetWindowVisualState :: Ptr () -> Int32 -> IO Int32
-- hobj : HUIAPATTERNOBJECT -> Ptr ()
-- state : WindowVisualState -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let windowpattern_setwindowvisualstate =
  foreign "WindowPattern_SetWindowVisualState"
    ((ptr void) @-> int32_t @-> returning int32_t)
(* hobj : HUIAPATTERNOBJECT -> (ptr void) *)
(* state : WindowVisualState -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library uiautomationcore (t "UIAutomationCore.dll"))
(cffi:use-foreign-library uiautomationcore)

(cffi:defcfun ("WindowPattern_SetWindowVisualState" window-pattern-set-window-visual-state :convention :stdcall) :int32
  (hobj :pointer)   ; HUIAPATTERNOBJECT
  (state :int32))   ; WindowVisualState
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WindowPattern_SetWindowVisualState = Win32::API::More->new('UIAutomationCore',
    'int WindowPattern_SetWindowVisualState(HANDLE hobj, int state)');
# my $ret = $WindowPattern_SetWindowVisualState->Call($hobj, $state);
# hobj : HUIAPATTERNOBJECT -> HANDLE
# state : WindowVisualState -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型