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