ホーム › UI.WindowsAndMessaging › ShowWindow
ShowWindow
関数ウィンドウの表示状態を設定する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL ShowWindow(
HWND hWnd,
SHOW_WINDOW_CMD nCmdShow
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | in |
| nCmdShow | SHOW_WINDOW_CMD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL ShowWindow(
HWND hWnd,
SHOW_WINDOW_CMD nCmdShow
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool ShowWindow(
IntPtr hWnd, // HWND
int nCmdShow // SHOW_WINDOW_CMD
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function ShowWindow(
hWnd As IntPtr, ' HWND
nCmdShow As Integer ' SHOW_WINDOW_CMD
) As Boolean
End Function' hWnd : HWND
' nCmdShow : SHOW_WINDOW_CMD
Declare PtrSafe Function ShowWindow Lib "user32" ( _
ByVal hWnd As LongPtr, _
ByVal nCmdShow As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ShowWindow = ctypes.windll.user32.ShowWindow
ShowWindow.restype = wintypes.BOOL
ShowWindow.argtypes = [
wintypes.HANDLE, # hWnd : HWND
ctypes.c_int, # nCmdShow : SHOW_WINDOW_CMD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
ShowWindow = Fiddle::Function.new(
lib['ShowWindow'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
Fiddle::TYPE_INT, # nCmdShow : SHOW_WINDOW_CMD
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn ShowWindow(
hWnd: *mut core::ffi::c_void, // HWND
nCmdShow: i32 // SHOW_WINDOW_CMD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_ShowWindow' -Namespace Win32 -PassThru
# $api::ShowWindow(hWnd, nCmdShow)#uselib "USER32.dll"
#func global ShowWindow "ShowWindow" sptr, sptr
; ShowWindow hWnd, nCmdShow ; 戻り値は stat
; hWnd : HWND -> "sptr"
; nCmdShow : SHOW_WINDOW_CMD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global ShowWindow "ShowWindow" sptr, int
; res = ShowWindow(hWnd, nCmdShow)
; hWnd : HWND -> "sptr"
; nCmdShow : SHOW_WINDOW_CMD -> "int"; BOOL ShowWindow(HWND hWnd, SHOW_WINDOW_CMD nCmdShow)
#uselib "USER32.dll"
#cfunc global ShowWindow "ShowWindow" intptr, int
; res = ShowWindow(hWnd, nCmdShow)
; hWnd : HWND -> "intptr"
; nCmdShow : SHOW_WINDOW_CMD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procShowWindow = user32.NewProc("ShowWindow")
)
// hWnd (HWND), nCmdShow (SHOW_WINDOW_CMD)
r1, _, err := procShowWindow.Call(
uintptr(hWnd),
uintptr(nCmdShow),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction ShowWindow(
hWnd: THandle; // HWND
nCmdShow: Integer // SHOW_WINDOW_CMD
): BOOL; stdcall;
external 'USER32.dll' name 'ShowWindow';result := DllCall("USER32\ShowWindow"
, "Ptr", hWnd ; HWND
, "Int", nCmdShow ; SHOW_WINDOW_CMD
, "Int") ; return: BOOL●ShowWindow(hWnd, nCmdShow) = DLL("USER32.dll", "bool ShowWindow(void*, int)")
# 呼び出し: ShowWindow(hWnd, nCmdShow)
# hWnd : HWND -> "void*"
# nCmdShow : SHOW_WINDOW_CMD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。