ホーム › System.Ole › OleSetMenuDescriptor
OleSetMenuDescriptor
関数合成メニューを枠ウィンドウにインストールする。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT OleSetMenuDescriptor(
INT_PTR holemenu,
HWND hwndFrame,
HWND hwndActiveObject,
IOleInPlaceFrame* lpFrame,
IOleInPlaceActiveObject* lpActiveObj
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| holemenu | INT_PTR | in | OleCreateMenuDescriptor 関数が返した複合メニュー記述子へのハンドル。NULL の場合、ディスパッチコードのフックが解除されます。 |
| hwndFrame | HWND | in | インプレース複合メニューをインストールするコンテナのフレームウィンドウへのハンドル。 |
| hwndActiveObject | HWND | in | オブジェクトのインプレースアクティベーションウィンドウへのハンドル。OLE はメニューメッセージとコマンドをこのウィンドウにディスパッチします。 |
| lpFrame | IOleInPlaceFrame* | in | コンテナのフレームウィンドウ上の IOleInPlaceFrame インターフェイスへのポインター。 |
| lpActiveObj | IOleInPlaceActiveObject* | in | アクティブなインプレースオブジェクト上の IOleInPlaceActiveObject インターフェイスへのポインター。 |
戻り値の型: HRESULT
公式ドキュメント
コンテナのフレームウィンドウに OLE のディスパッチコードをインストール、または削除します。
戻り値
この関数は成功すると S_OK を返します。
解説(Remarks)
コンテナは、オブジェクトが IOleInPlaceFrame::SetMenu メソッドを呼び出したときに hwndFrame へディスパッチコードをインストールするために OleSetMenuDescriptor を呼び出す必要があります。また、ディスパッチコードを削除するには、holemenu の値として NULL を OleSetMenuDescriptor に渡します。
lpFrame パラメーターと lpActiveObj パラメーターの両方が非 NULL の場合、OLE はアプリケーションにコンテキスト依存ヘルプの F1 メッセージフィルターをインストールします。それ以外の場合、アプリケーションは独自のメッセージフィルターを用意する必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT OleSetMenuDescriptor(
INT_PTR holemenu,
HWND hwndFrame,
HWND hwndActiveObject,
IOleInPlaceFrame* lpFrame,
IOleInPlaceActiveObject* lpActiveObj
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int OleSetMenuDescriptor(
IntPtr holemenu, // INT_PTR
IntPtr hwndFrame, // HWND
IntPtr hwndActiveObject, // HWND
IntPtr lpFrame, // IOleInPlaceFrame*
IntPtr lpActiveObj // IOleInPlaceActiveObject*
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function OleSetMenuDescriptor(
holemenu As IntPtr, ' INT_PTR
hwndFrame As IntPtr, ' HWND
hwndActiveObject As IntPtr, ' HWND
lpFrame As IntPtr, ' IOleInPlaceFrame*
lpActiveObj As IntPtr ' IOleInPlaceActiveObject*
) As Integer
End Function' holemenu : INT_PTR
' hwndFrame : HWND
' hwndActiveObject : HWND
' lpFrame : IOleInPlaceFrame*
' lpActiveObj : IOleInPlaceActiveObject*
Declare PtrSafe Function OleSetMenuDescriptor Lib "ole32" ( _
ByVal holemenu As LongPtr, _
ByVal hwndFrame As LongPtr, _
ByVal hwndActiveObject As LongPtr, _
ByVal lpFrame As LongPtr, _
ByVal lpActiveObj As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
OleSetMenuDescriptor = ctypes.windll.ole32.OleSetMenuDescriptor
OleSetMenuDescriptor.restype = ctypes.c_int
OleSetMenuDescriptor.argtypes = [
ctypes.c_ssize_t, # holemenu : INT_PTR
wintypes.HANDLE, # hwndFrame : HWND
wintypes.HANDLE, # hwndActiveObject : HWND
ctypes.c_void_p, # lpFrame : IOleInPlaceFrame*
ctypes.c_void_p, # lpActiveObj : IOleInPlaceActiveObject*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
OleSetMenuDescriptor = Fiddle::Function.new(
lib['OleSetMenuDescriptor'],
[
Fiddle::TYPE_INTPTR_T, # holemenu : INT_PTR
Fiddle::TYPE_VOIDP, # hwndFrame : HWND
Fiddle::TYPE_VOIDP, # hwndActiveObject : HWND
Fiddle::TYPE_VOIDP, # lpFrame : IOleInPlaceFrame*
Fiddle::TYPE_VOIDP, # lpActiveObj : IOleInPlaceActiveObject*
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn OleSetMenuDescriptor(
holemenu: isize, // INT_PTR
hwndFrame: *mut core::ffi::c_void, // HWND
hwndActiveObject: *mut core::ffi::c_void, // HWND
lpFrame: *mut core::ffi::c_void, // IOleInPlaceFrame*
lpActiveObj: *mut core::ffi::c_void // IOleInPlaceActiveObject*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int OleSetMenuDescriptor(IntPtr holemenu, IntPtr hwndFrame, IntPtr hwndActiveObject, IntPtr lpFrame, IntPtr lpActiveObj);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_OleSetMenuDescriptor' -Namespace Win32 -PassThru
# $api::OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)#uselib "OLE32.dll"
#func global OleSetMenuDescriptor "OleSetMenuDescriptor" sptr, sptr, sptr, sptr, sptr
; OleSetMenuDescriptor holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj ; 戻り値は stat
; holemenu : INT_PTR -> "sptr"
; hwndFrame : HWND -> "sptr"
; hwndActiveObject : HWND -> "sptr"
; lpFrame : IOleInPlaceFrame* -> "sptr"
; lpActiveObj : IOleInPlaceActiveObject* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLE32.dll"
#cfunc global OleSetMenuDescriptor "OleSetMenuDescriptor" sptr, sptr, sptr, sptr, sptr
; res = OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
; holemenu : INT_PTR -> "sptr"
; hwndFrame : HWND -> "sptr"
; hwndActiveObject : HWND -> "sptr"
; lpFrame : IOleInPlaceFrame* -> "sptr"
; lpActiveObj : IOleInPlaceActiveObject* -> "sptr"; HRESULT OleSetMenuDescriptor(INT_PTR holemenu, HWND hwndFrame, HWND hwndActiveObject, IOleInPlaceFrame* lpFrame, IOleInPlaceActiveObject* lpActiveObj)
#uselib "OLE32.dll"
#cfunc global OleSetMenuDescriptor "OleSetMenuDescriptor" intptr, intptr, intptr, intptr, intptr
; res = OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
; holemenu : INT_PTR -> "intptr"
; hwndFrame : HWND -> "intptr"
; hwndActiveObject : HWND -> "intptr"
; lpFrame : IOleInPlaceFrame* -> "intptr"
; lpActiveObj : IOleInPlaceActiveObject* -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procOleSetMenuDescriptor = ole32.NewProc("OleSetMenuDescriptor")
)
// holemenu (INT_PTR), hwndFrame (HWND), hwndActiveObject (HWND), lpFrame (IOleInPlaceFrame*), lpActiveObj (IOleInPlaceActiveObject*)
r1, _, err := procOleSetMenuDescriptor.Call(
uintptr(holemenu),
uintptr(hwndFrame),
uintptr(hwndActiveObject),
uintptr(lpFrame),
uintptr(lpActiveObj),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction OleSetMenuDescriptor(
holemenu: NativeInt; // INT_PTR
hwndFrame: THandle; // HWND
hwndActiveObject: THandle; // HWND
lpFrame: Pointer; // IOleInPlaceFrame*
lpActiveObj: Pointer // IOleInPlaceActiveObject*
): Integer; stdcall;
external 'OLE32.dll' name 'OleSetMenuDescriptor';result := DllCall("OLE32\OleSetMenuDescriptor"
, "Ptr", holemenu ; INT_PTR
, "Ptr", hwndFrame ; HWND
, "Ptr", hwndActiveObject ; HWND
, "Ptr", lpFrame ; IOleInPlaceFrame*
, "Ptr", lpActiveObj ; IOleInPlaceActiveObject*
, "Int") ; return: HRESULT●OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj) = DLL("OLE32.dll", "int OleSetMenuDescriptor(int, void*, void*, void*, void*)")
# 呼び出し: OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
# holemenu : INT_PTR -> "int"
# hwndFrame : HWND -> "void*"
# hwndActiveObject : HWND -> "void*"
# lpFrame : IOleInPlaceFrame* -> "void*"
# lpActiveObj : IOleInPlaceActiveObject* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ole32" fn OleSetMenuDescriptor(
holemenu: isize, // INT_PTR
hwndFrame: ?*anyopaque, // HWND
hwndActiveObject: ?*anyopaque, // HWND
lpFrame: ?*anyopaque, // IOleInPlaceFrame*
lpActiveObj: ?*anyopaque // IOleInPlaceActiveObject*
) callconv(std.os.windows.WINAPI) i32;proc OleSetMenuDescriptor(
holemenu: int, # INT_PTR
hwndFrame: pointer, # HWND
hwndActiveObject: pointer, # HWND
lpFrame: pointer, # IOleInPlaceFrame*
lpActiveObj: pointer # IOleInPlaceActiveObject*
): int32 {.importc: "OleSetMenuDescriptor", stdcall, dynlib: "OLE32.dll".}pragma(lib, "ole32");
extern(Windows)
int OleSetMenuDescriptor(
ptrdiff_t holemenu, // INT_PTR
void* hwndFrame, // HWND
void* hwndActiveObject, // HWND
void* lpFrame, // IOleInPlaceFrame*
void* lpActiveObj // IOleInPlaceActiveObject*
);ccall((:OleSetMenuDescriptor, "OLE32.dll"), stdcall, Int32,
(Int, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
# holemenu : INT_PTR -> Int
# hwndFrame : HWND -> Ptr{Cvoid}
# hwndActiveObject : HWND -> Ptr{Cvoid}
# lpFrame : IOleInPlaceFrame* -> Ptr{Cvoid}
# lpActiveObj : IOleInPlaceActiveObject* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t OleSetMenuDescriptor(
intptr_t holemenu,
void* hwndFrame,
void* hwndActiveObject,
void* lpFrame,
void* lpActiveObj);
]]
local ole32 = ffi.load("ole32")
-- ole32.OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
-- holemenu : INT_PTR
-- hwndFrame : HWND
-- hwndActiveObject : HWND
-- lpFrame : IOleInPlaceFrame*
-- lpActiveObj : IOleInPlaceActiveObject*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('OLE32.dll');
const OleSetMenuDescriptor = lib.func('__stdcall', 'OleSetMenuDescriptor', 'int32_t', ['intptr_t', 'void *', 'void *', 'void *', 'void *']);
// OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
// holemenu : INT_PTR -> 'intptr_t'
// hwndFrame : HWND -> 'void *'
// hwndActiveObject : HWND -> 'void *'
// lpFrame : IOleInPlaceFrame* -> 'void *'
// lpActiveObj : IOleInPlaceActiveObject* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("OLE32.dll", {
OleSetMenuDescriptor: { parameters: ["isize", "pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
// holemenu : INT_PTR -> "isize"
// hwndFrame : HWND -> "pointer"
// hwndActiveObject : HWND -> "pointer"
// lpFrame : IOleInPlaceFrame* -> "pointer"
// lpActiveObj : IOleInPlaceActiveObject* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t OleSetMenuDescriptor(
intptr_t holemenu,
void* hwndFrame,
void* hwndActiveObject,
void* lpFrame,
void* lpActiveObj);
C, "OLE32.dll");
// $ffi->OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj);
// holemenu : INT_PTR
// hwndFrame : HWND
// hwndActiveObject : HWND
// lpFrame : IOleInPlaceFrame*
// lpActiveObj : IOleInPlaceActiveObject*
// 構造体/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 Ole32 extends StdCallLibrary {
Ole32 INSTANCE = Native.load("ole32", Ole32.class);
int OleSetMenuDescriptor(
long holemenu, // INT_PTR
Pointer hwndFrame, // HWND
Pointer hwndActiveObject, // HWND
Pointer lpFrame, // IOleInPlaceFrame*
Pointer lpActiveObj // IOleInPlaceActiveObject*
);
}@[Link("ole32")]
lib LibOLE32
fun OleSetMenuDescriptor = OleSetMenuDescriptor(
holemenu : LibC::SSizeT, # INT_PTR
hwndFrame : Void*, # HWND
hwndActiveObject : Void*, # HWND
lpFrame : Void*, # IOleInPlaceFrame*
lpActiveObj : Void* # IOleInPlaceActiveObject*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef OleSetMenuDescriptorNative = Int32 Function(IntPtr, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef OleSetMenuDescriptorDart = int Function(int, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final OleSetMenuDescriptor = DynamicLibrary.open('OLE32.dll')
.lookupFunction<OleSetMenuDescriptorNative, OleSetMenuDescriptorDart>('OleSetMenuDescriptor');
// holemenu : INT_PTR -> IntPtr
// hwndFrame : HWND -> Pointer<Void>
// hwndActiveObject : HWND -> Pointer<Void>
// lpFrame : IOleInPlaceFrame* -> Pointer<Void>
// lpActiveObj : IOleInPlaceActiveObject* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function OleSetMenuDescriptor(
holemenu: NativeInt; // INT_PTR
hwndFrame: THandle; // HWND
hwndActiveObject: THandle; // HWND
lpFrame: Pointer; // IOleInPlaceFrame*
lpActiveObj: Pointer // IOleInPlaceActiveObject*
): Integer; stdcall;
external 'OLE32.dll' name 'OleSetMenuDescriptor';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "OleSetMenuDescriptor"
c_OleSetMenuDescriptor :: CIntPtr -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- holemenu : INT_PTR -> CIntPtr
-- hwndFrame : HWND -> Ptr ()
-- hwndActiveObject : HWND -> Ptr ()
-- lpFrame : IOleInPlaceFrame* -> Ptr ()
-- lpActiveObj : IOleInPlaceActiveObject* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let olesetmenudescriptor =
foreign "OleSetMenuDescriptor"
(intptr_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* holemenu : INT_PTR -> intptr_t *)
(* hwndFrame : HWND -> (ptr void) *)
(* hwndActiveObject : HWND -> (ptr void) *)
(* lpFrame : IOleInPlaceFrame* -> (ptr void) *)
(* lpActiveObj : IOleInPlaceActiveObject* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ole32 (t "OLE32.dll"))
(cffi:use-foreign-library ole32)
(cffi:defcfun ("OleSetMenuDescriptor" ole-set-menu-descriptor :convention :stdcall) :int32
(holemenu :int64) ; INT_PTR
(hwnd-frame :pointer) ; HWND
(hwnd-active-object :pointer) ; HWND
(lp-frame :pointer) ; IOleInPlaceFrame*
(lp-active-obj :pointer)) ; IOleInPlaceActiveObject*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $OleSetMenuDescriptor = Win32::API::More->new('OLE32',
'int OleSetMenuDescriptor(LPARAM holemenu, HANDLE hwndFrame, HANDLE hwndActiveObject, LPVOID lpFrame, LPVOID lpActiveObj)');
# my $ret = $OleSetMenuDescriptor->Call($holemenu, $hwndFrame, $hwndActiveObject, $lpFrame, $lpActiveObj);
# holemenu : INT_PTR -> LPARAM
# hwndFrame : HWND -> HANDLE
# hwndActiveObject : HWND -> HANDLE
# lpFrame : IOleInPlaceFrame* -> LPVOID
# lpActiveObj : IOleInPlaceActiveObject* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f OleCreateMenuDescriptor — OLEメニュー合成用のメニュー記述子を作成する。