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