構文
外部データ構造へのインターフェイスを定義します。
説明
例
typedef struct {
DWORD lStructSize;
HWND hwndOwner;
HWND hInstance;
COLORREF rgbResult;
COLORREF *lpCustColors;
DWORD Flags;
LPARAM lCustData;
LPCCHOOKPROC lpfnHook;
LPCCTSTR lpTemplateName;
} CHOOSECOLOR, *LPCHOOSECOLOR;
{let public constant WindowsHook:ProcType =
{proc-type {hwnd:CPointer, msg:int, l:int, w:int}:CPointer}
}
{define-C-struct public ChooseColorStruct
|| Flag values
let public constant CC_RGBINIT:int = 0x0001
field public size:int
field public owner:CPointer
field public instance:CPointer
field private _rgb:int
field public custom-colors:{CArray-of int}
field public flags:int
field public data:CPointer
field public hook:{StdcallCallback-to #WindowsHook}
field public template-name:#String (rep = CString)
{getter public {color}:Color
let rgb:int = self._rgb
{return
{Color.from-rgb-uint8
{bit-and 0xff, rgb},
{bit-and 0xff, {bit-srl rgb, 8}},
{bit-and 0xff, {bit-srl rgb, 16}}
}
}
}
{setter public {color color:Color}:void
let pixel:Pixel = {color.to-Pixel}
set self._rgb =
{bit-or
pixel.red-as-uint8,
{bit-sll pixel.green-as-uint8, 8},
{bit-sll pixel.blue-as-uint8, 16}
}
}
{constructor public {default color:#Color = null}
set self.size = 36
set self.flags = ChooseColorInfo.CC_RGBINIT
set self.custom-colors = {{CArray-of int} 16}
set self.color =
{if-non-null color then
color
else
{Color.from-string "white"}
}
}
}
#include <stdio.h>
#include <windows.h>
void main()
{
printf("CC_RGBINIT == 0x%X\n", CC_RGBINIT);
}