I posted an article to Japanese Mozilla community site about js-ctypes on Firefox.next (3.7). Firefox.next improves many features such as struct support and callback support for js-ctypes.
This is a sample to use color picker on Windows using js-ctypes. ComDlg32 has color picker API "ChooseColor()". This sample is to access ChooseColor().
Components.utils.import("resource://gre/modules/ctypes.jsm"); var custColors_type = ctypes.ArrayType(ctypes.int32_t, 16); const CHOOSECOLOR = new ctypes.StructType( 'CHOOSECOLOR', [ {'lStructSize': ctypes.uint32_t}, {'hwndOwner' : ctypes.uint32_t}, {'hInstance' : ctypes.uint32_t}, {'rgbResult' : ctypes.uint32_t}, {'lpCustColors' : custColors_type.ptr}, {'Flags' : ctypes.uint32_t}, {'lCustData' : ctypes.uint32_t}, {'lpfnHook' : ctypes.uint32_t}, {'lpTemplateName' : ctypes.uint32_t} ]); var comdlg32 = ctypes.open("comdlg32"); var ChooseColor = comdlg32.declare("ChooseColorW", ctypes.stdcall_abi, ctypes.int32_t, CHOOSECOLOR.ptr); var custColors = new custColors_type(); var col = new CHOOSECOLOR (CHOOSECOLOR.size, 0, 0, 0, custColors.address(), 0, 0, 0, 0); ChooseColor(col.address()); alert(col.rgbResult);
No comments:
Post a Comment