Mercurial > projects > dwt-win
changeset 98:ecba636b634e
package dwt/ole
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 09 Feb 2008 03:36:27 +0100 |
parents | 2e6eb5bd2c16 |
children | 873874015a62 |
files | dwt/DWT.d dwt/dwthelper/utils.d dwt/internal/ole/win32/COM.d dwt/ole/win32/OLE.d dwt/ole/win32/OleAutomation.d dwt/ole/win32/OleClientSite.d dwt/ole/win32/OleControlSite.d dwt/ole/win32/OleEvent.d dwt/ole/win32/OleEventSink.d dwt/ole/win32/OleEventTable.d dwt/ole/win32/OleFrame.d dwt/ole/win32/OleFunctionDescription.d dwt/ole/win32/OleListener.d dwt/ole/win32/OleParameterDescription.d dwt/ole/win32/OlePropertyChangeSink.d dwt/ole/win32/OlePropertyDescription.d dwt/ole/win32/Variant.d tango_sys_win32/Types.d |
diffstat | 18 files changed, 2530 insertions(+), 1031 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/DWT.d Fri Feb 08 19:49:32 2008 +0100 +++ b/dwt/DWT.d Sat Feb 09 03:36:27 2008 +0100 @@ -3473,6 +3473,9 @@ * * @param code the DWT error code */ +public static void error (char[] file, long line, int code) { + error (code, null); +} public static void error (int code) { error (code, null); }
--- a/dwt/dwthelper/utils.d Fri Feb 08 19:49:32 2008 +0100 +++ b/dwt/dwthelper/utils.d Sat Feb 09 03:36:27 2008 +0100 @@ -6,7 +6,7 @@ public import dwt.dwthelper.System; public import Math = tango.math.Math; -public import tango.core.Exception : IllegalArgumentException; +public import tango.core.Exception : IllegalArgumentException, IOException; import tango.io.Stdout; import tango.stdc.stringz; @@ -41,6 +41,7 @@ } alias ValueWrapperT!(bool) ValueWrapperBool; +alias ValueWrapperT!(int) ValueWrapperInt; alias ArrayWrapperT!(byte) ArrayWrapperByte; alias ArrayWrapperT!(int) ArrayWrapperInt; alias ArrayWrapperT!(Object) ArrayWrapperObject; @@ -128,6 +129,12 @@ return src[ $-pattern.length .. $ ] == pattern; } +public bool startsWith( char[] src, char[] pattern ){ + if( src.length < pattern.length ){ + return false; + } + return src[ 0 .. pattern.length ] == pattern; +} public char[] toLowerCase( char[] src ){ return tango.text.Unicode.toLower( src ); }
--- a/dwt/internal/ole/win32/COM.d Fri Feb 08 19:49:32 2008 +0100 +++ b/dwt/internal/ole/win32/COM.d Sat Feb 09 03:36:27 2008 +0100 @@ -1,16 +1,20 @@ - -/* - * COM types, constants and APIs +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * all API are aliased from other modules - * - * author : Shawn Liu - */ - + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Shawn Liu + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ module dwt.internal.ole.win32.COM; -private import dwt.internal.ole.win32.COMTYPES; +public import dwt.internal.ole.win32.COMTYPES; private import dwt.internal.ole.win32.OAIDL; private import dwt.internal.ole.win32.OBJIDL; private import dwt.internal.ole.win32.OLEIDL; @@ -26,125 +30,149 @@ public import dwt.internal.win32.OS; +template IIDFromStringT(char[] g) { + static if (g.length == 38) + const GUID IIDFromStringT = IIDFromStringT!(g[1..$-1]); + else static if (g.length == 36) + const GUID IIDFromStringT = { + mixin("0x" ~ g[0..8]), + mixin("0x" ~ g[9..13]), + mixin("0x" ~ g[14..18]), + [ + mixin("0x" ~ g[19..21]), + mixin("0x" ~ g[21..23]), + mixin("0x" ~ g[24..26]), + mixin("0x" ~ g[26..28]), + mixin("0x" ~ g[28..30]), + mixin("0x" ~ g[30..32]), + mixin("0x" ~ g[32..34]), + mixin("0x" ~ g[34..36]) ] }; + else + static assert(false, "Incorrect format for GUID. "~g); +} + + public class COM : OS { //private import std.c.windows.com; // all the GUID // GUIDs for Home Page Browser - public static const GUID IIDJavaBeansBridge = { 0x8AD9C840, 0x044E, 0x11D1, [ 0xB3, 0xE9, 0x00, 0x80, 0x5F, 0x49, 0x9D, 0x93]}; //$NON-NLS-1$ - public static const GUID IIDShockwaveActiveXControl = { 0x166B1BCA, 0x3F9C, 0x11CF, [ 0x80, 0x75, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; //$NON-NLS-1$ - public const GUID IIDIEditorSiteTime = { 0x6BD2AEFE, 0x7876, 0x45e6, [0xA6, 0xE7, 0x3B, 0xFC, 0xDF, 0x65, 0x40, 0xAA]}; - public const GUID IIDIEditorSiteProperty = { 0xD381A1F4, 0x2326, 0x4f3c, [0xAF, 0xB9, 0xB7, 0x53, 0x7D, 0xB9, 0xE2, 0x38]}; - public const GUID IIDIEditorBaseProperty = { 0x61E55B0B, 0x2647, 0x47c4, [0x8C, 0x89, 0xE7, 0x36, 0xEF, 0x15, 0xD6, 0x36]}; - public const GUID IIDIEditorSite = { 0xCDD88AB9, 0xB01D, 0x426E, [0xB0, 0xF0, 0x30, 0x97, 0x3E, 0x9A, 0x07, 0x4B]}; - public const GUID IIDIEditorService = { 0xBEE283FE, 0x7B42, 0x4FF3, [0x82, 0x32, 0x0F, 0x07, 0xD4, 0x3A, 0xBC, 0xF1]}; - public const GUID IIDIEditorManager = { 0xEFDE08C4, 0xBE87, 0x4B1A, [0xBF, 0x84, 0x15, 0xFC, 0x30, 0x20, 0x71, 0x80]}; - - public const GUID IIDIAccessible = { 0x618736E0, 0x3C3D, 0x11CF, [0x81, 0x0C, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71]}; - //public const GUID IIDIAccessibleHandler = { 0x03022430, 0xABC4, 0x11D0, [0xBD, 0xE2, 0x00, 0xAA, 0x00, 0x1A, 0x19, 0x53]}; - //public const GUID IIDIAccessor = { 0x0C733A8C, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]}; - public const GUID IIDIAdviseSink = { 0x0000010F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIAdviseSink2 = { 0x00000125, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIBindCtx = { 0x0000000E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIClassFactory = { 0x00000001, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIClassFactory2 = { 0xB196B28F, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - public const GUID IIDIConnectionPoint = { 0xB196B286, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - public const GUID IIDIConnectionPointContainer = { 0xB196B284, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - //public const GUID IIDICreateErrorInfo = { 0x22F03340, 0x547D, 0x101B, [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19]}; - //public const GUID IIDICreateTypeInfo = { 0x00020405, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDICreateTypeLib = { 0x00020406, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIDataAdviseHolder = { 0x00000110, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIDataObject = { 0x0000010E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIDispatch = { 0x00020400, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIDocHostUIHandler = { 0xBD3F23C0, 0xD43E, 0x11CF, [0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A]}; - public const GUID IIDIDocHostShowUI = { 0xC4D244B0, 0xD43E, 0x11CF, [0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A]}; - public const GUID IIDIDropSource = { 0x00000121, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIDropTarget = { 0x00000122, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIEnumConnectionPoints = { 0xB196B285, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - //public const GUID IIDIEnumConnections = { 0xB196B287, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - public const GUID IIDIEnumFORMATETC = { 0x00000103, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIEnumMoniker = { 0x00000102, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIEnumOLEVERB = { 0x00000104, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIEnumSTATDATA = { 0x00000105, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIEnumSTATSTG = { 0x0000000D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIEnumString = { 0x00000101, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIEnumUnknown = { 0x00000100, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIEnumVARIANT = { 0x00020404, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIErrorInfo = { 0x1CF2B120, 0x547D, 0x101B, [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19]}; - //public const GUID IIDIErrorLog = { 0x3127CA40, 0x446E, 0x11CE, [0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]}; - //public const GUID IIDIExternalConnection = { 0x00000019, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIFont = { 0xBEF6E002, 0xA874, 0x101A, [0x8B, 0xBA, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; - //public const GUID IIDIFontDisp = { 0xBEF6E003, 0xA874, 0x101A, [0x8B, 0xBA, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; - public static const /*GUID*/ char[] IIDIHTMLDocumentEvents2 = /*IIDFromString(*/"{3050F613-98B5-11CF-BB82-00AA00BDCE0B}"/*)*/; - public const GUID IIDIInternetSecurityManager = { 0x79eac9ee, 0xbaf9, 0x11ce, [0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b]}; - //public const GUID IIDILockBytes = { 0x0000000A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIMalloc = { 0x00000002, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIMallocSpy = { 0x0000001D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIMarshal = { 0x00000003, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIMessageFilter = { 0x00000016, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIMoniker = { 0x0000000F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIOleAdviseHolder = { 0x00000111, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIOleCache = { 0x0000011E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIOleCache2 = { 0x00000128, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIOleCacheControl = { 0x00000129, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleClientSite = { 0x00000118, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleCommandTarget = { 0xB722BCCB, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]}; - public const GUID IIDIOleContainer = { 0x0000011B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleControl = { 0xB196B288, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - public const GUID IIDIOleControlSite = { 0xB196B289, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - public const GUID IIDIOleDocument = { 0xB722BCC5, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]}; - public const GUID IIDIOleDocumentSite = { 0xB722BCC7, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]}; - public const GUID IIDIOleInPlaceActiveObject = { 0x00000117, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleInPlaceFrame = { 0x00000116, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleInPlaceObject = { 0x00000113, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleInPlaceSite = { 0x00000119, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleInPlaceUIWindow = { 0x00000115, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIOleItemContainer = { 0x0000011C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleLink = { 0x0000011D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleObject = { 0x00000112, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIOleWindow = { 0x00000114, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIParseDisplayName = { 0x0000011A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIPerPropertyBrowsing = { 0x376BD3AA, 0x3845, 0x101B, [0x84, 0xED, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]}; - public const GUID IIDIPersist = { 0x0000010C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIPersistFile = { 0x0000010B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIPersistMemory = { 0xBD1AE5E0, 0xA6AE, 0x11CE, [0xBD, 0x37, 0x50, 0x42, 0x00, 0xC1, 0x00, 0x00]}; - //public const GUID IIDIPersistPropertyBag = { 0x37D84F60, 0x42CB, 0x11CE, [0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]}; - public const GUID IIDIPersistStorage = { 0x0000010A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIPersistStream = { 0x00000109, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIPersistStreamInit = { 0x7FD52380, 0x4E07, 0x101B, [0xAE, 0x2D, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]}; - //public const GUID IIDIPicture = { 0x7BF80980, 0xBF32, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; - //public const GUID IIDIPictureDisp = { 0x7BF80981, 0xBF32, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; - //public const GUID IIDIPropertyBag = { 0x55272A00, 0x42CB, 0x11CE, [0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]}; - public const GUID IIDIPropertyNotifySink = { 0x9BFBBC02, 0xEFF1, 0x101A, [0x84, 0xED, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - //public const GUID IIDIPropertyPage = { 0xB196B28D, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - //public const GUID IIDIPropertyPage2 = { 0x01E44665, 0x24AC, 0x101B, [0x84, 0xED, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]}; - //public const GUID IIDIPropertyPageSite = { 0xB196B28C, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - public const GUID IIDIProvideClassInfo = { 0xB196B283, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - public const GUID IIDIProvideClassInfo2 = { 0xA6BC3AC0, 0xDBAA, 0x11CE, [0x9D, 0xE3, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]}; - //public const GUID IIDIPSFactoryBuffer = { 0xD5F569D0, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]}; - //public const GUID IIDIRootStorage = { 0x00000012, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIROTData = { 0xF29F6BC0, 0x5021, 0x11CE, [0xAA, 0x15, 0x00, 0x00, 0x69, 0x01, 0x29, 0x3F]}; - //public const GUID IIDIRpcChannelBuffer = { 0xD5F56B60, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]}; - //public const GUID IIDIRpcProxyBuffer = { 0xD5F56A34, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]}; - //public const GUID IIDIRpcStubBuffer = { 0xD5F56AFC, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]}; - //public const GUID IIDIRunnableObject = { 0x00000126, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIRunningObjectTable = { 0x00000010, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDISimpleFrameSite = { 0x742B0E01, 0x14E6, 0x101B, [0x91, 0x4E, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; - public const GUID IIDIServiceProvider = { 0x6d5140c1, 0x7436, 0x11ce, [0x80, 0x34, 0x00, 0xaa, 0x00, 0x60, 0x09, 0xfa]}; - public const GUID IIDISpecifyPropertyPages = { 0xB196B28B, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; - //public const GUID IIDIStdMarshalInfo = { 0x00000018, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIStorage = { 0x0000000B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIStream = { 0x0000000C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDISupportErrorInfo = { 0xDF0B3D60, 0x548F, 0x101B, [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19]}; - //public const GUID IIDITypeComp = { 0x00020403, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDITypeLib = { 0x00020402, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIUnknown = { 0x00000000, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - //public const GUID IIDIViewObject = { 0x0000010D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public const GUID IIDIViewObject2 = { 0x00000127, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; - public static const GUID CGID_DocHostCommandHandler = { 0xf38bc242, 0xb950, 0x11d1, [0x89, 0x18, 0x00, 0xc0, 0x4f, 0xc2, 0xc8, 0x36]}; //$NON-NLS-1$ - public static const GUID CGID_Explorer = { 0x000214D0, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; //$NON-NLS-1$ + /** GUID Constants */ + public static const GUID IIDJavaBeansBridge = IIDFromStringT!("{8AD9C840-044E-11D1-B3E9-00805F499D93}"); //$NON-NLS-1$ + public static const GUID IIDShockwaveActiveXControl = IIDFromStringT!("{166B1BCA-3F9C-11CF-8075-444553540000}"); //$NON-NLS-1$ + public static const GUID IIDIEditorSiteTime = IIDFromStringT!("{6BD2AEFE-7876-45e6-A6E7-3BFCDF6540AA}"); //$NON-NLS-1$ + public static const GUID IIDIEditorSiteProperty = IIDFromStringT!("{D381A1F4-2326-4f3c-AFB9-B7537DB9E238}"); //$NON-NLS-1$ + public static const GUID IIDIEditorBaseProperty = IIDFromStringT!("{61E55B0B-2647-47c4-8C89-E736EF15D636}"); //$NON-NLS-1$ + public static const GUID IIDIEditorSite = IIDFromStringT!("{CDD88AB9-B01D-426E-B0F0-30973E9A074B}"); //$NON-NLS-1$ + public static const GUID IIDIEditorService = IIDFromStringT!("{BEE283FE-7B42-4FF3-8232-0F07D43ABCF1}"); //$NON-NLS-1$ + public static const GUID IIDIEditorManager = IIDFromStringT!("{EFDE08C4-BE87-4B1A-BF84-15FC30207180}"); //$NON-NLS-1$ + public static const GUID IIDIAccessible = IIDFromStringT!("{618736E0-3C3D-11CF-810C-00AA00389B71}"); //$NON-NLS-1$ + //public static const GUID IIDIAccessibleHandler = IIDFromStringT!("{03022430-ABC4-11D0-BDE2-00AA001A1953}"); //$NON-NLS-1$ + //public static const GUID IIDIAccessor = IIDFromStringT!("{0C733A8C-2A1C-11CE-ADE5-00AA0044773D}"); //$NON-NLS-1$ + public static const GUID IIDIAdviseSink = IIDFromStringT!("{0000010F-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIAdviseSink2 = IIDFromStringT!("{00000125-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIBindCtx = IIDFromStringT!("{0000000E-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIClassFactory = IIDFromStringT!("{00000001-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIClassFactory2 = IIDFromStringT!("{B196B28F-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + public static const GUID IIDIConnectionPoint = IIDFromStringT!("{B196B286-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + public static const GUID IIDIConnectionPointContainer = IIDFromStringT!("{B196B284-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + //public static const GUID IIDICreateErrorInfo = IIDFromStringT!("{22F03340-547D-101B-8E65-08002B2BD119}"); //$NON-NLS-1$ + //public static const GUID IIDICreateTypeInfo = IIDFromStringT!("{00020405-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDICreateTypeLib = IIDFromStringT!("{00020406-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIDataAdviseHolder = IIDFromStringT!("{00000110-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIDataObject = IIDFromStringT!("{0000010E-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIDispatch = IIDFromStringT!("{00020400-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIDocHostUIHandler = IIDFromStringT!("{BD3F23C0-D43E-11CF-893B-00AA00BDCE1A}"); //$NON-NLS-1$ + public static const GUID IIDIDocHostShowUI = IIDFromStringT!("{C4D244B0-D43E-11CF-893B-00AA00BDCE1A}"); //$NON-NLS-1$ + public static const GUID IIDIDropSource = IIDFromStringT!("{00000121-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIDropTarget = IIDFromStringT!("{00000122-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIEnumConnectionPoints = IIDFromStringT!("{B196B285-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + //public static const GUID IIDIEnumConnections = IIDFromStringT!("{B196B287-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + public static const GUID IIDIEnumFORMATETC = IIDFromStringT!("{00000103-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIEnumMoniker = IIDFromStringT!("{00000102-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIEnumOLEVERB = IIDFromStringT!("{00000104-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIEnumSTATDATA = IIDFromStringT!("{00000105-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIEnumSTATSTG = IIDFromStringT!("{0000000D-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIEnumString = IIDFromStringT!("{00000101-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIEnumUnknown = IIDFromStringT!("{00000100-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIEnumVARIANT = IIDFromStringT!("{00020404-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIErrorInfo = IIDFromStringT!("{1CF2B120-547D-101B-8E65-08002B2BD119}"); //$NON-NLS-1$ + //public static const GUID IIDIErrorLog = IIDFromStringT!("{3127CA40-446E-11CE-8135-00AA004BB851}"); //$NON-NLS-1$ + //public static const GUID IIDIExternalConnection = IIDFromStringT!("{00000019-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIFont = IIDFromStringT!("{BEF6E002-A874-101A-8BBA-00AA00300CAB}"); //$NON-NLS-1$ + //public static const GUID IIDIFontDisp = IIDFromStringT!("{BEF6E003-A874-101A-8BBA-00AA00300CAB}"); //$NON-NLS-1$ + public static const /*GUID*/ char[] IIDIHTMLDocumentEvents2 = /*IIDFromStringT!(*/"{3050F613-98B5-11CF-BB82-00AA00BDCE0B}"/*)*/; + public static const GUID IIDIInternetSecurityManager = IIDFromStringT!("{79eac9ee-baf9-11ce-8c82-00aa004ba90b}"); //$NON-NLS-1$ + //public static const GUID IIDILockBytes = IIDFromStringT!("{0000000A-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIMalloc = IIDFromStringT!("{00000002-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIMallocSpy = IIDFromStringT!("{0000001D-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIMarshal = IIDFromStringT!("{00000003-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIMessageFilter = IIDFromStringT!("{00000016-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIMoniker = IIDFromStringT!("{0000000F-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIOleAdviseHolder = IIDFromStringT!("{00000111-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIOleCache = IIDFromStringT!("{0000011E-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIOleCache2 = IIDFromStringT!("{00000128-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIOleCacheControl = IIDFromStringT!("{00000129-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleClientSite = IIDFromStringT!("{00000118-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleCommandTarget = IIDFromStringT!("{B722BCCB-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$ + public static const GUID IIDIOleContainer = IIDFromStringT!("{0000011B-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleControl = IIDFromStringT!("{B196B288-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + public static const GUID IIDIOleControlSite = IIDFromStringT!("{B196B289-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + public static const GUID IIDIOleDocument = IIDFromStringT!("{B722BCC5-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$ + public static const GUID IIDIOleDocumentSite = IIDFromStringT!("{B722BCC7-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$ + public static const GUID IIDIOleInPlaceActiveObject = IIDFromStringT!("{00000117-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleInPlaceFrame = IIDFromStringT!("{00000116-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleInPlaceObject = IIDFromStringT!("{00000113-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleInPlaceSite = IIDFromStringT!("{00000119-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleInPlaceUIWindow = IIDFromStringT!("{00000115-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIOleItemContainer = IIDFromStringT!("{0000011C-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleLink = IIDFromStringT!("{0000011D-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleObject = IIDFromStringT!("{00000112-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIOleWindow = IIDFromStringT!("{00000114-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIParseDisplayName = IIDFromStringT!("{0000011A-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIPerPropertyBrowsing = IIDFromStringT!("{376BD3AA-3845-101B-84ED-08002B2EC713}"); //$NON-NLS-1$ + public static const GUID IIDIPersist = IIDFromStringT!("{0000010C-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIPersistFile = IIDFromStringT!("{0000010B-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIPersistMemory = IIDFromStringT!("{BD1AE5E0-A6AE-11CE-BD37-504200C10000}"); //$NON-NLS-1$ + //public static const GUID IIDIPersistPropertyBag = IIDFromStringT!("{37D84F60-42CB-11CE-8135-00AA004BB851}"); //$NON-NLS-1$ + public static const GUID IIDIPersistStorage = IIDFromStringT!("{0000010A-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIPersistStream = IIDFromStringT!("{00000109-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIPersistStreamInit = IIDFromStringT!("{7FD52380-4E07-101B-AE2D-08002B2EC713}"); //$NON-NLS-1$ + //public static const GUID IIDIPicture = IIDFromStringT!("{7BF80980-BF32-101A-8BBB-00AA00300CAB}"); //$NON-NLS-1$ + //public static const GUID IIDIPictureDisp = IIDFromStringT!("{7BF80981-BF32-101A-8BBB-00AA00300CAB}"); //$NON-NLS-1$ + //public static const GUID IIDIPropertyBag = IIDFromStringT!("{55272A00-42CB-11CE-8135-00AA004BB851}"); //$NON-NLS-1$ + public static const GUID IIDIPropertyNotifySink = IIDFromStringT!("{9BFBBC02-EFF1-101A-84ED-00AA00341D07}"); //$NON-NLS-1$ + //public static const GUID IIDIPropertyPage = IIDFromStringT!("{B196B28D-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + //public static const GUID IIDIPropertyPage2 = IIDFromStringT!("{01E44665-24AC-101B-84ED-08002B2EC713}"); //$NON-NLS-1$ + //public static const GUID IIDIPropertyPageSite = IIDFromStringT!("{B196B28C-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + public static const GUID IIDIProvideClassInfo = IIDFromStringT!("{B196B283-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + public static const GUID IIDIProvideClassInfo2 = IIDFromStringT!("{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}"); //$NON-NLS-1$ + //public static const GUID IIDIPSFactoryBuffer = IIDFromStringT!("{D5F569D0-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$ + //public static const GUID IIDIRootStorage = IIDFromStringT!("{00000012-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIROTData = IIDFromStringT!("{F29F6BC0-5021-11CE-AA15-00006901293F}"); //$NON-NLS-1$ + //public static const GUID IIDIRpcChannelBuffer = IIDFromStringT!("{D5F56B60-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$ + //public static const GUID IIDIRpcProxyBuffer = IIDFromStringT!("{D5F56A34-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$ + //public static const GUID IIDIRpcStubBuffer = IIDFromStringT!("{D5F56AFC-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$ + //public static const GUID IIDIRunnableObject = IIDFromStringT!("{00000126-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIRunningObjectTable = IIDFromStringT!("{00000010-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDISimpleFrameSite = IIDFromStringT!("{742B0E01-14E6-101B-914E-00AA00300CAB}"); //$NON-NLS-1$ + public static const GUID IIDIServiceProvider = IIDFromStringT!("{6d5140c1-7436-11ce-8034-00aa006009fa}"); //$NON-NLS-1$ + public static const GUID IIDISpecifyPropertyPages = IIDFromStringT!("{B196B28B-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$ + //public static const GUID IIDIStdMarshalInfo = IIDFromStringT!("{00000018-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIStorage = IIDFromStringT!("{0000000B-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIStream = IIDFromStringT!("{0000000C-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDISupportErrorInfo = IIDFromStringT!("{DF0B3D60-548F-101B-8E65-08002B2BD119}"); //$NON-NLS-1$ + //public static const GUID IIDITypeComp = IIDFromStringT!("{00020403-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDITypeLib = IIDFromStringT!("{00020402-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIUnknown = IIDFromStringT!("{00000000-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + //public static const GUID IIDIViewObject = IIDFromStringT!("{0000010D-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID IIDIViewObject2 = IIDFromStringT!("{00000127-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + public static const GUID CGID_DocHostCommandHandler = IIDFromStringT!("{f38bc242-b950-11d1-8918-00c04fc2c836}"); //$NON-NLS-1$ + public static const GUID CGID_Explorer = IIDFromStringT!("{000214D0-0000-0000-C000-000000000046}"); //$NON-NLS-1$ + + /* Constants */ //public static const int ADVF_DATAONSTOP = 64; @@ -713,42 +741,10 @@ */ + +public static const int CHILDID_SELF = 0; public static const int CO_E_OBJNOTCONNECTED = 0x800401FD; -public static const int STATE_SYSTEM_NORMAL = 0; -//public static const int STATE_SYSTEM_UNAVAILABLE = 0x1; -public static const int STATE_SYSTEM_SELECTED = 0x2; -public static const int STATE_SYSTEM_FOCUSED = 0x4; -public static const int STATE_SYSTEM_PRESSED = 0x8; -public static const int STATE_SYSTEM_CHECKED = 0x10; -//public static const int STATE_SYSTEM_MIXED = 0x20; -//public static const int STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED; -public static const int STATE_SYSTEM_READONLY = 0x40; -public static const int STATE_SYSTEM_HOTTRACKED = 0x80; -//public static const int STATE_SYSTEM_DEFAULT = 0x100; -public static const int STATE_SYSTEM_EXPANDED = 0x200; -public static const int STATE_SYSTEM_COLLAPSED = 0x400; -public static const int STATE_SYSTEM_BUSY = 0x800; -//public static const int STATE_SYSTEM_FLOATING = 0x1000; -//public static const int STATE_SYSTEM_MARQUEED = 0x2000; -//public static const int STATE_SYSTEM_ANIMATED = 0x4000; -public static const int STATE_SYSTEM_INVISIBLE = 0x8000; -public static const int STATE_SYSTEM_OFFSCREEN = 0x10000; -public static const int STATE_SYSTEM_SIZEABLE = 0x20000; -//public static const int STATE_SYSTEM_MOVEABLE = 0x40000; -//public static const int STATE_SYSTEM_SELFVOICING = 0x80000; -public static const int STATE_SYSTEM_FOCUSABLE = 0x100000; -public static const int STATE_SYSTEM_SELECTABLE = 0x200000; -public static const int STATE_SYSTEM_LINKED = 0x400000; -//public static const int STATE_SYSTEM_TRAVERSED = 0x800000; -public static const int STATE_SYSTEM_MULTISELECTABLE = 0x1000000; -//public static const int STATE_SYSTEM_EXTSELECTABLE = 0x2000000; -//public static const int STATE_SYSTEM_ALERT_LOW = 0x4000000; -//public static const int STATE_SYSTEM_ALERT_MEDIUM = 0x8000000; -//public static const int STATE_SYSTEM_ALERT_HIGH = 0x10000000; -//public static const int STATE_SYSTEM_PROTECTED = 0x20000000; -//public static const int STATE_SYSTEM_VALID = 0x3fffffff; - //public static const int ROLE_SYSTEM_TITLEBAR = 0x1; public static const int ROLE_SYSTEM_MENUBAR = 0x2; public static const int ROLE_SYSTEM_SCROLLBAR = 0x3; @@ -811,7 +807,39 @@ public static const int ROLE_SYSTEM_PAGETABLIST = 0x3c; //public static const int ROLE_SYSTEM_CLOCK = 0x3d; -public static const int CHILDID_SELF = 0; +public static const int STATE_SYSTEM_NORMAL = 0; +//public static const int STATE_SYSTEM_UNAVAILABLE = 0x1; +public static const int STATE_SYSTEM_SELECTED = 0x2; +public static const int STATE_SYSTEM_FOCUSED = 0x4; +public static const int STATE_SYSTEM_PRESSED = 0x8; +public static const int STATE_SYSTEM_CHECKED = 0x10; +//public static const int STATE_SYSTEM_MIXED = 0x20; +//public static const int STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED; +public static const int STATE_SYSTEM_READONLY = 0x40; +public static const int STATE_SYSTEM_HOTTRACKED = 0x80; +//public static const int STATE_SYSTEM_DEFAULT = 0x100; +public static const int STATE_SYSTEM_EXPANDED = 0x200; +public static const int STATE_SYSTEM_COLLAPSED = 0x400; +public static const int STATE_SYSTEM_BUSY = 0x800; +//public static const int STATE_SYSTEM_FLOATING = 0x1000; +//public static const int STATE_SYSTEM_MARQUEED = 0x2000; +//public static const int STATE_SYSTEM_ANIMATED = 0x4000; +public static const int STATE_SYSTEM_INVISIBLE = 0x8000; +public static const int STATE_SYSTEM_OFFSCREEN = 0x10000; +public static const int STATE_SYSTEM_SIZEABLE = 0x20000; +//public static const int STATE_SYSTEM_MOVEABLE = 0x40000; +//public static const int STATE_SYSTEM_SELFVOICING = 0x80000; +public static const int STATE_SYSTEM_FOCUSABLE = 0x100000; +public static const int STATE_SYSTEM_SELECTABLE = 0x200000; +public static const int STATE_SYSTEM_LINKED = 0x400000; +//public static const int STATE_SYSTEM_TRAVERSED = 0x800000; +public static const int STATE_SYSTEM_MULTISELECTABLE = 0x1000000; +//public static const int STATE_SYSTEM_EXTSELECTABLE = 0x2000000; +//public static const int STATE_SYSTEM_ALERT_LOW = 0x4000000; +//public static const int STATE_SYSTEM_ALERT_MEDIUM = 0x8000000; +//public static const int STATE_SYSTEM_ALERT_HIGH = 0x10000000; +//public static const int STATE_SYSTEM_PROTECTED = 0x20000000; +//public static const int STATE_SYSTEM_VALID = 0x3fffffff; /* End ACCESSIBILITY */
--- a/dwt/ole/win32/OLE.d Fri Feb 08 19:49:32 2008 +0100 +++ b/dwt/ole/win32/OLE.d Sat Feb 09 03:36:27 2008 +0100 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> *******************************************************************************/ module dwt.ole.win32.OLE; @@ -282,9 +284,15 @@ static const char[] ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$ +public static void error (char[] file, long line, int code) { + error (code, 0); +} public static void error (int code) { error (code, 0); } +public static void error (char[] file, long line, int code, int hresult) { + error (code, hresult); +} public static void error (int code, int hresult) { switch (code) {
--- a/dwt/ole/win32/OleAutomation.d Fri Feb 08 19:49:32 2008 +0100 +++ b/dwt/ole/win32/OleAutomation.d Sat Feb 09 03:36:27 2008 +0100 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> *******************************************************************************/ module dwt.ole.win32.OleAutomation; @@ -25,16 +27,13 @@ import dwt.internal.win32.OS; import dwt.ole.win32.OleClientSite; - +import dwt.ole.win32.OlePropertyDescription; +import dwt.ole.win32.OleFunctionDescription; +import dwt.ole.win32.OleParameterDescription; +import dwt.ole.win32.Variant; +import dwt.ole.win32.OLE; -//PORTING_TYPE -public final class OleAutomation { - this(IDispatch idispatch); - public this(OleClientSite clientSite) ; - IDispatch getAddress() ; -} - -/++ +import dwt.dwthelper.utils; /** * OleAutomation provides a generic mechanism for accessing functionality that is @@ -103,7 +102,7 @@ */ public final class OleAutomation { private IDispatch objIDispatch; - private String exceptionDescription; + private char[] exceptionDescription; private ITypeInfo objITypeInfo; this(IDispatch idispatch) { @@ -111,10 +110,8 @@ objIDispatch = idispatch; objIDispatch.AddRef(); - int[] ppv = new int[1]; - int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv); + int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, &objITypeInfo); if (result is OLE.S_OK) { - objITypeInfo = new ITypeInfo(ppv[0]); objITypeInfo.AddRef(); } } @@ -132,10 +129,8 @@ if (clientSite is null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS); objIDispatch = clientSite.getAutomationObject(); - int[] ppv = new int[1]; - int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv); + auto result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, &objITypeInfo); if (result is OLE.S_OK) { - objITypeInfo = new ITypeInfo(ppv[0]); objITypeInfo.AddRef(); } } @@ -158,55 +153,62 @@ objITypeInfo = null; } -int getAddress() { - return objIDispatch.getAddress(); +IDispatch getAddress() { + return objIDispatch; } -public String getHelpFile(int dispId) { +public char[] getHelpFile(int dispId) { if (objITypeInfo is null) return null; - String[] file = new String[1]; - int rc = objITypeInfo.GetDocumentation(dispId, null, null, null, file ); - if (rc is OLE.S_OK) return file[0]; + BSTR file; + HRESULT rc = objITypeInfo.GetDocumentation(dispId, null, null, null, &file ); + if (rc is OLE.S_OK) { + char[] str = WCHARzToStr( file, -1 ); + COM.SysFreeString(file); + return str; + } return null; } -public String getDocumentation(int dispId) { +public char[] getDocumentation(int dispId) { if (objITypeInfo is null) return null; - String[] doc = new String[1]; - int rc = objITypeInfo.GetDocumentation(dispId, null, doc, null, null ); - if (rc is OLE.S_OK) return doc[0]; + BSTR doc; + HRESULT rc = objITypeInfo.GetDocumentation(dispId, null, &doc, null, null ); + if (rc == OLE.S_OK) { + char[] s = WCHARzToStr(doc, -1); + COM.SysFreeString(doc); + return s; + } return null; } public OlePropertyDescription getPropertyDescription(int index) { if (objITypeInfo is null) return null; - int[] ppVarDesc = new int[1]; - int rc = objITypeInfo.GetVarDesc(index, ppVarDesc); - if (rc !is OLE.S_OK) return null; - VARDESC vardesc = new VARDESC(); - COM.MoveMemory(vardesc, ppVarDesc[0], VARDESC.sizeof); + VARDESC* vardesc; + HRESULT rc = objITypeInfo.GetVarDesc(index, &vardesc); + if (rc != OLE.S_OK) return null; +// VARDESC* vardesc = new VARDESC(); +// COM.MoveMemory(vardesc, ppVarDesc[0], VARDESC.sizeof); OlePropertyDescription data = new OlePropertyDescription(); data.id = vardesc.memid; data.name = getName(vardesc.memid); - data.type = vardesc.elemdescVar_tdesc_vt; - if (data.type is OLE.VT_PTR) { - short[] vt = new short[1]; - COM.MoveMemory(vt, vardesc.elemdescVar_tdesc_union + 4, 2); - data.type = vt[0]; + data.type = vardesc.elemdescVar.tdesc.vt; + if (data.type == OLE.VT_PTR) { +// short[] vt = new short[1]; +// COM.MoveMemory(vt, vardesc.elemdescVar.tdesc_union + 4, 2); + // TODO: + data.type = vardesc.elemdescVar.tdesc.vt; } data.flags = vardesc.wVarFlags; data.kind = vardesc.varkind; data.description = getDocumentation(vardesc.memid); data.helpFile = getHelpFile(vardesc.memid); - objITypeInfo.ReleaseVarDesc(ppVarDesc[0]); + objITypeInfo.ReleaseVarDesc(vardesc); return data; } public OleFunctionDescription getFunctionDescription(int index) { if (objITypeInfo is null) return null; - int[] ppFuncDesc = new int[1]; - int rc = objITypeInfo.GetFuncDesc(index, ppFuncDesc); - if (rc !is OLE.S_OK) return null; - FUNCDESC funcdesc = new FUNCDESC(); - COM.MoveMemory(funcdesc, ppFuncDesc[0], FUNCDESC.sizeof); + FUNCDESC* funcdesc; + HRESULT rc = objITypeInfo.GetFuncDesc(index, &funcdesc); + if (rc != OLE.S_OK) return null; OleFunctionDescription data = new OleFunctionDescription(); @@ -219,7 +221,7 @@ data.documentation = getDocumentation(funcdesc.memid); data.helpFile = getHelpFile(funcdesc.memid); - String[] names = getNames(funcdesc.memid, funcdesc.cParams + 1); + char[][] names = getNames(funcdesc.memid, funcdesc.cParams + 1); if (names.length > 0) { data.name = names[0]; } @@ -229,59 +231,68 @@ if (names.length > i + 1) { data.args[i].name = names[i + 1]; } - short[] vt = new short[1]; - COM.MoveMemory(vt, funcdesc.lprgelemdescParam + i * 16 + 4, 2); + short[1] vt; + COM.MoveMemory(vt.ptr, funcdesc.lprgelemdescParam + i * 16 + 4, 2); if (vt[0] is OLE.VT_PTR) { - int[] pTypedesc = new int[1]; - COM.MoveMemory(pTypedesc, funcdesc.lprgelemdescParam + i * 16, 4); - short[] vt2 = new short[1]; - COM.MoveMemory(vt2, pTypedesc[0] + 4, 2); - vt[0] = (short)(vt2[0] | COM.VT_BYREF); + int[1] pTypedesc; + COM.MoveMemory(pTypedesc.ptr, funcdesc.lprgelemdescParam + i * 16, 4); + short[1] vt2; + COM.MoveMemory(vt2.ptr, pTypedesc[0] + 4, 2); + vt[0] = cast(short)(vt2[0] | COM.VT_BYREF); } data.args[i].type = vt[0]; - short[] wParamFlags = new short[1]; - COM.MoveMemory(wParamFlags, funcdesc.lprgelemdescParam + i * 16 + 12, 2); + short[1] wParamFlags; + COM.MoveMemory(wParamFlags.ptr, funcdesc.lprgelemdescParam + i * 16 + 12, 2); data.args[i].flags = wParamFlags[0]; } - data.returnType = funcdesc.elemdescFunc_tdesc_vt; + data.returnType = funcdesc.elemdescFunc.tdesc.vt; if (data.returnType is OLE.VT_PTR) { - short[] vt = new short[1]; - COM.MoveMemory(vt, funcdesc.elemdescFunc_tdesc_union + 4, 2); + ushort[1] vt; + COM.MoveMemory(vt.ptr, funcdesc.elemdescFunc.tdesc.u.lpadesc, 2); data.returnType = vt[0]; } - objITypeInfo.ReleaseFuncDesc(ppFuncDesc[0]); + objITypeInfo.ReleaseFuncDesc(funcdesc); return data; } -public TYPEATTR getTypeInfoAttributes() { +public TYPEATTR* getTypeInfoAttributes() { if (objITypeInfo is null) return null; - int[] ppTypeAttr = new int[1]; - int rc = objITypeInfo.GetTypeAttr(ppTypeAttr); + TYPEATTR* ppTypeAttr; + HRESULT rc = objITypeInfo.GetTypeAttr(&ppTypeAttr); if (rc !is OLE.S_OK) return null; - TYPEATTR typeattr = new TYPEATTR(); - COM.MoveMemory(typeattr, ppTypeAttr[0], TYPEATTR.sizeof); - objITypeInfo.ReleaseTypeAttr(ppTypeAttr[0]); + TYPEATTR* typeattr = new TYPEATTR(); + COM.MoveMemory(typeattr, ppTypeAttr, TYPEATTR.sizeof); + objITypeInfo.ReleaseTypeAttr(ppTypeAttr); return typeattr; } -public String getName(int dispId) { + +public char[] getName(int dispId) { if (objITypeInfo is null) return null; - String[] name = new String[1]; - int rc = objITypeInfo.GetDocumentation(dispId, name, null, null, null ); - if (rc is OLE.S_OK) return name[0]; + BSTR name; + HRESULT rc = objITypeInfo.GetDocumentation(dispId, &name, null, null, null ); + if (rc == OLE.S_OK) { + char[] s = WCHARzToStr(name, -1); + COM.SysFreeString(name); + return s; + } return null; } -public String[] getNames(int dispId, int maxSize) { - if (objITypeInfo is null) return new String[0]; - String[] names = new String[maxSize]; - int[] count = new int[1]; - int rc = objITypeInfo.GetNames(dispId, names, maxSize, count); - if (rc is OLE.S_OK) { - String[] newNames = new String[count[0]]; - System.arraycopy(names, 0, newNames, 0, count[0]); + +public char[][] getNames(int dispId, int maxSize) { + if (objITypeInfo is null) return new char[][0]; + BSTR[] names = new BSTR[maxSize]; + uint count; + HRESULT rc = objITypeInfo.GetNames(dispId, names.ptr, maxSize, &count); + if (rc == OLE.S_OK) { + char[][] newNames = new char[][count]; + for(int i=0; i<count; ++i){ + newNames[i] = WCHARzToStr(names[i], -1); + COM.SysFreeString(names[i]); + } return newNames; } - return new String[0]; + return null; } /** * Returns the positive integer values (IDs) that are associated with the specified names by the @@ -293,11 +304,18 @@ * @return positive integer values that are associated with the specified names in the same * order as the names where provided; or null if the names are unknown */ -public int[] getIDsOfNames(String[] names) { +public int[] getIDsOfNames(char[][] names) { - int[] rgdispid = new int[names.length]; - int result = objIDispatch.GetIDsOfNames(new GUID(), names, names.length, COM.LOCALE_USER_DEFAULT, rgdispid); - if (result !is COM.S_OK) return null; + int count = names.length; + wchar*[] wcNames = new wchar*[count]; + for(int i=0; i<count; ++i){ + wcNames[i] = StrToWCHARz(names[i]); + } + int[] rgdispid = new int[count]; + // TODO: NULL GUID ?? + GUID id; + HRESULT result = objIDispatch.GetIDsOfNames(&id, wcNames.ptr, count, COM.LOCALE_USER_DEFAULT, rgdispid.ptr); + if (result != COM.S_OK) return null; return rgdispid; } @@ -306,7 +324,7 @@ * * @return a description of the last error encountered */ -public String getLastError() { +public char[] getLastError() { return exceptionDescription; @@ -321,7 +339,7 @@ */ public Variant getProperty(int dispIdMember) { Variant pVarResult = new Variant(); - int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, null, null, pVarResult); + HRESULT result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, null, null, pVarResult); return (result is OLE.S_OK) ? pVarResult : null; } /** @@ -339,7 +357,7 @@ */ public Variant getProperty(int dispIdMember, Variant[] rgvarg) { Variant pVarResult = new Variant(); - int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, null, pVarResult); + HRESULT result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, null, pVarResult); return (result is OLE.S_OK) ? pVarResult : null; } @@ -363,7 +381,7 @@ */ public Variant getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) { Variant pVarResult = new Variant(); - int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, rgdispidNamedArgs, pVarResult); + HRESULT result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, rgdispidNamedArgs, pVarResult); return (result is OLE.S_OK) ? pVarResult : null; } @@ -377,7 +395,7 @@ */ public Variant invoke(int dispIdMember) { Variant pVarResult = new Variant(); - int result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, pVarResult); + HRESULT result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, pVarResult); return (result is COM.S_OK) ? pVarResult : null; } /** @@ -393,7 +411,7 @@ */ public Variant invoke(int dispIdMember, Variant[] rgvarg) { Variant pVarResult = new Variant(); - int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, pVarResult); + HRESULT result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, pVarResult); return (result is COM.S_OK) ? pVarResult : null; } /** @@ -416,66 +434,77 @@ */ public Variant invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) { Variant pVarResult = new Variant(); - int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, pVarResult); + HRESULT result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, pVarResult); return (result is COM.S_OK) ? pVarResult : null; } -private int invoke(int dispIdMember, int wFlags, Variant[] rgvarg, int[] rgdispidNamedArgs, Variant pVarResult) { +private int invoke(int dispIdMember, ushort wFlags, Variant[] rgvarg, int[] rgdispidNamedArgs, Variant pVarResult) { + assert(objIDispatch); // get the IDispatch interface for the control if (objIDispatch is null) return COM.E_FAIL; // create a DISPPARAMS structure for the input parameters - DISPPARAMS pDispParams = new DISPPARAMS(); + DISPPARAMS pDispParams; + // store arguments in rgvarg if (rgvarg !is null && rgvarg.length > 0) { - pDispParams.cArgs = rgvarg.length; - pDispParams.rgvarg = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, Variant.sizeof * rgvarg.length); - int offset = 0; - for (int i = rgvarg.length - 1; i >= 0 ; i--) { - rgvarg[i].getData(pDispParams.rgvarg + offset); - offset += Variant.sizeof; + VARIANT[] tempArgs = new VARIANT[rgvarg.length]; + for (int i = 0; i < rgvarg.length ; ++i) { + rgvarg[i].getData(&tempArgs[i]); } + // the reverse sequency + tempArgs.reverse; + pDispParams.cArgs = tempArgs.length; + pDispParams.rgvarg = tempArgs.ptr; } // if arguments have ids, store the ids in rgdispidNamedArgs if (rgdispidNamedArgs !is null && rgdispidNamedArgs.length > 0) { - pDispParams.cNamedArgs = rgdispidNamedArgs.length; - pDispParams.rgdispidNamedArgs = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4 * rgdispidNamedArgs.length); - int offset = 0; - for (int i = rgdispidNamedArgs.length; i > 0; i--) { - COM.MoveMemory(pDispParams.rgdispidNamedArgs + offset, new int[] {rgdispidNamedArgs[i-1]}, 4); - offset += 4; - } + DISPID[] tempArgs = rgdispidNamedArgs.dup; + // the reverse sequency + tempArgs.reverse; + pDispParams.cNamedArgs = tempArgs.length; + pDispParams.rgdispidNamedArgs = tempArgs.ptr; } // invoke the method - EXCEPINFO excepInfo = new EXCEPINFO(); - int[] pArgErr = new int[1]; - int pVarResultAddress = 0; - if (pVarResult !is null) pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof); - int result = objIDispatch.Invoke(dispIdMember, new GUID(), COM.LOCALE_USER_DEFAULT, wFlags, pDispParams, pVarResultAddress, excepInfo, pArgErr); + EXCEPINFO excepInfo; + uint pArgErr; + VARIANT* pVarResultAddress = null; + if (pVarResult !is null) + pVarResultAddress = new VARIANT(); - if (pVarResultAddress !is 0){ + GUID id; // IID_NULL + /* + HRESULT Invoke( + [in] DISPID dispIdMember, + [in] REFIID riid, + [in] LCID lcid, + [in] WORD wFlags, + [in, out] DISPPARAMS * pDispParams, + [out] VARIANT * pVarResult, + [out] EXCEPINFO * pExcepInfo, + [out] UINT * puArgErr + ); + */ + HRESULT result = objIDispatch.Invoke(dispIdMember, &id, COM.LOCALE_USER_DEFAULT, wFlags, &pDispParams, pVarResultAddress, &excepInfo, &pArgErr); + + if (pVarResultAddress !is null){ pVarResult.setData(pVarResultAddress); COM.VariantClear(pVarResultAddress); - OS.GlobalFree(pVarResultAddress); } // free the Dispparams resources - if (pDispParams.rgdispidNamedArgs !is 0){ - OS.GlobalFree(pDispParams.rgdispidNamedArgs); - } - if (pDispParams.rgvarg !is 0) { - int offset = 0; + if (pDispParams.rgvarg !is null) { for (int i = 0, length = rgvarg.length; i < length; i++){ - COM.VariantClear(pDispParams.rgvarg + offset); - offset += Variant.sizeof; + COM.VariantClear(&pDispParams.rgvarg[i]); } - OS.GlobalFree(pDispParams.rgvarg); + pDispParams.rgvarg = null; } + pDispParams.rgdispidNamedArgs = null; // save error string and cleanup EXCEPINFO - manageExcepinfo(result, excepInfo); + manageExcepinfo(result, &excepInfo); return result; } @@ -493,9 +522,9 @@ * </ul> */ public void invokeNoReply(int dispIdMember) { - int result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, null); + HRESULT result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, null); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result); + OLE.error(__FILE__, __LINE__, OLE.ERROR_ACTION_NOT_PERFORMED, result); } /** * Invokes a method on the OLE Object; the method has no optional parameters. In the early days of OLE, @@ -516,7 +545,7 @@ public void invokeNoReply(int dispIdMember, Variant[] rgvarg) { int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, null); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result); + OLE.error(__FILE__, __LINE__, OLE.ERROR_ACTION_NOT_PERFORMED, result); } /** * Invokes a method on the OLE Object; the method has optional parameters. It is not @@ -542,11 +571,11 @@ * </ul> */ public void invokeNoReply(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) { - int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, null); + HRESULT result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, null); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result); + OLE.error(__FILE__, __LINE__, OLE.ERROR_ACTION_NOT_PERFORMED, result); } -private void manageExcepinfo(int hResult, EXCEPINFO excepInfo) { +private void manageExcepinfo(int hResult, EXCEPINFO* excepInfo) { if (hResult is COM.S_OK){ exceptionDescription = "No Error"; //$NON-NLS-1$ @@ -555,29 +584,28 @@ // extract exception info if (hResult is COM.DISP_E_EXCEPTION) { - if (excepInfo.bstrDescription !is 0){ - int size = COM.SysStringByteLen(excepInfo.bstrDescription); - char[] buffer = new char[(size + 1) /2]; - COM.MoveMemory(buffer, excepInfo.bstrDescription, size); - exceptionDescription = new String(buffer); + if (excepInfo.bstrDescription !is null){ + exceptionDescription = WCHARzToStr(excepInfo.bstrDescription); } else { - exceptionDescription = "OLE Automation Error Exception "; //$NON-NLS-1$ - if (excepInfo.wCode !is 0){ - exceptionDescription += "code = "+excepInfo.wCode; //$NON-NLS-1$ - } else if (excepInfo.scode !is 0){ - exceptionDescription += "code = "+excepInfo.scode; //$NON-NLS-1$ + exceptionDescription = ("OLE Automation Error Exception "); //$NON-NLS-1$ + if (excepInfo.wCode != 0){ + exceptionDescription ~= "code = "; + exceptionDescription ~= cast(int)(excepInfo.wCode); //$NON-NLS-1$ + } else if (excepInfo.scode != 0){ + exceptionDescription ~= "code = "; + exceptionDescription ~= (excepInfo.scode); //$NON-NLS-1$ } } } else { - exceptionDescription = "OLE Automation Error HResult : " + hResult; //$NON-NLS-1$ + exceptionDescription = ("OLE Automation Error HResult : ") ~ toHex(hResult); //$NON-NLS-1$ } // cleanup EXCEPINFO struct - if (excepInfo.bstrDescription !is 0) + if (excepInfo.bstrDescription !is null) COM.SysFreeString(excepInfo.bstrDescription); - if (excepInfo.bstrHelpFile !is 0) + if (excepInfo.bstrHelpFile !is null) COM.SysFreeString(excepInfo.bstrHelpFile); - if (excepInfo.bstrSource !is 0) + if (excepInfo.bstrSource !is null) COM.SysFreeString(excepInfo.bstrSource); } /** @@ -590,14 +618,17 @@ * @return true if the operation was successful */ public bool setProperty(int dispIdMember, Variant rgvarg) { - Variant[] rgvarg2 = new Variant[] {rgvarg}; - int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT}; - int dwFlags = COM.DISPATCH_PROPERTYPUT; - if ((rgvarg.getType() & COM.VT_BYREF) is COM.VT_BYREF) + + Variant[] rgvarg2 = new Variant[1]; + rgvarg2[0] = rgvarg; + int[] rgdispidNamedArgs; + rgdispidNamedArgs ~= COM.DISPID_PROPERTYPUT; + ushort dwFlags = COM.DISPATCH_PROPERTYPUT; + if ((rgvarg.getType() & COM.VT_BYREF) == COM.VT_BYREF) dwFlags = COM.DISPATCH_PROPERTYPUTREF; Variant pVarResult = new Variant(); - int result = invoke(dispIdMember, dwFlags, rgvarg2, rgdispidNamedArgs, pVarResult); - return (result is COM.S_OK); + HRESULT result = invoke(dispIdMember, dwFlags, rgvarg2, rgdispidNamedArgs, pVarResult); + return (result == COM.S_OK); } /** * Sets the property specified by the dispIdMember to a new value. @@ -612,15 +643,16 @@ * @since 2.0 */ public bool setProperty(int dispIdMember, Variant[] rgvarg) { - int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT}; - int dwFlags = COM.DISPATCH_PROPERTYPUT; + int[] rgdispidNamedArgs; + rgdispidNamedArgs ~= COM.DISPID_PROPERTYPUT; + ushort dwFlags = COM.DISPATCH_PROPERTYPUT; for (int i = 0; i < rgvarg.length; i++) { - if ((rgvarg[i].getType() & COM.VT_BYREF) is COM.VT_BYREF) + if ((rgvarg[i].getType() & COM.VT_BYREF) == COM.VT_BYREF) dwFlags = COM.DISPATCH_PROPERTYPUTREF; } Variant pVarResult = new Variant(); - int result = invoke(dispIdMember, dwFlags, rgvarg, rgdispidNamedArgs, pVarResult); - return (result is COM.S_OK); + HRESULT result = invoke(dispIdMember, dwFlags, rgvarg, rgdispidNamedArgs, pVarResult); + return (result == COM.S_OK); } } -++/ +
--- a/dwt/ole/win32/OleClientSite.d Fri Feb 08 19:49:32 2008 +0100 +++ b/dwt/ole/win32/OleClientSite.d Sat Feb 09 03:36:27 2008 +0100 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> *******************************************************************************/ module dwt.ole.win32.OleClientSite; @@ -42,6 +44,13 @@ // import dwt.internal.ole.win32.OLECMD; // import dwt.internal.ole.win32.OLEINPLACEFRAMEINFO; import dwt.internal.win32.OS; +import dwt.internal.ole.win32.extras; +import dwt.internal.ole.win32.OAIDL; +import dwt.internal.ole.win32.OLEIDL; +import dwt.internal.ole.win32.OBJIDL; +import dwt.internal.ole.win32.DOCOBJ; +import dwt.internal.ole.win32.COM; +import dwt.internal.ole.win32.ifs; import dwt.widgets.Composite; import dwt.widgets.Event; @@ -49,10 +58,10 @@ import dwt.widgets.Menu; import dwt.widgets.Shell; -//PORTING_TYPE -class OleClientSite : Composite { -} -/++ +import dwt.ole.win32.OleFrame; +import dwt.ole.win32.Variant; +import dwt.ole.win32.OLE; + /** * OleClientSite provides a site to manage an embedded OLE Document within a container. @@ -81,26 +90,26 @@ public class OleClientSite : Composite { // Interfaces for this Ole Client Container - private COMObject iUnknown; - private COMObject iOleClientSite; - private COMObject iAdviseSink; - private COMObject iOleInPlaceSite; - private COMObject iOleDocumentSite; + private _IUnknownImpl iUnknown; + private _IOleClientSiteImpl iOleClientSite; + private _IAdviseSinkImpl iAdviseSink; + private _IOleInPlaceSiteImpl iOleInPlaceSite; + private _IOleDocumentSiteImpl iOleDocumentSite; - protected GUID appClsid; - private GUID objClsid; + protected GUID* appClsid; + private GUID* objClsid; private int refCount; // References to the associated Frame. - protected OleFrame frame; + package OleFrame frame; // Access to the embedded/linked Ole Object - protected IUnknown objIUnknown; - protected IOleObject objIOleObject; - protected IViewObject2 objIViewObject2; + protected IUnknown objIUnknown; + protected IOleObject objIOleObject; + protected IViewObject2 objIViewObject2; protected IOleInPlaceObject objIOleInPlaceObject; - protected IOleCommandTarget objIOleCommandTarget; - protected IOleDocumentView objDocumentView; + protected IOleCommandTarget objIOleCommandTarget; + protected IOleDocumentView objDocumentView; // Related storage information protected IStorage tempStorage; // IStorage interface of the receiver @@ -110,24 +119,26 @@ private int type; // Indicates the type of client that can be supported inside this container private bool isStatic; // Indicates item's display is static, i.e., a bitmap, metafile, etc. - private RECT borderWidths = new RECT(); - private RECT indent = new RECT(); + private RECT borderWidths; + private RECT indent; private bool inUpdate = false; private bool inInit = true; private bool inDispose = false; - private static final String WORDPROGID = "Word.Document"; //$NON-NLS-1$ + private static const char[] WORDPROGID = "Word.Document"; //$NON-NLS-1$ private Listener listener; - static final int STATE_NONE = 0; - static final int STATE_RUNNING = 1; - static final int STATE_INPLACEACTIVE = 2; - static final int STATE_UIACTIVE = 3; - static final int STATE_ACTIVE = 4; + enum{ + STATE_NONE = 0, + STATE_RUNNING = 1, + STATE_INPLACEACTIVE = 2, + STATE_UIACTIVE = 3, + STATE_ACTIVE = 4, + } int state = STATE_NONE; -protected OleClientSite(Composite parent, int style) { +protected this(Composite parent, int style) { /* * NOTE: this constructor should never be used by itself because it does * not create an Ole Object @@ -138,20 +149,20 @@ // install the Ole Frame for this Client Site while (parent !is null) { - if (parent instanceof OleFrame){ - frame = (OleFrame)parent; + if ( auto frame = cast(OleFrame)parent){ + frame = frame; break; } parent = parent.getParent(); } - if (frame is null) OLE.error(DWT.ERROR_INVALID_ARGUMENT); + if (frame is null) OLE.error (__FILE__, __LINE__, DWT.ERROR_INVALID_ARGUMENT); frame.AddRef(); aspect = COM.DVASPECT_CONTENT; type = COM.OLEEMBEDDED; isStatic = false; - listener = new Listener() { + listener = new class() Listener { public void handleEvent(Event e) { switch (e.type) { case DWT.Resize : @@ -163,7 +174,7 @@ case DWT.Traverse: onTraverse(e); break; case DWT.KeyDown: /* required for traversal */ break; default : - OLE.error(DWT.ERROR_NOT_IMPLEMENTED); + OLE.error (__FILE__, __LINE__, DWT.ERROR_NOT_IMPLEMENTED); } } }; @@ -198,38 +209,35 @@ * <li>ERROR_INVALID_CLASSID * </ul> */ -public OleClientSite(Composite parent, int style, File file) { +public this(Composite parent, int style, File file) { this(parent, style); try { if (file is null || file.isDirectory() || !file.exists()) - OLE.error(OLE.ERROR_INVALID_ARGUMENT); + OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_ARGUMENT); // Is there an associated CLSID? appClsid = new GUID(); - char[] fileName = (file.getAbsolutePath()+"\0").toCharArray(); + TCHAR* fileName = StrToTCHARz( 0, file.getAbsolutePath() ); int result = COM.GetClassFile(fileName, appClsid); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_INVALID_CLASSID, result); + OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_CLASSID, result); // associated CLSID may not be installed on this machine if (getProgramID() is null) - OLE.error(OLE.ERROR_INVALID_CLASSID, result); + OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_CLASSID, result); // Open a temporary storage object tempStorage = createTempStorage(); // Create ole object with storage object - int[] address = new int[1]; - result = COM.OleCreateFromFile(appClsid, fileName, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address); + result = COM.OleCreateFromFile(appClsid, fileName, &COM.IIDIUnknown, COM.OLERENDER_DRAW, null, null, tempStorage, cast(void**)&objIUnknown); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); - - objIUnknown = new IUnknown(address[0]); + OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_CREATE_OBJECT, result); // Init sinks addObjectReferences(); - if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state = STATE_RUNNING; + if (COM.OleRun(objIUnknown) is OLE.S_OK) state = STATE_RUNNING; } catch (DWTException e) { dispose(); disposeCOMInterfaces(); @@ -258,28 +266,25 @@ * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object * </ul> */ -public OleClientSite(Composite parent, int style, String progId) { +public this(Composite parent, int style, char[] progId) { this(parent, style); try { appClsid = getClassID(progId); if (appClsid is null) - OLE.error(OLE.ERROR_INVALID_CLASSID); + OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_CLASSID); // Open a temporary storage object tempStorage = createTempStorage(); // Create ole object with storage object - int[] address = new int[1]; - int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address); + HRESULT result = COM.OleCreate(appClsid, &COM.IIDIUnknown, COM.OLERENDER_DRAW, null, null, tempStorage, cast(void**)&objIUnknown); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); - - objIUnknown = new IUnknown(address[0]); + OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_CREATE_OBJECT, result); // Init sinks addObjectReferences(); - if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state = STATE_RUNNING; + if (COM.OleRun(objIUnknown) is OLE.S_OK) state = STATE_RUNNING; } catch (DWTException e) { dispose(); @@ -315,55 +320,48 @@ * <li>ERROR_CANNOT_OPEN_FILE when failed to open file * </ul> */ -public OleClientSite(Composite parent, int style, String progId, File file) { +public this(Composite parent, int style, char[] progId, File file) { this(parent, style); try { - if (file is null || file.isDirectory() || !file.exists()) OLE.error(OLE.ERROR_INVALID_ARGUMENT); + if (file is null || file.isDirectory() || !file.exists()) OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_ARGUMENT); appClsid = getClassID(progId); - if (appClsid is null) OLE.error(OLE.ERROR_INVALID_CLASSID); + if (appClsid is null) OLE.error (__FILE__, __LINE__, OLE.ERROR_INVALID_CLASSID); // Are we opening this file with the preferred OLE object? - char[] fileName = (file.getAbsolutePath()+"\0").toCharArray(); - GUID fileClsid = new GUID(); + wchar* fileName = StrToWCHARz(file.getAbsolutePath()); + GUID* fileClsid = new GUID(); COM.GetClassFile(fileName, fileClsid); if (COM.IsEqualGUID(appClsid, fileClsid)){ // Using the same application that created file, therefore, use default mechanism. tempStorage = createTempStorage(); // Create ole object with storage object - int[] address = new int[1]; - int result = COM.OleCreateFromFile(appClsid, fileName, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address); - if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); - objIUnknown = new IUnknown(address[0]); + HRESULT result = COM.OleCreateFromFile(appClsid, fileName, &COM.IIDIUnknown, COM.OLERENDER_DRAW, null, null, tempStorage, cast(void**)&objIUnknown); + if (result !is COM.S_OK) OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_CREATE_OBJECT, result); } else { // Not using the same application that created file, therefore, copy from original file to a new storage file IStorage storage = null; if (COM.StgIsStorageFile(fileName) is COM.S_OK) { - int[] address = new int[1]; int mode = COM.STGM_READ | COM.STGM_TRANSACTED | COM.STGM_SHARE_EXCLUSIVE; - int result = COM.StgOpenStorage(fileName, 0, mode, 0, 0, address); //Does an AddRef if successful - if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); - storage = new IStorage(address[0]); + HRESULT result = COM.StgOpenStorage(fileName, null, mode, null, 0, &storage); //Does an AddRef if successful + if (result !is COM.S_OK) OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_OPEN_FILE, result); } else { // Original file is not a Storage file so copy contents to a stream in a new storage file - int[] address = new int[1]; int mode = COM.STGM_READWRITE | COM.STGM_DIRECT | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_CREATE; - int result = COM.StgCreateDocfile(null, mode | COM.STGM_DELETEONRELEASE, 0, address); // Increments ref count if successful - if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); - storage = new IStorage(address[0]); + HRESULT result = COM.StgCreateDocfile(null, mode | COM.STGM_DELETEONRELEASE, 0, &storage); // Increments ref count if successful + if (result !is COM.S_OK) OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_OPEN_FILE, result); // Create a stream on the storage object. // Word does not follow the standard and does not use "CONTENTS" as the name of // its primary stream - String streamName = "CONTENTS"; //$NON-NLS-1$ - GUID wordGUID = getClassID(WORDPROGID); + wchar* streamName = StrToWCHARz("CONTENTS"); //$NON-NLS-1$ + GUID* wordGUID = getClassID(WORDPROGID); if (wordGUID !is null && COM.IsEqualGUID(appClsid, wordGUID)) streamName = "WordDocument"; //$NON-NLS-1$ - address = new int[1]; - result = storage.CreateStream(streamName, mode, 0, 0, address); // Increments ref count if successful + IStream stream; + result = storage.CreateStream(streamName, mode, 0, 0, &stream); // Increments ref count if successful if (result !is COM.S_OK) { storage.Release(); - OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); + OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_OPEN_FILE, result); } - IStream stream = new IStream(address[0]); try { // Copy over data in file to named stream FileInputStream fileInput = new FileInputStream(file); @@ -371,15 +369,15 @@ byte[] buffer = new byte[increment]; int count = 0; while((count = fileInput.read(buffer)) > 0){ - int pv = COM.CoTaskMemAlloc(count); - OS.MoveMemory(pv, buffer, count); + auto pv = COM.CoTaskMemAlloc(count); + OS.MoveMemory(pv, buffer.ptr, count); result = stream.Write(pv, count, null) ; COM.CoTaskMemFree(pv); if (result !is COM.S_OK) { fileInput.close(); stream.Release(); storage.Release(); - OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); + OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_OPEN_FILE, result); } } fileInput.close(); @@ -388,37 +386,34 @@ } catch (IOException err) { stream.Release(); storage.Release(); - OLE.error(OLE.ERROR_CANNOT_OPEN_FILE); + OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_OPEN_FILE); } } // Open a temporary storage object tempStorage = createTempStorage(); // Copy over contents of file - int result = storage.CopyTo(0, null, null, tempStorage.getAddress()); + HRESULT result = storage.CopyTo(0, null, null, tempStorage); storage.Release(); - if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); + if (result !is COM.S_OK) OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_OPEN_FILE, result); // create ole client - int[] ppv = new int[1]; - result = COM.CoCreateInstance(appClsid, 0, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, COM.IIDIUnknown, ppv); - if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); - objIUnknown = new IUnknown(ppv[0]); + result = COM.CoCreateInstance(appClsid, null, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, &COM.IIDIUnknown, cast(void**)&objIUnknown); + if (result !is COM.S_OK) OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_CREATE_OBJECT, result); // get the persistent storage of the ole client - ppv = new int[1]; - result = objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv); - if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); - IPersistStorage iPersistStorage = new IPersistStorage(ppv[0]); + IPersistStorage iPersistStorage; + result = objIUnknown.QueryInterface(&COM.IIDIPersistStorage, cast(void**)&iPersistStorage); + if (result !is COM.S_OK) OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_CREATE_OBJECT, result); // load the contents of the file into the ole client site - result = iPersistStorage.Load(tempStorage.getAddress()); + result = iPersistStorage.Load(tempStorage); iPersistStorage.Release(); - if (result !is COM.S_OK)OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); + if (result !is COM.S_OK)OLE.error (__FILE__, __LINE__, OLE.ERROR_CANNOT_CREATE_OBJECT, result); } // Init sinks addObjectReferences(); - if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state = STATE_RUNNING; + if (COM.OleRun(objIUnknown) is OLE.S_OK) state = STATE_RUNNING; } catch (DWTException e) { dispose(); @@ -428,44 +423,37 @@ } protected void addObjectReferences() { // - int[] ppvObject = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIPersist, ppvObject) is COM.S_OK) { - IPersist objIPersist = new IPersist(ppvObject[0]); - GUID tempid = new GUID(); + IPersist objIPersist; + if (objIUnknown.QueryInterface(&COM.IIDIPersist, cast(void**)&objIPersist) is COM.S_OK) { + GUID* tempid = new GUID(); if (objIPersist.GetClassID(tempid) is COM.S_OK) objClsid = tempid; objIPersist.Release(); } // - ppvObject = new int[1]; - int result = objIUnknown.QueryInterface(COM.IIDIViewObject2, ppvObject); + HRESULT result = objIUnknown.QueryInterface(&COM.IIDIViewObject2, cast(void**)&objIViewObject2); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND, result); - objIViewObject2 = new IViewObject2(ppvObject[0]); - objIViewObject2.SetAdvise(aspect, 0, iAdviseSink.getAddress()); + OLE.error (__FILE__, __LINE__, OLE.ERROR_INTERFACE_NOT_FOUND, result); + objIViewObject2.SetAdvise(aspect, 0, iAdviseSink); // - ppvObject = new int[1]; - result = objIUnknown.QueryInterface(COM.IIDIOleObject, ppvObject); + result = objIUnknown.QueryInterface(&COM.IIDIOleObject, cast(void**)&objIOleObject); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND, result); - objIOleObject = new IOleObject(ppvObject[0]); - objIOleObject.SetClientSite(iOleClientSite.getAddress()); - int[] pdwConnection = new int[1]; - objIOleObject.Advise(iAdviseSink.getAddress(), pdwConnection); + OLE.error (__FILE__, __LINE__, OLE.ERROR_INTERFACE_NOT_FOUND, result); + objIOleObject.SetClientSite(iOleClientSite); + uint pdwConnection; + objIOleObject.Advise(iAdviseSink, &pdwConnection); objIOleObject.SetHostNames("main", "main"); //$NON-NLS-1$ //$NON-NLS-2$ // Notify the control object that it is embedded in an OLE container - COM.OleSetContainedObject(objIUnknown.getAddress(), true); + COM.OleSetContainedObject(objIUnknown, true); // Is OLE object linked or embedded? - ppvObject = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIOleLink, ppvObject) is COM.S_OK) { - IOleLink objIOleLink = new IOleLink(ppvObject[0]); - int[] ppmk = new int[1]; - if (objIOleLink.GetSourceMoniker(ppmk) is COM.S_OK) { - IMoniker objIMoniker = new IMoniker(ppmk[0]); + IOleLink objIOleLink; + if (objIUnknown.QueryInterface(&COM.IIDIOleLink, cast(void**)&objIOleLink) is COM.S_OK) { + IMoniker objIMoniker; + if (objIOleLink.GetSourceMoniker(&objIMoniker) is COM.S_OK) { objIMoniker.Release(); type = COM.OLELINKED; objIOleLink.BindIfRunning(); @@ -489,67 +477,18 @@ return COM.S_OK; } protected void createCOMInterfaces() { - - iUnknown = new COMObject(new int[]{2, 0, 0}){ - public int method0(int[] args) {return QueryInterface(args[0], args[1]);} - public int method1(int[] args) {return AddRef();} - public int method2(int[] args) {return Release();} - }; - - iOleClientSite = new COMObject(new int[]{2, 0, 0, 0, 3, 1, 0, 1, 0}){ - public int method0(int[] args) {return QueryInterface(args[0], args[1]);} - public int method1(int[] args) {return AddRef();} - public int method2(int[] args) {return Release();} - public int method3(int[] args) {return SaveObject();} - // method4 GetMoniker - not implemented - public int method5(int[] args) {return GetContainer(args[0]);} - public int method6(int[] args) {return ShowObject();} - public int method7(int[] args) {return OnShowWindow(args[0]);} - // method8 RequestNewObjectLayout - not implemented - }; - - iAdviseSink = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 0, 0}){ - public int method0(int[] args) {return QueryInterface(args[0], args[1]);} - public int method1(int[] args) {return AddRef();} - public int method2(int[] args) {return Release();} - public int method3(int[] args) {return OnDataChange(args[0], args[1]);} - public int method4(int[] args) {return OnViewChange(args[0], args[1]);} - //method5 OnRename - not implemented - public int method6(int[] args) {OnSave();return 0;} - public int method7(int[] args) {return OnClose();} - }; - - iOleInPlaceSite = new COMObject(new int[]{2, 0, 0, 1, 1, 0, 0, 0, 5, 1, 1, 0, 0, 0, 1}){ - public int method0(int[] args) {return QueryInterface(args[0], args[1]);} - public int method1(int[] args) {return AddRef();} - public int method2(int[] args) {return Release();} - public int method3(int[] args) {return GetWindow(args[0]);} - public int method4(int[] args) {return ContextSensitiveHelp(args[0]);} - public int method5(int[] args) {return CanInPlaceActivate();} - public int method6(int[] args) {return OnInPlaceActivate();} - public int method7(int[] args) {return OnUIActivate();} - public int method8(int[] args) {return GetWindowContext(args[0], args[1], args[2], args[3], args[4]);} - public int method9(int[] args) {return Scroll(args[0]);} - public int method10(int[] args) {return OnUIDeactivate(args[0]);} - public int method11(int[] args) {return OnInPlaceDeactivate();} - // method12 DiscardUndoState - not implemented - // method13 DeactivateAndUndoChange - not implemented - public int method14(int[] args) {return OnPosRectChange(args[0]);} - }; - - iOleDocumentSite = new COMObject(new int[]{2, 0, 0, 1}){ - public int method0(int[] args) {return QueryInterface(args[0], args[1]);} - public int method1(int[] args) {return AddRef();} - public int method2(int[] args) {return Release();} - public int method3(int[] args) {return ActivateMe(args[0]);} - }; + iUnknown = new _IUnknownImpl(this); + iOleClientSite = new _IOleClientSiteImpl(this); + iAdviseSink = new _IAdviseSinkImpl(this); + iOleInPlaceSite = new _IOleInPlaceSiteImpl(this); + iOleDocumentSite = new _IOleDocumentSiteImpl(this); } protected IStorage createTempStorage() { - int[] tempStorage = new int[1]; + IStorage tmpStorage; int grfMode = COM.STGM_READWRITE | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_DELETEONRELEASE; - int result = COM.StgCreateDocfile(null, grfMode, 0, tempStorage); - if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_FILE, result); - return new IStorage(tempStorage[0]); + HRESULT result = COM.StgCreateDocfile(null, grfMode, 0, &tmpStorage); + if (result !is COM.S_OK) OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_CREATE_FILE, result); + return (tmpStorage); } /** * Deactivates an active in-place object and discards the object's undo state. @@ -567,24 +506,10 @@ tempStorage = null; } protected void disposeCOMInterfaces() { - if (iUnknown !is null) - iUnknown.dispose(); iUnknown = null; - - if (iOleClientSite !is null) - iOleClientSite.dispose(); iOleClientSite = null; - - if (iAdviseSink !is null) - iAdviseSink.dispose(); iAdviseSink = null; - - if (iOleInPlaceSite !is null) - iOleInPlaceSite.dispose(); iOleInPlaceSite = null; - - if (iOleDocumentSite !is null) - iOleDocumentSite.dispose(); iOleDocumentSite = null; } /** @@ -600,15 +525,15 @@ // Not all OLE clients (for example PowerPoint) can be set into the running state in the constructor. // The fix is to ensure that the client is in the running state before invoking any verb on it. if (state is STATE_NONE) { - if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state = STATE_RUNNING; + if (COM.OleRun(objIUnknown) is OLE.S_OK) state = STATE_RUNNING; } if (state is STATE_NONE || isStatic) return COM.E_FAIL; // See PR: 1FV9RZW - RECT rect = new RECT(); - OS.GetClientRect(handle, rect); - int result = objIOleObject.DoVerb(verb, null, iOleClientSite.getAddress(), 0, handle, rect); + RECT rect; + OS.GetClientRect(handle, &rect); + int result = objIOleObject.DoVerb(verb, null, iOleClientSite, 0, handle, &rect); if (state !is STATE_RUNNING && inInit) { updateStorage(); @@ -632,77 +557,75 @@ * @return an HRESULT value; OLE.S_OK is returned if successful * */ -public int exec(int cmdID, int options, Variant in, Variant out) { +public int exec(int cmdID, int options, Variant pvaIn, Variant pvaOut) { if (objIOleCommandTarget is null) { - int[] address = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIOleCommandTarget, address) !is COM.S_OK) + if (objIUnknown.QueryInterface(&COM.IIDIOleCommandTarget, cast(void**)&objIOleCommandTarget) !is COM.S_OK) return OLE.ERROR_INTERFACE_NOT_FOUND; - objIOleCommandTarget = new IOleCommandTarget(address[0]); } - int inAddress = 0; - if (in !is null){ - inAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof); - in.getData(inAddress); + VARIANT* pIn = null; + VARIANT* pOut = null; + + if(pvaIn){ + pIn = new VARIANT(); + pvaIn.getData(pIn); } - int outAddress = 0; - if (out !is null){ - outAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof); - out.getData(outAddress); + if(pvaOut){ + pOut = new VARIANT(); + pvaOut.getData(pOut); } - int result = objIOleCommandTarget.Exec(null, cmdID, options, inAddress, outAddress); + HRESULT result = objIOleCommandTarget.Exec(null, cmdID, options, pIn, pOut); - if (inAddress !is 0){ - COM.VariantClear(inAddress); - OS.GlobalFree(inAddress); + if(pIn) { + COM.VariantClear(pIn); } - if (outAddress !is 0) { - out.setData(outAddress); - COM.VariantClear(outAddress); - OS.GlobalFree(outAddress); + + if(pOut) { + pvaOut.setData(pOut); + COM.VariantClear(pOut); } return result; } IDispatch getAutomationObject() { - int[] ppvObject = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIDispatch, ppvObject) !is COM.S_OK) + IDispatch ppvObject; + if (objIUnknown.QueryInterface(&COM.IIDIDispatch, cast(void**)&ppvObject) !is COM.S_OK) return null; - return new IDispatch(ppvObject[0]); + return ppvObject; } -protected GUID getClassID(String clientName) { +protected GUID* getClassID(char[] clientName) { // create a GUID struct to hold the result - GUID guid = new GUID(); + GUID* guid = new GUID(); // create a null terminated array of char - char[] buffer = null; + wchar* buffer = null; if (clientName !is null) { - int count = clientName.length(); - buffer = new char[count + 1]; - clientName.getChars(0, count, buffer, 0); + buffer = StrToWCHARz(clientName);; } if (COM.CLSIDFromProgID(buffer, guid) !is COM.S_OK){ - int result = COM.CLSIDFromString(buffer, guid); + HRESULT result = COM.CLSIDFromString(buffer, guid); if (result !is COM.S_OK) return null; } return guid; } -private int GetContainer(int ppContainer) { + +private HRESULT GetContainer(IOleContainer* ppContainer) { /* Simple containers that do not support links to their embedded * objects probably do not need to implement this method. Instead, * they can return E_NOINTERFACE and set ppContainer to NULL. */ - if (ppContainer !is 0) - COM.MoveMemory(ppContainer, new int[]{0}, 4); + if (ppContainer !is null) + *ppContainer = null; return COM.E_NOINTERFACE; } -private SIZE getExtent() { - SIZE sizel = new SIZE(); + +private SIZE* getExtent() { + SIZE* sizel = new SIZE(); // get the current size of the embedded OLENatives object if (objIOleObject !is null) { - if ( objIViewObject2 !is null && !COM.OleIsRunning(objIOleObject.getAddress())) { + if ( objIViewObject2 !is null && !COM.OleIsRunning(objIOleObject)) { objIViewObject2.GetExtent(aspect, -1, null, sizel); } else { objIOleObject.GetExtent(aspect, sizel); @@ -718,97 +641,96 @@ * * @return the program ID of the OLE Document or ActiveX Control */ -public String getProgramID(){ +public char[] getProgramID(){ if (appClsid !is null){ - int[] lplpszProgID = new int[1]; - if (COM.ProgIDFromCLSID(appClsid, lplpszProgID) is COM.S_OK) { - int hMem = lplpszProgID[0]; + wchar* hMem; + if (COM.ProgIDFromCLSID(appClsid, &hMem) is COM.S_OK) { int length = OS.GlobalSize(hMem); - int ptr = OS.GlobalLock(hMem); - char[] buffer = new char[length]; - COM.MoveMemory(buffer, ptr, length); + auto ptr = OS.GlobalLock(hMem); + wchar[] buffer = new wchar[length]; + COM.MoveMemory(buffer.ptr, ptr, length); OS.GlobalUnlock(hMem); OS.GlobalFree(hMem); - String result = new String(buffer); + char[] result = WCHARzToStr(buffer.ptr); // remove null terminator - int index = result.indexOf("\0"); - return result.substring(0, index); + //int index = result.indexOf("\0"); + return result;//.substring(0, index); } } return null; } -int ActivateMe(int pViewToActivate) { - if (pViewToActivate is 0) { - int[] ppvObject = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIOleDocument, ppvObject) !is COM.S_OK) return COM.E_FAIL; - IOleDocument objOleDocument = new IOleDocument(ppvObject[0]); - if (objOleDocument.CreateView(iOleInPlaceSite.getAddress(), 0, 0, ppvObject) !is COM.S_OK) return COM.E_FAIL; +int ActivateMe(IOleDocumentView pViewToActivate) { + if (pViewToActivate is null) { + void* ppvObject; + if (objIUnknown.QueryInterface(&COM.IIDIOleDocument, &ppvObject) !is COM.S_OK) return COM.E_FAIL; + IOleDocument objOleDocument = cast(IOleDocument)ppvObject; + if (objOleDocument.CreateView(iOleInPlaceSite, null, 0, &objDocumentView) !is COM.S_OK) return COM.E_FAIL; objOleDocument.Release(); - objDocumentView = new IOleDocumentView(ppvObject[0]); } else { - objDocumentView = new IOleDocumentView(pViewToActivate); + objDocumentView = pViewToActivate; objDocumentView.AddRef(); - objDocumentView.SetInPlaceSite(iOleInPlaceSite.getAddress()); + objDocumentView.SetInPlaceSite(iOleInPlaceSite); } objDocumentView.UIActivate(1);//TRUE - RECT rect = getRect(); + RECT* rect = getRect(); objDocumentView.SetRect(rect); objDocumentView.Show(1);//TRUE return COM.S_OK; } -protected int GetWindow(int phwnd) { - if (phwnd is 0) +protected int GetWindow(HWND* phwnd) { + if (phwnd is null) return COM.E_INVALIDARG; if (frame is null) { - COM.MoveMemory(phwnd, new int[] {0}, 4); + *phwnd = null; return COM.E_NOTIMPL; } // Copy the Window's handle into the memory passed in - COM.MoveMemory(phwnd, new int[] {frame.handle}, 4); + *phwnd = frame.handle; return COM.S_OK; } -RECT getRect() { +RECT* getRect() { Point location = this.getLocation(); Rectangle area = frame.getClientArea(); - RECT rect = new RECT(); + RECT* rect = new RECT(); rect.left = location.x; rect.top = location.y; rect.right = location.x + area.width - borderWidths.left - borderWidths.right; rect.bottom = location.y + area.height - borderWidths.top - borderWidths.bottom; return rect; } -private int GetWindowContext(int ppFrame, int ppDoc, int lprcPosRect, int lprcClipRect, int lpFrameInfo) { - if (frame is null || ppFrame is 0) + +private int GetWindowContext(IOleInPlaceFrame* ppFrame, IOleInPlaceUIWindow* ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) { + if (frame is null || ppFrame is null) return COM.E_NOTIMPL; // fill in frame handle - int iOleInPlaceFrame = frame.getIOleInPlaceFrame(); - COM.MoveMemory(ppFrame, new int[] {iOleInPlaceFrame}, 4); + auto iOleInPlaceFrame = frame.getIOleInPlaceFrame(); + *ppFrame = iOleInPlaceFrame; frame.AddRef(); // null out document handle - if (ppDoc !is 0) COM.MoveMemory(ppDoc, new int[] {0}, 4); + if (ppDoc !is null) *ppDoc = null; // fill in position and clipping info - RECT rect = getRect(); - if (lprcPosRect !is 0) OS.MoveMemory(lprcPosRect, rect, RECT.sizeof); - if (lprcClipRect !is 0) OS.MoveMemory(lprcClipRect, rect, RECT.sizeof); + RECT* rect = getRect(); + if (lprcPosRect !is null) OS.MoveMemory(lprcPosRect, rect, RECT.sizeof); + if (lprcClipRect !is null) OS.MoveMemory(lprcClipRect, rect, RECT.sizeof); // get frame info - OLEINPLACEFRAMEINFO frameInfo = new OLEINPLACEFRAMEINFO(); + OLEINPLACEFRAMEINFO* frameInfo = new OLEINPLACEFRAMEINFO(); frameInfo.cb = OLEINPLACEFRAMEINFO.sizeof; frameInfo.fMDIApp = 0; frameInfo.hwndFrame = frame.handle; Shell shell = getShell(); Menu menubar = shell.getMenuBar(); if (menubar !is null && !menubar.isDisposed()) { - int hwnd = shell.handle; - int cAccel = OS.SendMessage(hwnd, OS.WM_APP, 0, 0); + auto hwnd = shell.handle; + auto cAccel = OS.SendMessage(hwnd, OS.WM_APP, 0, 0); if (cAccel !is 0) { - int hAccel = OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0); - if (hAccel !is 0) { + auto hAccel = cast(HACCEL) OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0); + if (hAccel !is null) { frameInfo.cAccelEntries = cAccel; frameInfo.haccel = hAccel; } @@ -826,24 +748,23 @@ */ // Get access to the persistent storage mechanism - int[] address = new int[1]; - if (objIOleObject.QueryInterface(COM.IIDIPersistFile, address) !is COM.S_OK) + IPersistStorage permStorage; + if (objIOleObject.QueryInterface(&COM.IIDIPersistFile, cast(void**)&permStorage) !is COM.S_OK) return true; - IPersistStorage permStorage = new IPersistStorage(address[0]); // Are the contents of the permanent storage different from the file? - int result = permStorage.IsDirty(); + auto result = permStorage.IsDirty(); permStorage.Release(); if (result is COM.S_FALSE) return false; return true; } public bool isFocusControl () { checkWidget (); - int focusHwnd = OS.GetFocus(); + auto focusHwnd = OS.GetFocus(); if (objIOleInPlaceObject is null) return (handle is focusHwnd); - int[] phwnd = new int[1]; - objIOleInPlaceObject.GetWindow(phwnd); - while (focusHwnd !is 0) { - if (phwnd[0] is focusHwnd) return true; + HWND phwnd; + objIOleInPlaceObject.GetWindow(&phwnd); + while (focusHwnd !is null) { + if (phwnd is focusHwnd) return true; focusHwnd = OS.GetParent(focusHwnd); } return false; @@ -879,10 +800,10 @@ if (state !is STATE_UIACTIVE) doVerb(OLE.OLEIVERB_SHOW); if (objIOleInPlaceObject is null) return; if (isFocusControl()) return; - int[] phwnd = new int[1]; - objIOleInPlaceObject.GetWindow(phwnd); - if (phwnd[0] is 0) return; - OS.SetFocus(phwnd[0]); + HWND phwnd; + objIOleInPlaceObject.GetWindow(&phwnd); + if (phwnd is null) return; + OS.SetFocus(phwnd); } void onFocusOut(Event e) { } @@ -892,8 +813,8 @@ if (objIOleObject is null) return COM.S_OK; int[] ppvObject = new int[1]; - if (objIOleObject.QueryInterface(COM.IIDIOleInPlaceObject, ppvObject) is COM.S_OK) { - objIOleInPlaceObject = new IOleInPlaceObject(ppvObject[0]); + if (objIOleObject.QueryInterface(&COM.IIDIOleInPlaceObject, cast(void**)&objIOleInPlaceObject) is COM.S_OK) { + //objIOleInPlaceObject = new IOleInPlaceObject(ppvObject[0]); } return COM.S_OK; } @@ -908,16 +829,16 @@ } return COM.S_OK; } -private int OnPosRectChange(int lprcPosRect) { +private int OnPosRectChange(LPRECT lprcPosRect) { Point size = getSize(); setExtent(size.x, size.y); return COM.S_OK; } private void onPaint(Event e) { if (state is STATE_RUNNING || state is STATE_INPLACEACTIVE) { - SIZE size = getExtent(); + SIZE* size = getExtent(); Rectangle area = getClientArea(); - RECT rect = new RECT(); + RECT* rect = new RECT(); if (getProgramID().startsWith("Excel.Sheet")) { //$NON-NLS-1$ rect.left = area.x; rect.right = area.x + (area.height * size.cx / size.cy); rect.top = area.y; rect.bottom = area.y + area.height; @@ -926,9 +847,9 @@ rect.top = area.y; rect.bottom = area.y + size.cy; } - int pArea = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, RECT.sizeof); + auto pArea = cast(RECT*)OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, RECT.sizeof); OS.MoveMemory(pArea, rect, RECT.sizeof); - COM.OleDraw(objIUnknown.getAddress(), aspect, e.gc.handle, pArea); + COM.OleDraw(objIUnknown, aspect, e.gc.handle, pArea); OS.GlobalFree(pArea); } } @@ -949,9 +870,9 @@ private int OnUIActivate() { if (objIOleInPlaceObject is null) return COM.E_FAIL; state = STATE_UIACTIVE; - int[] phwnd = new int[1]; - if (objIOleInPlaceObject.GetWindow(phwnd) is COM.S_OK) { - OS.SetWindowPos(phwnd[0], OS.HWND_TOP, 0, 0, 0, 0, OS.SWP_NOSIZE | OS.SWP_NOMOVE); + HWND phwnd; + if (objIOleInPlaceObject.GetWindow(&phwnd) is COM.S_OK) { + OS.SetWindowPos(phwnd, cast(HWND)OS.HWND_TOP, 0, 0, 0, 0, OS.SWP_NOSIZE | OS.SWP_NOMOVE); } return COM.S_OK; } @@ -959,7 +880,7 @@ // currently, we are ignoring the fUndoable flag if (frame is null || frame.isDisposed()) return COM.S_OK; state = STATE_INPLACEACTIVE; - frame.SetActiveObject(0,0); + frame.SetActiveObject(null, null); redraw(); Shell shell = getShell(); if (isFocusControl() || frame.isFocusControl()) { @@ -969,9 +890,9 @@ if (menubar is null || menubar.isDisposed()) return COM.S_OK; - int shellHandle = shell.handle; + auto shellHandle = shell.handle; OS.SetMenu(shellHandle, menubar.handle); - return COM.OleSetMenuDescriptor(0, shellHandle, 0, 0, 0); + return COM.OleSetMenuDescriptor(null, shellHandle, null, null, null); } private void onTraverse(Event event) { switch (event.detail) { @@ -989,42 +910,42 @@ private int OnViewChange(int dwAspect, int lindex) { return COM.S_OK; } -protected int QueryInterface(int riid, int ppvObject) { +protected int QueryInterface(REFIID riid, void ** ppvObject) { - if (riid is 0 || ppvObject is 0) + if (riid is null || ppvObject is null) return COM.E_NOINTERFACE; - GUID guid = new GUID(); + GUID* guid = new GUID(); COM.MoveMemory(guid, riid, GUID.sizeof); - if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) { - COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4); + if (COM.IsEqualGUID(guid, &COM.IIDIUnknown)) { + *ppvObject = cast(void*)cast(IUnknown)iUnknown; AddRef(); return COM.S_OK; } - if (COM.IsEqualGUID(guid, COM.IIDIAdviseSink)) { - COM.MoveMemory(ppvObject, new int[] {iAdviseSink.getAddress()}, 4); + if (COM.IsEqualGUID(guid, &COM.IIDIAdviseSink)) { + *ppvObject = cast(void*)cast(IAdviseSink)iAdviseSink; AddRef(); return COM.S_OK; } - if (COM.IsEqualGUID(guid, COM.IIDIOleClientSite)) { - COM.MoveMemory(ppvObject, new int[] {iOleClientSite.getAddress()}, 4); + if (COM.IsEqualGUID(guid, &COM.IIDIOleClientSite)) { + *ppvObject = cast(void*)cast(IOleClientSite)iOleClientSite; AddRef(); return COM.S_OK; } - if (COM.IsEqualGUID(guid, COM.IIDIOleInPlaceSite)) { - COM.MoveMemory(ppvObject, new int[] {iOleInPlaceSite.getAddress()}, 4); + if (COM.IsEqualGUID(guid, &COM.IIDIOleInPlaceSite)) { + *ppvObject = cast(void*)cast(IOleInPlaceSite)iOleInPlaceSite; AddRef(); return COM.S_OK; } - if (COM.IsEqualGUID(guid, COM.IIDIOleDocumentSite )) { - String progID = getProgramID(); + if (COM.IsEqualGUID(guid, &COM.IIDIOleDocumentSite )) { + char[] progID = getProgramID(); if (!progID.startsWith("PowerPoint")) { //$NON-NLS-1$ - COM.MoveMemory(ppvObject, new int[] {iOleDocumentSite.getAddress()}, 4); + *ppvObject = cast(void*)cast(IOleDocumentSite)iOleDocumentSite; AddRef(); return COM.S_OK; } } - COM.MoveMemory(ppvObject, new int[] {0}, 4); + *ppvObject = null; return COM.E_NOINTERFACE; } /** @@ -1042,16 +963,14 @@ public int queryStatus(int cmd) { if (objIOleCommandTarget is null) { - int[] address = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIOleCommandTarget, address) !is COM.S_OK) + if (objIUnknown.QueryInterface(&COM.IIDIOleCommandTarget, cast(void**)&objIOleCommandTarget) !is COM.S_OK) return 0; - objIOleCommandTarget = new IOleCommandTarget(address[0]); } - OLECMD olecmd = new OLECMD(); + OLECMD* olecmd = new OLECMD(); olecmd.cmdID = cmd; - int result = objIOleCommandTarget.QueryStatus(null, 1, olecmd, null); + auto result = objIOleCommandTarget.QueryStatus(null, 1, olecmd, null); if (result !is COM.S_OK) return 0; @@ -1083,7 +1002,7 @@ objDocumentView = null; if (objIViewObject2 !is null) { - objIViewObject2.SetAdvise(aspect, 0, 0); + objIViewObject2.SetAdvise(aspect, 0, null); objIViewObject2.Release(); } objIViewObject2 = null; @@ -1104,22 +1023,22 @@ return saveToStorageFile(file); return saveToTraditionalFile(file); } -private bool saveFromContents(int address, File file) { +private bool saveFromContents(IStream address, File file) { bool success = false; - IStream tempContents = new IStream(address); + IStream tempContents = address; tempContents.AddRef(); try { FileOutputStream writer = new FileOutputStream(file); int increment = 1024 * 4; - int pv = COM.CoTaskMemAlloc(increment); - int[] pcbWritten = new int[1]; - while (tempContents.Read(pv, increment, pcbWritten) is COM.S_OK && pcbWritten[0] > 0) { - byte[] buffer = new byte[ pcbWritten[0]]; - OS.MoveMemory(buffer, pv, pcbWritten[0]); + LPVOID pv = COM.CoTaskMemAlloc(increment); + uint pcbWritten; + while (tempContents.Read(pv, increment, &pcbWritten) is COM.S_OK && pcbWritten > 0) { + byte[] buffer = new byte[ pcbWritten]; + OS.MoveMemory(buffer.ptr, pv, pcbWritten); writer.write(buffer); // Note: if file does not exist, this will create the file the // first time it is called success = true; @@ -1135,27 +1054,27 @@ return success; } -private bool saveFromOle10Native(int address, File file) { +private bool saveFromOle10Native(IStream address, File file) { bool success = false; - IStream tempContents = new IStream(address); + IStream tempContents = address; tempContents.AddRef(); // The "\1Ole10Native" stream contains a DWORD header whose value is the length // of the native data that follows. - int pv = COM.CoTaskMemAlloc(4); - int[] size = new int[1]; - int rc = tempContents.Read(pv, 4, null); + LPVOID pv = COM.CoTaskMemAlloc(4); + uint size; + auto rc = tempContents.Read(pv, 4, null); OS.MoveMemory(size, pv, 4); COM.CoTaskMemFree(pv); - if (rc is COM.S_OK && size[0] > 0) { + if (rc is COM.S_OK && size > 0) { // Read the data - byte[] buffer = new byte[size[0]]; - pv = COM.CoTaskMemAlloc(size[0]); - rc = tempContents.Read(pv, size[0], null); - OS.MoveMemory(buffer, pv, size[0]); + byte[] buffer = new byte[size]; + pv = COM.CoTaskMemAlloc(size); + rc = tempContents.Read(pv, size, null); + OS.MoveMemory(buffer.ptr, pv, size); COM.CoTaskMemFree(pv); // open the file and write data into it @@ -1200,18 +1119,16 @@ if (!updateStorage()) return false; // get access to the persistent storage mechanism - int[] address = new int[1]; - if (objIOleObject.QueryInterface(COM.IIDIPersistStorage, address) !is COM.S_OK) return false; - IPersistStorage permStorage = new IPersistStorage(address[0]); + IPersistStorage permStorage; + if (objIOleObject.QueryInterface(&COM.IIDIPersistStorage, cast(void**)&permStorage) !is COM.S_OK) return false; try { - address = new int[1]; - char[] path = (file.getAbsolutePath()+"\0").toCharArray(); + IStorage storage; + wchar* path = StrToWCHARz(file.getAbsolutePath()); int mode = COM.STGM_TRANSACTED | COM.STGM_READWRITE | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_CREATE; - int result = COM.StgCreateDocfile(path, mode, 0, address); //Does an AddRef if successful + int result = COM.StgCreateDocfile(path, mode, 0, &storage); //Does an AddRef if successful if (result !is COM.S_OK) return false; - IStorage storage = new IStorage(address[0]); try { - if (COM.OleSave(permStorage.getAddress(), storage.getAddress(), false) is COM.S_OK) { + if (COM.OleSave(permStorage, storage, false) is COM.S_OK) { if (storage.Commit(COM.STGC_DEFAULT) is COM.S_OK) { return true; } @@ -1243,22 +1160,22 @@ if (!updateStorage()) return false; - int[] address = new int[1]; + IStream stream; // Look for a CONTENTS stream - if (tempStorage.OpenStream("CONTENTS", 0, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, address) is COM.S_OK) //$NON-NLS-1$ - return saveFromContents(address[0], file); + if (tempStorage.OpenStream(("CONTENTS"w).ptr, null, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, &stream) is COM.S_OK) //$NON-NLS-1$ + return saveFromContents(stream, file); // Look for Ole 1.0 object stream - if (tempStorage.OpenStream("\1Ole10Native", 0, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, address) is COM.S_OK) //$NON-NLS-1$ - return saveFromOle10Native(address[0], file); + if (tempStorage.OpenStream(("\1Ole10Native"w).ptr, null, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, &stream) is COM.S_OK) //$NON-NLS-1$ + return saveFromOle10Native(stream, file); return false; } private int Scroll(int scrollExtant) { return COM.S_OK; } -void setBorderSpace(RECT newBorderwidth) { - borderWidths = newBorderwidth; +void setBorderSpace(RECT* newBorderwidth) { + borderWidths = *newBorderwidth; // readjust size and location of client site Rectangle area = frame.getClientArea(); setBounds(borderWidths.left, borderWidths.top, @@ -1271,17 +1188,17 @@ // to the specified values. if (objIOleObject is null || isStatic || inUpdate) return; - SIZE currentExtent = getExtent(); + SIZE* currentExtent = getExtent(); if (width is currentExtent.cx && height is currentExtent.cy) return; - SIZE newExtent = new SIZE(); + SIZE* newExtent = new SIZE(); newExtent.cx = width; newExtent.cy = height; newExtent = xFormPixelsToHimetric(newExtent); // Get the server running first, then do a SetExtent, then show it - bool alreadyRunning = COM.OleIsRunning(objIOleObject.getAddress()); + bool alreadyRunning = cast(bool) COM.OleIsRunning(objIOleObject); if (!alreadyRunning) - COM.OleRun(objIOleObject.getAddress()); + COM.OleRun(objIOleObject); if (objIOleObject.SetExtent(aspect, newExtent) is COM.S_OK){ inUpdate = true; @@ -1293,7 +1210,6 @@ } } public void setIndent(Rectangle newIndent) { - indent = new RECT(); indent.left = newIndent.x; indent.right = newIndent.width; indent.top = newIndent.y; @@ -1303,7 +1219,7 @@ if (objIOleInPlaceObject is null) return; // size the object to fill the available space // leave a border - RECT rect = getRect(); + RECT* rect = getRect(); objIOleInPlaceObject.SetObjectRects(rect, rect); } @@ -1320,24 +1236,22 @@ * * @param title the name that will appear in the titlebar of the dialog */ -public void showProperties(String title) { +public void showProperties(char[] title) { // Get the Property Page information from the OLE Object - int[] ppvObject = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDISpecifyPropertyPages, ppvObject) !is COM.S_OK) return; - ISpecifyPropertyPages objISPP = new ISpecifyPropertyPages(ppvObject[0]); - CAUUID caGUID = new CAUUID(); - int result = objISPP.GetPages(caGUID); + ISpecifyPropertyPages objISPP; + if (objIUnknown.QueryInterface(&COM.IIDISpecifyPropertyPages, cast(void**)&objISPP) !is COM.S_OK) return; + CAUUID* caGUID = new CAUUID(); + auto result = objISPP.GetPages(caGUID); objISPP.Release(); if (result !is COM.S_OK) return; // create a frame in which to display the pages - char[] chTitle = null; + wchar* chTitle = null; if (title !is null) { - chTitle = new char[title.length()]; - title.getChars(0, title.length(), chTitle, 0); + chTitle = StrToWCHARz(title); } - result = COM.OleCreatePropertyFrame(frame.handle, 10, 10, chTitle, 1, new int[] {objIUnknown.getAddress()}, caGUID.cElems, caGUID.pElems, COM.LOCALE_USER_DEFAULT, 0, 0); + result = COM.OleCreatePropertyFrame(frame.handle, 10, 10, chTitle, 1, &objIUnknown, caGUID.cElems, caGUID.pElems, COM.LOCALE_USER_DEFAULT, 0, null); // free the property page information COM.CoTaskMemFree(caGUID.pElems); @@ -1346,53 +1260,152 @@ if (tempStorage is null) return false; - int[] ppv = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv) !is COM.S_OK) return false; - IPersistStorage iPersistStorage = new IPersistStorage(ppv[0]); + IPersistStorage iPersistStorage; + if (objIUnknown.QueryInterface(&COM.IIDIPersistStorage, cast(void**)&iPersistStorage) !is COM.S_OK) return false; - int result = COM.OleSave(iPersistStorage.getAddress(), tempStorage.getAddress(), true); + auto result = COM.OleSave(iPersistStorage, tempStorage, true); if (result !is COM.S_OK){ // OleSave will fail for static objects, so do what OleSave does. - COM.WriteClassStg(tempStorage.getAddress(), objClsid); - result = iPersistStorage.Save(tempStorage.getAddress(), true); + COM.WriteClassStg(tempStorage, objClsid); + result = iPersistStorage.Save(tempStorage, true); } tempStorage.Commit(COM.STGC_DEFAULT); - result = iPersistStorage.SaveCompleted(0); + result = iPersistStorage.SaveCompleted(null); iPersistStorage.Release(); return true; } -private SIZE xFormHimetricToPixels(SIZE aSize) { +private SIZE* xFormHimetricToPixels(SIZE* aSize) { // Return a new Size which is the pixel transformation of a // size in HIMETRIC units. - int hDC = OS.GetDC(0); + auto hDC = OS.GetDC(null); int xppi = OS.GetDeviceCaps(hDC, 88); // logical pixels/inch in x int yppi = OS.GetDeviceCaps(hDC, 90); // logical pixels/inch in y - OS.ReleaseDC(0, hDC); + OS.ReleaseDC(null, hDC); int cx = Compatibility.round(aSize.cx * xppi, 2540); // 2540 HIMETRIC units per inch int cy = Compatibility.round(aSize.cy * yppi, 2540); - SIZE size = new SIZE(); + SIZE* size = new SIZE(); size.cx = cx; size.cy = cy; return size; } -private SIZE xFormPixelsToHimetric(SIZE aSize) { +private SIZE* xFormPixelsToHimetric(SIZE* aSize) { // Return a new size which is the HIMETRIC transformation of a // size in pixel units. - int hDC = OS.GetDC(0); + auto hDC = OS.GetDC(null); int xppi = OS.GetDeviceCaps(hDC, 88); // logical pixels/inch in x int yppi = OS.GetDeviceCaps(hDC, 90); // logical pixels/inch in y - OS.ReleaseDC(0, hDC); + OS.ReleaseDC(null, hDC); int cx = Compatibility.round(aSize.cx * 2540, xppi); // 2540 HIMETRIC units per inch int cy = Compatibility.round(aSize.cy * 2540, yppi); - SIZE size = new SIZE(); + SIZE* size = new SIZE(); size.cx = cx; size.cy = cy; return size; } } -++/ + +class _IAdviseSinkImpl : IAdviseSink { + + OleClientSite parent; + this(OleClientSite p) { parent = p; } +extern (Windows): + // interface of IUnknown + HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } + + // interface of IAdviseSink + void OnDataChange(FORMATETC *pFormatetc,STGMEDIUM *pStgmed) {return COM.S_OK; } + void OnViewChange(DWORD dwAspect, LONG lindex) {return COM.S_OK; } + void OnRename(IMoniker pmk) {return COM.S_OK; } + void OnSave() {return COM.S_OK; } + void OnClose() {return COM.S_OK; } +} + +class _IOleClientSiteImpl : IOleClientSite { + + OleClientSite parent; + this(OleClientSite p) { parent = p; } +extern (Windows): + // interface of IUnknown + HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } + + // interface of IOleClientSite + HRESULT SaveObject() { if(parent) parent.updateStorage(); return COM.S_OK; } + HRESULT GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker * ppmk ) {return COM.E_NOTIMPL; } + HRESULT GetContainer( IOleContainer* ppContainer ) { return parent.GetContainer(ppContainer);} + HRESULT ShowObject() { + /* Tells the container to position the object so it is visible to + * the user. This method ensures that the container itself is + * visible and not minimized. + */ + return COM.S_OK; + } + HRESULT OnShowWindow(BOOL fShow ) {return COM.S_OK; } + HRESULT RequestNewObjectLayout() {return COM.E_NOTIMPL; } +} + +class _IOleDocumentSiteImpl : IOleDocumentSite { + + OleClientSite parent; + this(OleClientSite p) { parent = p; } +extern (Windows): + // interface of IUnknown + HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } + + // interface of IOleDocumentSite + HRESULT ActivateMe(IOleDocumentView pViewToActivate) { return parent.ActivateMe(pViewToActivate);} +} + +class _IOleInPlaceSiteImpl : IOleInPlaceSite { + OleClientSite parent; + this(OleClientSite p) { parent = p; } +extern (Windows): + // interface of IUnknown + HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } + + // interface of IOleWindow + HRESULT GetWindow( HWND* phwnd ) { return parent.GetWindow(phwnd); } + HRESULT ContextSensitiveHelp( BOOL fEnterMode ) {return COM.S_OK; } + + // interface of IOleInPlaceSite + HRESULT CanInPlaceActivate() { return parent.CanInPlaceActivate();} + HRESULT OnInPlaceActivate() { return parent.OnInPlaceActivate(); } + HRESULT OnUIActivate() { return parent.OnUIActivate(); } + HRESULT GetWindowContext( IOleInPlaceFrame * ppFrame, IOleInPlaceUIWindow * ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo ) { + return parent.GetWindowContext(ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo); + } + HRESULT Scroll( SIZE scrollExtant ) {return COM.S_OK; } + HRESULT OnUIDeactivate( BOOL fUndoable ) { return parent.OnUIDeactivate(fUndoable);} + HRESULT OnInPlaceDeactivate() { return parent.OnInPlaceDeactivate();} + HRESULT DiscardUndoState() {return COM.E_NOTIMPL; } + HRESULT DeactivateAndUndo() {return COM.E_NOTIMPL; } + HRESULT OnPosRectChange( LPCRECT lprcPosRect) { return parent.OnPosRectChange(lprcPosRect);} +} + +class _IUnknownImpl : IUnknown +{ + + OleClientSite parent; + this(OleClientSite p) { parent = p; } +extern (Windows): + // interface of IUnknown + HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } +} + + + +
--- a/dwt/ole/win32/OleControlSite.d Fri Feb 08 19:49:32 2008 +0100 +++ b/dwt/ole/win32/OleControlSite.d Sat Feb 09 03:36:27 2008 +0100 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> *******************************************************************************/ module dwt.ole.win32.OleControlSite; @@ -16,16 +18,27 @@ import dwt.graphics.Color; import dwt.graphics.Font; import dwt.graphics.FontData; +import dwt.graphics.Device; import dwt.internal.ole.win32.COM; +import dwt.internal.ole.win32.COMTYPES; +import dwt.internal.ole.win32.extras; +import dwt.internal.ole.win32.ifs; +import dwt.internal.ole.win32.OAIDL; +import dwt.internal.ole.win32.OBJIDL; import dwt.internal.win32.OS; import dwt.widgets.Composite; import dwt.widgets.Event; import dwt.ole.win32.OleClientSite; +import dwt.ole.win32.OleEventSink; +import dwt.ole.win32.OlePropertyChangeSink; +import dwt.ole.win32.OleListener; +import dwt.ole.win32.OleAutomation; +import dwt.ole.win32.Variant; +import dwt.ole.win32.OLE; -class OleControlSite : OleClientSite { -} -/++ +import dwt.dwthelper.utils; + /** * OleControlSite provides a site to manage an embedded ActiveX Control within a container. * @@ -49,24 +62,24 @@ * </dl> * */ -public class OleControlSite extends OleClientSite +public class OleControlSite : OleClientSite { // interfaces for this container - private COMObject iOleControlSite; - private COMObject iDispatch; + private _IOleControlSiteImpl iOleControlSite; + private _IDispatchImpl iDispatch; // supporting Property Change attributes private OlePropertyChangeSink olePropertyChangeSink; // supporting Event Sink attributes - private OleEventSink[] oleEventSink = new OleEventSink[0]; - private GUID[] oleEventSinkGUID = new GUID[0]; - private int[] oleEventSinkIUnknown = new int[0]; + private OleEventSink[] oleEventSink; + private GUID*[] oleEventSinkGUID; + private IUnknown[] oleEventSinkIUnknown; // supporting information for the Control COM object - private CONTROLINFO currentControlInfo; - private int[] sitePropertyIds = new int[0]; - private Variant[] sitePropertyValues = new Variant[0]; + private CONTROLINFO* currentControlInfo; + private int[] sitePropertyIds; + private Variant[] sitePropertyValues; // work around for IE destroying the caret static int SWT_RESTORECARET; @@ -93,55 +106,47 @@ * <li>ERROR_CANNOT_CREATE_LICENSED_OBJECT when failed to create a licensed OLE Object * </ul> */ -public OleControlSite(Composite parent, int style, String progId) { +public this(Composite parent, int style, char[] progId) { super(parent, style); try { // check for licensing appClsid = getClassID(progId); - if (appClsid is null) OLE.error(OLE.ERROR_INVALID_CLASSID); + if (appClsid is null) OLE.error(__FILE__, __LINE__, OLE.ERROR_INVALID_CLASSID); - int licinfo = getLicenseInfo(appClsid); - if (licinfo is 0) { + BSTR licinfo = getLicenseInfo(appClsid); + if (licinfo is null) { // Open a storage object tempStorage = createTempStorage(); // Create ole object with storage object - int[] address = new int[1]; - int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address); + HRESULT result = COM.OleCreate(appClsid, &COM.IIDIUnknown, COM.OLERENDER_DRAW, null, null, tempStorage, cast(void**)&objIUnknown); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); - - objIUnknown = new IUnknown(address[0]); + OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_CREATE_OBJECT, result); } else { // Prepare the ClassFactory - int[] ppvObject = new int[1]; try { - int result = COM.CoGetClassObject(appClsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory2, ppvObject); + IClassFactory2 classFactory; + HRESULT result = COM.CoGetClassObject(appClsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, null, &COM.IIDIClassFactory2, cast(void**)&classFactory); if (result !is COM.S_OK) { - OLE.error(OLE.ERROR_CANNOT_ACCESS_CLASSFACTORY, result); + OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_ACCESS_CLASSFACTORY, result); } - IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]); // Create Com Object - ppvObject = new int[1]; - result = classFactory.CreateInstanceLic(0, 0, COM.IIDIUnknown, licinfo, ppvObject); + result = classFactory.CreateInstanceLic(null, null, &COM.IIDIUnknown, licinfo, cast(void**)&objIUnknown); classFactory.Release(); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_CANNOT_CREATE_LICENSED_OBJECT, result); + OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_CREATE_LICENSED_OBJECT, result); } finally { COM.SysFreeString(licinfo); } - objIUnknown = new IUnknown(ppvObject[0]); - // Prepare a storage medium - ppvObject = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppvObject) is COM.S_OK) { - IPersistStorage persist = new IPersistStorage(ppvObject[0]); + IPersistStorage persist; + if (objIUnknown.QueryInterface(&COM.IIDIPersistStorage, cast(void**)&persist) is COM.S_OK) { tempStorage = createTempStorage(); - persist.InitNew(tempStorage.getAddress()); + persist.InitNew(tempStorage); persist.Release(); } } @@ -153,7 +158,7 @@ setSiteProperty(COM.DISPID_AMBIENT_USERMODE, new Variant(true)); setSiteProperty(COM.DISPID_AMBIENT_UIDEAD, new Variant(false)); - if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state= STATE_RUNNING; + if (COM.OleRun(objIUnknown) is OLE.S_OK) state= STATE_RUNNING; } catch (DWTError e) { dispose(); @@ -173,66 +178,62 @@ * </ul> */ public void addEventListener(int eventID, OleListener listener) { - if (listener is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); - GUID riid = getDefaultEventSinkGUID(objIUnknown); + if (listener is null) OLE.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); + GUID* riid = getDefaultEventSinkGUID(objIUnknown); if (riid !is null) { - addEventListener(objIUnknown.getAddress(), riid, eventID, listener); + addEventListener(objIUnknown, riid, eventID, listener); } - } -static GUID getDefaultEventSinkGUID(IUnknown unknown) { + + +static GUID* getDefaultEventSinkGUID(IUnknown unknown) { // get Event Sink I/F from IProvideClassInfo2 - int[] ppvObject = new int[1]; - if (unknown.QueryInterface(COM.IIDIProvideClassInfo2, ppvObject) is COM.S_OK) { - IProvideClassInfo2 pci2 = new IProvideClassInfo2(ppvObject[0]); - GUID riid = new GUID(); - int result = pci2.GetGUID(COM.GUIDKIND_DEFAULT_SOURCE_DISP_IID, riid); + IProvideClassInfo2 pci2; + if (unknown.QueryInterface(&COM.IIDIProvideClassInfo2, cast(void**)&pci2) is COM.S_OK) { + GUID* riid = new GUID(); + HRESULT result = pci2.GetGUID(COM.GUIDKIND_DEFAULT_SOURCE_DISP_IID, riid); pci2.Release(); if (result is COM.S_OK) return riid; } // get Event Sink I/F from IProvideClassInfo - if (unknown.QueryInterface(COM.IIDIProvideClassInfo, ppvObject) is COM.S_OK) { - IProvideClassInfo pci = new IProvideClassInfo(ppvObject[0]); - int[] ppTI = new int[1]; - int[] ppEI = new int[1]; - int result = pci.GetClassInfo(ppTI); + IProvideClassInfo pci; + if (unknown.QueryInterface(&COM.IIDIProvideClassInfo, cast(void**)&pci) is COM.S_OK) { + ITypeInfo classInfo; + ITypeInfo eventInfo; + HRESULT result = pci.GetClassInfo(&classInfo); pci.Release(); - if (result is COM.S_OK && ppTI[0] !is 0) { - ITypeInfo classInfo = new ITypeInfo(ppTI[0]); - int[] ppTypeAttr = new int[1]; - result = classInfo.GetTypeAttr(ppTypeAttr); - if (result is COM.S_OK && ppTypeAttr[0] !is 0) { - TYPEATTR typeAttribute = new TYPEATTR(); - COM.MoveMemory(typeAttribute, ppTypeAttr[0], TYPEATTR.sizeof); - classInfo.ReleaseTypeAttr(ppTypeAttr[0]); + if (result is COM.S_OK && classInfo !is null) { + TYPEATTR* typeAttribute; + result = classInfo.GetTypeAttr(&typeAttribute); + if (result is COM.S_OK && typeAttribute !is null) { int implMask = COM.IMPLTYPEFLAG_FDEFAULT | COM.IMPLTYPEFLAG_FSOURCE | COM.IMPLTYPEFLAG_FRESTRICTED; int implBits = COM.IMPLTYPEFLAG_FDEFAULT | COM.IMPLTYPEFLAG_FSOURCE; - for (int i = 0; i < typeAttribute.cImplTypes; i++) { - int[] pImplTypeFlags = new int[1]; - if (classInfo.GetImplTypeFlags(i, pImplTypeFlags) is COM.S_OK) { - if ((pImplTypeFlags[0] & implMask) is implBits) { - int[] pRefType = new int[1]; - if (classInfo.GetRefTypeOfImplType(i, pRefType) is COM.S_OK) { - classInfo.GetRefTypeInfo(pRefType[0], ppEI); + for (uint i = 0; i < typeAttribute.cImplTypes; i++) { + int pImplTypeFlags; + if (classInfo.GetImplTypeFlags(i, &pImplTypeFlags) is COM.S_OK) { + if ((pImplTypeFlags & implMask) is implBits) { + uint pRefType; + if (classInfo.GetRefTypeOfImplType(i, &pRefType) is COM.S_OK) { + classInfo.GetRefTypeInfo(pRefType, &eventInfo); } } } } + classInfo.ReleaseTypeAttr(typeAttribute); } classInfo.Release(); - if (ppEI[0] !is 0) { - ITypeInfo eventInfo = new ITypeInfo(ppEI[0]); - ppTypeAttr = new int[1]; - result = eventInfo.GetTypeAttr(ppTypeAttr); - GUID riid = null; - if (result is COM.S_OK && ppTypeAttr[0] !is 0) { + if (eventInfo !is null) { + TYPEATTR* ppTypeAttr; + result = eventInfo.GetTypeAttr(&ppTypeAttr); + GUID* riid = null; + if (result is COM.S_OK && ppTypeAttr !is null) { riid = new GUID(); - COM.MoveMemory(riid, ppTypeAttr[0], GUID.sizeof); - eventInfo.ReleaseTypeAttr(ppTypeAttr[0]); + *riid = ppTypeAttr.guid; + eventInfo.ReleaseTypeAttr(ppTypeAttr); } eventInfo.Release(); return riid; @@ -256,12 +257,11 @@ * </ul> */ public void addEventListener(OleAutomation automation, int eventID, OleListener listener) { - if (listener is null || automation is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); - int address = automation.getAddress(); - IUnknown unknown = new IUnknown(address); - GUID riid = getDefaultEventSinkGUID(unknown); + if (listener is null || automation is null) OLE.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); + IUnknown unknown = automation.getAddress(); + GUID* riid = getDefaultEventSinkGUID(unknown); if (riid !is null) { - addEventListener(address, riid, eventID, listener); + addEventListener(unknown, riid, eventID, listener); } } @@ -279,18 +279,18 @@ * <li>ERROR_NULL_ARGUMENT when listener is null</li> * </ul> */ -public void addEventListener(OleAutomation automation, String eventSinkId, int eventID, OleListener listener) { - if (listener is null || automation is null || eventSinkId is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); - int address = automation.getAddress(); - if (address is 0) return; - char[] buffer = (eventSinkId +"\0").toCharArray(); - GUID guid = new GUID(); - if (COM.IIDFromString(buffer, guid) !is COM.S_OK) return; +public void addEventListener(OleAutomation automation, char[] eventSinkId, int eventID, OleListener listener) { + if (listener is null || automation is null || eventSinkId is null) OLE.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); + auto address = automation.getAddress(); + if (address is null) return; + wchar[] buffer = StrToWCHARs(0,eventSinkId,true); + GUID* guid = new GUID(); + if (COM.IIDFromString(buffer.ptr, guid) !is COM.S_OK) return; addEventListener(address, guid, eventID, listener); } -void addEventListener(int iunknown, GUID guid, int eventID, OleListener listener) { - if (listener is null || iunknown is 0 || guid is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); +void addEventListener(IUnknown iunknown, GUID* guid, int eventID, OleListener listener) { + if (listener is null || iunknown is null || guid is null) OLE.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); // have we connected to this kind of event sink before? int index = -1; for (int i = 0; i < oleEventSinkGUID.length; i++) { @@ -305,19 +305,11 @@ oleEventSink[index].addListener(eventID, listener); } else { int oldLength = oleEventSink.length; - OleEventSink[] newOleEventSink = new OleEventSink[oldLength + 1]; - GUID[] newOleEventSinkGUID = new GUID[oldLength + 1]; - int[] newOleEventSinkIUnknown = new int[oldLength + 1]; - System.arraycopy(oleEventSink, 0, newOleEventSink, 0, oldLength); - System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, oldLength); - System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, oldLength); - oleEventSink = newOleEventSink; - oleEventSinkGUID = newOleEventSinkGUID; - oleEventSinkIUnknown = newOleEventSinkIUnknown; - oleEventSink[oldLength] = new OleEventSink(this, iunknown, guid); - oleEventSinkGUID[oldLength] = guid; - oleEventSinkIUnknown[oldLength] = iunknown; + oleEventSink ~= new OleEventSink(this, iunknown, guid); + oleEventSinkGUID ~= guid; + oleEventSinkIUnknown ~= iunknown; + oleEventSink[oldLength].AddRef(); oleEventSink[oldLength].connect(); oleEventSink[oldLength].addListener(eventID, listener); @@ -332,9 +324,8 @@ connectPropertyChangeSink(); // Get access to the Control object - int[] ppvObject = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) is COM.S_OK) { - IOleControl objIOleControl = new IOleControl(ppvObject[0]); + IOleControl objIOleControl; + if (objIUnknown.QueryInterface(&COM.IIDIOleControl, cast(void**)&objIOleControl) is COM.S_OK) { // ask the control for its info in case users // need to act on it currentControlInfo = new CONTROLINFO(); @@ -353,7 +344,7 @@ * </ul> */ public void addPropertyListener(int propertyID, OleListener listener) { - if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + if (listener is null) DWT.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); olePropertyChangeSink.addListener(propertyID, listener); } @@ -364,30 +355,8 @@ } protected void createCOMInterfaces () { super.createCOMInterfaces(); - - // register each of the interfaces that this object implements - iOleControlSite = new COMObject(new int[]{2, 0, 0, 0, 1, 1, 3, 2, 1, 0}){ - public int method0(int[] args) {return QueryInterface(args[0], args[1]);} - public int method1(int[] args) {return AddRef();} - public int method2(int[] args) {return Release();} - public int method3(int[] args) {return OnControlInfoChanged();} - // method4 LockInPlaceActive - not implemented - // method5 GetExtendedControl - not implemented - // method6 TransformCoords - not implemented - // method7 Translate Accelerator - not implemented - public int method8(int[] args) {return OnFocus(args[0]);} - // method9 ShowPropertyFrame - not implemented - }; - - iDispatch = new COMObject(new int[]{2, 0, 0, 1, 3, 5, 8}){ - public int method0(int[] args) {return QueryInterface(args[0], args[1]);} - public int method1(int[] args) {return AddRef();} - public int method2(int[] args) {return Release();} - // method3 GetTypeInfoCount - not implemented - // method4 GetTypeInfo - not implemented - // method5 GetIDsOfNames - not implemented - public int method6(int[] args) {return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);} - }; + iOleControlSite = new _IOleControlSiteImpl(this); + iDispatch = new _IDispatchImpl(this); } private void disconnectEventSinks() { @@ -396,9 +365,9 @@ sink.disconnect(); sink.Release(); } - oleEventSink = new OleEventSink[0]; - oleEventSinkGUID = new GUID[0]; - oleEventSinkIUnknown = new int[0]; + oleEventSink = null; + oleEventSinkGUID = null; + oleEventSinkIUnknown = null; } private void disconnectPropertyChangeSink() { @@ -410,13 +379,7 @@ } protected void disposeCOMInterfaces() { super.disposeCOMInterfaces(); - - if (iOleControlSite !is null) - iOleControlSite.dispose(); iOleControlSite = null; - - if (iDispatch !is null) - iDispatch.dispose(); iDispatch = null; } public Color getBackground () { @@ -428,9 +391,9 @@ oleObject.dispose(); if (varBackColor !is null){ - int[] colorRef = new int[1]; - if (COM.OleTranslateColor(varBackColor.getInt(), getDisplay().hPalette, colorRef) is COM.S_OK) - return Color.win32_new(getDisplay(), colorRef[0]); + COLORREF colorRef; + if (COM.OleTranslateColor(varBackColor.getInt(), getDisplay().hPalette, &colorRef) is COM.S_OK) + return Color.win32_new(getDisplay(), colorRef); } } @@ -457,7 +420,8 @@ lfItalic !is null && lfBold !is null){ int style = 3 * lfBold.getInt() + 2 * lfItalic.getInt(); - Font font = new Font(getShell().getDisplay(), lfFaceName.getString(), lfHeight.getInt(), style); + Device dev = getShell().getDisplay(); + Font font = new Font(dev, lfFaceName.getString(), lfHeight.getInt(), style); return font; } } @@ -474,35 +438,33 @@ oleObject.dispose(); if (varForeColor !is null){ - int[] colorRef = new int[1]; - if (COM.OleTranslateColor(varForeColor.getInt(), getDisplay().hPalette, colorRef) is COM.S_OK) - return Color.win32_new(getDisplay(), colorRef[0]); + COLORREF colorRef; + if (COM.OleTranslateColor(varForeColor.getInt(), getDisplay().hPalette, &colorRef) is COM.S_OK) + return Color.win32_new(getDisplay(), colorRef); } } return super.getForeground(); } -protected int getLicenseInfo(GUID clsid) { - int[] ppvObject = new int[1]; - - if (COM.CoGetClassObject(clsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory2, ppvObject) !is COM.S_OK) { - return 0; +protected BSTR getLicenseInfo(GUID* clsid) { + IClassFactory2 classFactory; + if (COM.CoGetClassObject(clsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, null, &COM.IIDIClassFactory2, cast(void**)&classFactory) !is COM.S_OK) { + return null; } - IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]); - LICINFO licinfo = new LICINFO(); - if (classFactory.GetLicInfo(licinfo) !is COM.S_OK) { + LICINFO licinfo; + if (classFactory.GetLicInfo(&licinfo) !is COM.S_OK) { classFactory.Release(); - return 0; + return null; } - int[] pBstrKey = new int[1]; - if (licinfo !is null && licinfo.fRuntimeKeyAvail) { - if (classFactory.RequestLicKey(0, pBstrKey) is COM.S_OK) { + BSTR pBstrKey; + if (licinfo.fRuntimeKeyAvail) { + if (classFactory.RequestLicKey(0, &pBstrKey) is COM.S_OK) { classFactory.Release(); - return pBstrKey[0]; + return pBstrKey; } } classFactory.Release(); - return 0; + return null; } /** * @@ -519,28 +481,30 @@ } return null; } -protected int GetWindow(int phwnd) { +protected HRESULT GetWindow(HWND* phwnd) { - if (phwnd is 0) + if (phwnd is null) return COM.E_INVALIDARG; if (frame is null) { - COM.MoveMemory(phwnd, new int[] {0}, 4); + *phwnd = null; return COM.E_NOTIMPL; } // Copy the Window's handle into the memory passed in - COM.MoveMemory(phwnd, new int[] {handle}, 4); + *phwnd = handle; return COM.S_OK; } -private int Invoke(int dispIdMember, int riid, int lcid, int dwFlags, int pDispParams, int pVarResult, int pExcepInfo, int pArgErr) { - if (pVarResult is 0 || dwFlags !is COM.DISPATCH_PROPERTYGET) { - if (pExcepInfo !is 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4); - if (pArgErr !is 0) COM.MoveMemory(pArgErr, new int[] {0}, 4); + +private HRESULT Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD dwFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,EXCEPINFO* pExcepInfo,UINT* pArgErr) { + int nullv = 0; + if (pVarResult is null || dwFlags !is COM.DISPATCH_PROPERTYGET) { + if (pExcepInfo !is null) COM.MoveMemory(pExcepInfo, &nullv, 4); + if (pArgErr !is null) COM.MoveMemory(pArgErr, &nullv, 4); return COM.DISP_E_MEMBERNOTFOUND; } Variant result = getSiteProperty(dispIdMember); if (result !is null) { - if (pVarResult !is 0) result.getData(pVarResult); + if (pVarResult !is null) result.getData(pVarResult); return COM.S_OK; } switch (dispIdMember) { @@ -548,9 +512,9 @@ case COM.DISPID_AMBIENT_SUPPORTSMNEMONICS : case COM.DISPID_AMBIENT_SHOWGRABHANDLES : case COM.DISPID_AMBIENT_SHOWHATCHING : - if (pVarResult !is 0) COM.MoveMemory(pVarResult, new int[] {0}, 4); - if (pExcepInfo !is 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4); - if (pArgErr !is 0) COM.MoveMemory(pArgErr, new int[] {0}, 4); + if (pVarResult !is null) COM.MoveMemory(pVarResult, &nullv, 4); + if (pExcepInfo !is null) COM.MoveMemory(pExcepInfo, &nullv, 4); + if (pArgErr !is null) COM.MoveMemory(pArgErr, &nullv, 4); return COM.S_FALSE; // not implemented @@ -561,22 +525,21 @@ case COM.DISPID_AMBIENT_LOCALEID : case COM.DISPID_AMBIENT_SILENT : case COM.DISPID_AMBIENT_MESSAGEREFLECT : - if (pVarResult !is 0) COM.MoveMemory(pVarResult, new int[] {0}, 4); - if (pExcepInfo !is 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4); - if (pArgErr !is 0) COM.MoveMemory(pArgErr, new int[] {0}, 4); + if (pVarResult !is null) COM.MoveMemory(pVarResult, &nullv, 4); + if (pExcepInfo !is null) COM.MoveMemory(pExcepInfo, &nullv, 4); + if (pArgErr !is null) COM.MoveMemory(pArgErr, &nullv, 4); return COM.E_NOTIMPL; default : - if (pVarResult !is 0) COM.MoveMemory(pVarResult, new int[] {0}, 4); - if (pExcepInfo !is 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4); - if (pArgErr !is 0) COM.MoveMemory(pArgErr, new int[] {0}, 4); + if (pVarResult !is null) COM.MoveMemory(pVarResult, &nullv, 4); + if (pExcepInfo !is null) COM.MoveMemory(pExcepInfo, &nullv, 4); + if (pArgErr !is null) COM.MoveMemory(pArgErr, &nullv, 4); return COM.DISP_E_MEMBERNOTFOUND; } } private int OnControlInfoChanged() { - int[] ppvObject = new int[1]; - if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) is COM.S_OK) { - IOleControl objIOleControl = new IOleControl(ppvObject[0]); + IOleControl objIOleControl; + if (objIUnknown.QueryInterface(&COM.IIDIOleControl, cast(void**)&objIOleControl ) is COM.S_OK) { // ask the control for its info in case users // need to act on it currentControlInfo = new CONTROLINFO(); @@ -589,10 +552,10 @@ if (objIOleInPlaceObject is null) return; doVerb(OLE.OLEIVERB_UIACTIVATE); if (isFocusControl()) return; - int[] phwnd = new int[1]; - objIOleInPlaceObject.GetWindow(phwnd); - if (phwnd[0] is 0) return; - OS.SetFocus(phwnd[0]); + HWND phwnd; + objIOleInPlaceObject.GetWindow(&phwnd); + if (phwnd is null) return; + OS.SetFocus(phwnd); } void onFocusOut(Event e) { if (objIOleInPlaceObject !is null) { @@ -603,18 +566,18 @@ * that shows a caret then the caret disappears. The fix * is to detect this case and restore the caret. */ - int threadId = OS.GetCurrentThreadId(); - GUITHREADINFO lpgui1 = new GUITHREADINFO(); + auto threadId = OS.GetCurrentThreadId(); + GUITHREADINFO* lpgui1 = new GUITHREADINFO(); lpgui1.cbSize = GUITHREADINFO.sizeof; OS.GetGUIThreadInfo(threadId, lpgui1); objIOleInPlaceObject.UIDeactivate(); - if (lpgui1.hwndCaret !is 0) { - GUITHREADINFO lpgui2 = new GUITHREADINFO(); + if (lpgui1.hwndCaret !is null) { + GUITHREADINFO* lpgui2 = new GUITHREADINFO(); lpgui2.cbSize = GUITHREADINFO.sizeof; OS.GetGUIThreadInfo(threadId, lpgui2); - if (lpgui2.hwndCaret is 0 && lpgui1.hwndCaret is OS.GetFocus()) { + if (lpgui2.hwndCaret is null && lpgui1.hwndCaret is OS.GetFocus()) { if (SWT_RESTORECARET is 0) { - SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true)); + SWT_RESTORECARET = OS.RegisterWindowMessage (StrToTCHARz (0, "SWT_RESTORECARET")); } /* * If the caret was not restored by DWT, put it back using @@ -623,10 +586,10 @@ * API to query the bitmap that the caret is using. */ if (OS.SendMessage (lpgui1.hwndCaret, SWT_RESTORECARET, 0, 0) is 0) { - int width = lpgui1.right - lpgui1.left; - int height = lpgui1.bottom - lpgui1.top; - OS.CreateCaret (lpgui1.hwndCaret, 0, width, height); - OS.SetCaretPos (lpgui1.left, lpgui1.top); + int width = lpgui1.rcCaret.right - lpgui1.rcCaret.left; + int height = lpgui1.rcCaret.bottom - lpgui1.rcCaret.top; + OS.CreateCaret (lpgui1.hwndCaret, null, width, height); + OS.SetCaretPos (lpgui1.rcCaret.left, lpgui1.rcCaret.top); OS.ShowCaret (lpgui1.hwndCaret); } } @@ -642,25 +605,26 @@ state = STATE_INPLACEACTIVE; return COM.S_OK; } -protected int QueryInterface(int riid, int ppvObject) { +override protected HRESULT QueryInterface(REFIID riid, void ** ppvObject) { + int nullv = 0; int result = super.QueryInterface(riid, ppvObject); if (result is COM.S_OK) return result; - if (riid is 0 || ppvObject is 0) + if (riid is null || ppvObject is null) return COM.E_INVALIDARG; - GUID guid = new GUID(); - COM.MoveMemory(guid, riid, GUID.sizeof); - if (COM.IsEqualGUID(guid, COM.IIDIOleControlSite)) { - COM.MoveMemory(ppvObject, new int[] {iOleControlSite.getAddress()}, 4); + GUID* guid; + COM.MoveMemory(&guid, riid, GUID.sizeof); + if (COM.IsEqualGUID(guid, &COM.IIDIOleControlSite)) { + *ppvObject = cast(void*)cast(IOleControlSite)iOleControlSite; AddRef(); return COM.S_OK; } - if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) { - COM.MoveMemory(ppvObject, new int[] {iDispatch.getAddress()}, 4); + if (COM.IsEqualGUID(guid, &COM.IIDIDispatch)) { + *ppvObject = cast(void*)cast(IDispatch)iDispatch; AddRef(); return COM.S_OK; } - COM.MoveMemory(ppvObject, new int[] {0}, 4); + *ppvObject = null; return COM.E_NOINTERFACE; } protected int Release() { @@ -669,8 +633,8 @@ for (int i = 0; i < sitePropertyIds.length; i++) { sitePropertyValues[i].dispose(); } - sitePropertyIds = new int[0]; - sitePropertyValues = new Variant[0]; + sitePropertyIds = null; + sitePropertyValues = null; } return result; } @@ -695,11 +659,11 @@ */ public void removeEventListener(int eventID, OleListener listener) { checkWidget(); - if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + if (listener is null) DWT.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); - GUID riid = getDefaultEventSinkGUID(objIUnknown); + GUID* riid = getDefaultEventSinkGUID(objIUnknown); if (riid !is null) { - removeEventListener(objIUnknown.getAddress(), riid, eventID, listener); + removeEventListener(objIUnknown, riid, eventID, listener); } } /** @@ -720,9 +684,9 @@ * <li>ERROR_NULL_ARGUMENT when listener is null</li> * </ul> */ -public void removeEventListener(OleAutomation automation, GUID guid, int eventID, OleListener listener) { +public void removeEventListener(OleAutomation automation, GUID* guid, int eventID, OleListener listener) { checkWidget(); - if (automation is null || listener is null || guid is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + if (automation is null || listener is null || guid is null) DWT.error ( __FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); removeEventListener(automation.getAddress(), guid, eventID, listener); } /** @@ -742,16 +706,15 @@ */ public void removeEventListener(OleAutomation automation, int eventID, OleListener listener) { checkWidget(); - if (automation is null || listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); - int address = automation.getAddress(); - IUnknown unknown = new IUnknown(address); - GUID riid = getDefaultEventSinkGUID(unknown); + if (automation is null || listener is null) DWT.error ( __FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); + auto unknown = automation.getAddress(); + GUID* riid = getDefaultEventSinkGUID(unknown); if (riid !is null) { - removeEventListener(address, riid, eventID, listener); + removeEventListener(unknown, riid, eventID, listener); } } -void removeEventListener(int iunknown, GUID guid, int eventID, OleListener listener) { - if (listener is null || guid is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); +void removeEventListener(IUnknown iunknown, GUID* guid, int eventID, OleListener listener) { + if (listener is null || guid is null) DWT.error ( __FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); for (int i = 0; i < oleEventSink.length; i++) { if (COM.IsEqualGUID(oleEventSinkGUID[i], guid)) { if (iunknown is oleEventSinkIUnknown[i]) { @@ -762,23 +725,23 @@ oleEventSink[i].Release(); int oldLength = oleEventSink.length; if (oldLength is 1) { - oleEventSink = new OleEventSink[0]; - oleEventSinkGUID = new GUID[0]; - oleEventSinkIUnknown = new int[0]; + oleEventSink = null; + oleEventSinkGUID = null; + oleEventSinkIUnknown = null; } else { OleEventSink[] newOleEventSink = new OleEventSink[oldLength - 1]; System.arraycopy(oleEventSink, 0, newOleEventSink, 0, i); System.arraycopy(oleEventSink, i + 1, newOleEventSink, i, oldLength - i - 1); oleEventSink = newOleEventSink; - GUID[] newOleEventSinkGUID = new GUID[oldLength - 1]; - System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, i); - System.arraycopy(oleEventSinkGUID, i + 1, newOleEventSinkGUID, i, oldLength - i - 1); + GUID*[] newOleEventSinkGUID = new GUID*[oldLength - 1]; + SimpleType!(GUID*).arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, i); + SimpleType!(GUID*).arraycopy(oleEventSinkGUID, i + 1, newOleEventSinkGUID, i, oldLength - i - 1); oleEventSinkGUID = newOleEventSinkGUID; - int[] newOleEventSinkIUnknown = new int[oldLength - 1]; - System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, i); - System.arraycopy(oleEventSinkIUnknown, i + 1, newOleEventSinkIUnknown, i, oldLength - i - 1); + IUnknown[] newOleEventSinkIUnknown = new IUnknown[oldLength - 1]; + SimpleType!(IUnknown).arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, i); + SimpleType!(IUnknown).arraycopy(oleEventSinkIUnknown, i + 1, newOleEventSinkIUnknown, i, oldLength - i - 1); oleEventSinkIUnknown = newOleEventSinkIUnknown; } } @@ -797,7 +760,7 @@ * </ul> */ public void removePropertyListener(int propertyID, OleListener listener) { - if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + if (listener is null) DWT.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); olePropertyChangeSink.removeListener(propertyID, listener); } public void setBackground (Color color) { @@ -807,7 +770,7 @@ //set the background of the ActiveX Control if (objIUnknown !is null) { OleAutomation oleObject= new OleAutomation(this); - oleObject.setProperty(COM.DISPID_BACKCOLOR, new Variant(color.handle)); + oleObject.setProperty(COM.DISPID_BACKCOLOR, new Variant(cast(int)color.handle)); oleObject.dispose(); } } @@ -843,7 +806,7 @@ //set the foreground of the ActiveX Control if (objIUnknown !is null) { OleAutomation oleObject= new OleAutomation(this); - oleObject.setProperty(COM.DISPID_FORECOLOR, new Variant(color.handle)); + oleObject.setProperty(COM.DISPID_FORECOLOR, new Variant(cast(int)color.handle)); oleObject.dispose(); } } @@ -890,4 +853,57 @@ sitePropertyValues = newSitePropertyValues; } } -++/ + +class _IDispatchImpl : IDispatch { + + OleControlSite parent; + this(OleControlSite p) { parent = p; } +extern (Windows): + // interface of IUnknown + HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } + + // interface of IDispatch : IUnknown + HRESULT GetTypeInfoCount(UINT * pctinfo) { return COM.E_NOTIMPL; } + HRESULT GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo * ppTInfo) { return COM.E_NOTIMPL; } + HRESULT GetIDsOfNames(REFIID riid, LPOLESTR * rgszNames, UINT cNames, LCID lcid, DISPID * rgDispId) { return COM.E_NOTIMPL; } + // Note : <Shawn> one argument is short !!! + HRESULT Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS* pDispParams,VARIANT* pVarResult,EXCEPINFO* pExcepInfo,UINT* puArgErr) { + return parent.Invoke(dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + } +} + +class _IOleControlSiteImpl : IOleControlSite { + + OleControlSite parent; + this(OleControlSite p) { parent = p; } +extern (Windows): + // interface of IUnknown + HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } + + // interface IOleControlSite : IUnknown + HRESULT OnControlInfoChanged() { return parent.OnControlInfoChanged();} + HRESULT LockInPlaceActive(BOOL fLock) { return COM.E_NOTIMPL; } + HRESULT GetExtendedControl(LPDISPATCH* ppDisp) { return COM.E_NOTIMPL; } + HRESULT TransformCoords( + POINT* pPtlHimetric , //Address of POINTL structure + POINTF* pPtfContainer , //Address of POINTF structure + DWORD dwFlags //Flags indicating the exact conversion + ) { return COM.E_NOTIMPL; } + HRESULT TranslateAccelerator( + LPMSG pMsg , //Pointer to the structure + DWORD grfModifiers //Flags describing the state of the keys + ) + { return COM.E_NOTIMPL; } + HRESULT OnFocus( + BOOL fGotFocus //Indicates whether the control gained focus + ) + { return COM.S_OK; } + HRESULT ShowPropertyFrame() { return COM.E_NOTIMPL; } +} + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleEvent.d Sat Feb 09 03:36:27 2008 +0100 @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.ole.win32.OleEvent; + +import dwt.ole.win32.Variant; + +import dwt.widgets.Widget; + +public class OleEvent { + public int type; + public Widget widget; + public int detail; + public bool doit = true; + public Variant[] arguments; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleEventSink.d Sat Feb 09 03:36:27 2008 +0100 @@ -0,0 +1,197 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.ole.win32.OleEventSink; + +import dwt.DWT; +import dwt.DWTException; +import dwt.internal.ole.win32.COM; +import dwt.internal.ole.win32.extras; +import dwt.internal.ole.win32.OAIDL; +import dwt.internal.ole.win32.ifs; + +import dwt.ole.win32.OleControlSite; +import dwt.ole.win32.OleEventTable; +import dwt.ole.win32.OleListener; +import dwt.ole.win32.OleEvent; +import dwt.ole.win32.OLE; +import dwt.ole.win32.Variant; + +final class OleEventSink +{ + private OleControlSite widget; + + private _DispatchImpl iDispatch; + private int refCount; + + private IUnknown objIUnknown; + private int eventCookie; + private GUID* eventGuid; + + private OleEventTable eventTable; + +this(OleControlSite widget, IUnknown iUnknown, GUID* riid) { + + this.widget = widget; + this.eventGuid = riid; + this.objIUnknown = iUnknown; + + createCOMInterfaces(); +} + +void connect () { + IConnectionPointContainer cpc; + if (objIUnknown.QueryInterface(&COM.IIDIConnectionPointContainer, cast(void**)&cpc) is COM.S_OK) { + IConnectionPoint cp; + if (cpc.FindConnectionPoint(eventGuid, &cp) is COM.S_OK) { + uint pCookie; + if (cp.Advise(iDispatch, &pCookie) is COM.S_OK) + eventCookie = pCookie; + cp.Release(); + } + cpc.Release(); + } +} +void addListener(int eventID, OleListener listener) { + if (listener is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) eventTable = new OleEventTable (); + eventTable.hook(eventID, listener); +} +int AddRef() { + refCount++; + return refCount; +} +private void createCOMInterfaces() { + iDispatch = new _DispatchImpl(this); +} +void disconnect() { + // disconnect event sink + if (eventCookie !is 0 && objIUnknown !is null) { + IConnectionPointContainer cpc; + if (objIUnknown.QueryInterface(&COM.IIDIConnectionPointContainer, cast(void**)&cpc) is COM.S_OK) { + IConnectionPoint cp; + if (cpc.FindConnectionPoint(eventGuid, &cp) is COM.S_OK) { + if (cp.Unadvise(eventCookie) is COM.S_OK) { + eventCookie = 0; + } + cp.Release(); + } + cpc.Release(); + } + } +} +private void disposeCOMInterfaces() { + iDispatch = null; +} + +private HRESULT Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS* pDispParams,VARIANT* pVarResult,EXCEPINFO* pExcepInfo,UINT* puArgErr) +{ + if (eventTable is null || !eventTable.hooks(dispIdMember)) return COM.S_OK; + + // Construct an array of the parameters that are passed in + // Note: parameters are passed in reverse order - here we will correct the order + Variant[] eventInfo = null; + if (pDispParams !is null) { + DISPPARAMS* dispParams = new DISPPARAMS(); + COM.MoveMemory(dispParams, pDispParams, DISPPARAMS.sizeof); + eventInfo = new Variant[dispParams.cArgs]; + int size = Variant.sizeof; + int offset = (dispParams.cArgs - 1) * size; + + for (int j = 0; j < dispParams.cArgs; j++){ + eventInfo[j] = new Variant(); + eventInfo[j].setData(dispParams.rgvarg + offset); + offset = offset - size; + } + } + + OleEvent event = new OleEvent(); + event.arguments = eventInfo; + notifyListener(dispIdMember,event); + return COM.S_OK; +} +/** +* Notify listeners of an event. +* <p> +* This method notifies all listeners that an event +* has occurred. +* +* @param eventType the desired DWT event +* @param event the event data +* +* @exception IllegalArgumentException <ul> +* <li>ERROR_NULL_ARGUMENT when handler is null</li> +* </ul> +* @exception DWTException <ul> +* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> +* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> +* </ul> +*/ +private void notifyListener (int eventType, OleEvent event) { + if (event is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + event.type = eventType; + event.widget = widget; + eventTable.sendEvent (event); +} + +private HRESULT QueryInterface(REFIID riid, void ** ppvObject) { + + if (riid is null || ppvObject is null) + return COM.E_INVALIDARG; + + if ( COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIDispatch) || + COM.IsEqualGUID(riid, eventGuid)) { + *ppvObject = cast(void*)iDispatch; + AddRef(); + return OLE.S_OK; + } + + *ppvObject = null; + return COM.E_NOINTERFACE; +} +int Release() { + refCount--; + if (refCount is 0) { + disposeCOMInterfaces(); + } + + return refCount; +} +void removeListener(int eventID, OleListener listener) { + if (listener is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (eventID, listener); +} +bool hasListeners() { + return eventTable.hasEntries(); +} +} + +private class _DispatchImpl : IDispatch { + + OleEventSink parent; + this(OleEventSink sink) { parent = sink;} +extern (Windows) : + HRESULT QueryInterface(REFIID riid, void ** ppvObject){ + return parent.QueryInterface(riid, ppvObject); + } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } + HRESULT GetTypeInfoCount(UINT * pctinfo) { return COM.E_NOTIMPL; } + HRESULT GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo * ppTInfo) { return COM.E_NOTIMPL; } + HRESULT GetIDsOfNames(REFIID riid, LPOLESTR * rgszNames, UINT cNames, LCID lcid, DISPID * rgDispId) { return COM.E_NOTIMPL; } + HRESULT Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS* pDispParams,VARIANT* pVarResult,EXCEPINFO* pExcepInfo,UINT* puArgErr){ + return parent.Invoke(dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleEventTable.d Sat Feb 09 03:36:27 2008 +0100 @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.ole.win32.OleEventTable; + +import dwt.ole.win32.OleListener; +import dwt.ole.win32.OleEvent; + +import dwt.dwthelper.utils; + +/** +* The OleEventTable class implements a simple +* look up mechanism that maps an event type +* to a listener. Multiple listeners for the +* same event type are supported. +* +*/ + +class OleEventTable { + int [] types; + OleListener [] handlers; +void hook (int eventType, OleListener handler) { + if (types is null) types = new int [4]; + if (handlers is null) handlers = new OleListener [4]; + for (int i=0; i<types.length; i++) { + if (types [i] is 0) { + types [i] = eventType; + handlers [i] = handler; + return; + } + } + int size = types.length; + int [] newTypes = new int [size + 4]; + OleListener [] newHandlers = new OleListener [size + 4]; + System.arraycopy (types, 0, newTypes, 0, size); + SimpleType!(OleListener).arraycopy (handlers, 0, newHandlers, 0, size); + types = newTypes; handlers = newHandlers; + types [size] = eventType; handlers [size] = handler; +} +bool hooks (int eventType) { + if (handlers is null) return false; + for (int i=0; i<types.length; i++) { + if (types [i] is eventType) return true; + } + return false; +} +void sendEvent (OleEvent event) { + if (handlers is null) return; + for (int i=0; i<types.length; i++) { + if (types [i] is event.type) { + OleListener listener = handlers [i]; + if (listener !is null) listener.handleEvent (event); + } + } +} +void unhook (int eventType, OleListener handler) { + if (handlers is null) return; + for (int i=0; i<types.length; i++) { + if ((types [i] is eventType) && (handlers [i] is handler)) { + types [i] = 0; + handlers [i] = null; + return; + } + } +} +bool hasEntries() { + for (int i=0; i<types.length; i++) { + if (types[i] !is 0) return true; + } + return false; +} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleFrame.d Sat Feb 09 03:36:27 2008 +0100 @@ -0,0 +1,841 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.ole.win32.OleFrame; + +import dwt.DWT; +import dwt.DWTException; +import dwt.internal.ole.win32.COM; +import dwt.internal.ole.win32.OLEIDL; +import dwt.internal.ole.win32.extras; +import dwt.internal.win32.OS; +import dwt.widgets.Composite; +import dwt.widgets.Control; +import dwt.widgets.Display; +import dwt.widgets.Event; +import dwt.widgets.Listener; +import dwt.widgets.Menu; +import dwt.widgets.MenuItem; +import dwt.widgets.Shell; +import dwt.widgets.Widget; + +import dwt.ole.win32.OleClientSite; +import dwt.ole.win32.OLE; + +import dwt.dwthelper.utils; +import dwt.dwthelper.Runnable; +import tango.core.Array; + +/** + * + * OleFrame is an OLE Container's top level frame. + * + * <p>This object implements the OLE Interfaces IUnknown and IOleInPlaceFrame + * + * <p>OleFrame allows the container to do the following: <ul> + * <li>position and size the ActiveX Control or OLE Document within the application + * <li>insert menu items from the application into the OLE Document's menu + * <li>activate and deactivate the OLE Document's menus + * <li>position the OLE Document's menu in the application + * <li>translate accelerator keystrokes intended for the container's frame</ul> + * + * <dl> + * <dt><b>Styles</b> <dd>BORDER + * <dt><b>Events</b> <dd>Dispose, Move, Resize + * </dl> + * + */ +final public class OleFrame : Composite +{ + // Interfaces for this Ole Client Container + //private COMObject iUnknown; + private _IOleInPlaceFrameImpl iOleInPlaceFrame; + + // Access to the embedded/linked Ole Object + private IOleInPlaceActiveObject objIOleInPlaceActiveObject; + + private OleClientSite currentdoc; + + private int refCount = 0; + + private MenuItem[] fileMenuItems; + private MenuItem[] containerMenuItems; + private MenuItem[] windowMenuItems; + + private Listener listener; + + private static char[] CHECK_FOCUS = "OLE_CHECK_FOCUS"; //$NON-NLS-1$ + private static char[] HHOOK = "OLE_HHOOK"; //$NON-NLS-1$ + private static char[] HHOOKMSG = "OLE_HHOOK_MSG"; //$NON-NLS-1$ + + private static bool ignoreNextKey; + private static const short [] ACCENTS = [ cast(short)'~', '`', '\'', '^', '"']; + + private static const char[] CONSUME_KEY = "org.eclipse.swt.OleFrame.ConsumeKey"; //$NON-NLS-1$ + +/** + * Create an OleFrame child widget using style bits + * to select a particular look or set of properties. + * + * @param parent a composite widget (cannot be null) + * @param style the bitwise OR'ing of widget styles + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when the parent is null + * </ul> + * @exception DWTException <ul> + * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + * </ul> + * + */ +public this(Composite parent, int style) { + super(parent, style); + + createCOMInterfaces(); + + // setup cleanup proc + listener = new class() Listener { + public void handleEvent(Event e) { + switch (e.type) { + case DWT.Activate : onActivate(e); break; + case DWT.Deactivate : onDeactivate(e); break; + case DWT.Dispose : onDispose(e); break; + case DWT.Resize : + case DWT.Move : onResize(e); break; + default : + OLE.error(DWT.ERROR_NOT_IMPLEMENTED); + } + } + }; + + + addListener(DWT.Activate, listener); + addListener(DWT.Deactivate, listener); + addListener(DWT.Dispose, listener); + + // inform inplaceactiveobject whenever frame resizes + addListener(DWT.Resize, listener); + + // inform inplaceactiveobject whenever frame moves + addListener(DWT.Move, listener); + + // Maintain a reference to yourself so that when + // ClientSites close, they don't take the frame away + // with them. + this.AddRef(); + + // Check for focus change + Display display = getDisplay(); + initCheckFocus(display); + initMsgHook(display); +} +private static void initCheckFocus (Display display_) { + if (display_.getData(CHECK_FOCUS) !is null) return; + display_.setData(CHECK_FOCUS, new ArrayWrapperString(CHECK_FOCUS)); + static const int time = 50; + auto timer = new class(display_) Runnable { + Display display; + Control[1] lastFocus; + this( Display display){ this.display = display; } + public void run() { + if (( null !is cast(OleClientSite)lastFocus[0] ) && !lastFocus[0].isDisposed()) { + // ignore popup menus and dialogs + auto hwnd = OS.GetFocus(); + while (hwnd !is null) { + auto ownerHwnd = OS.GetWindow(hwnd, OS.GW_OWNER); + if (ownerHwnd !is null) { + display.timerExec(time, this); + return; + } + hwnd = OS.GetParent(hwnd); + } + } + if (lastFocus[0] is null || lastFocus[0].isDisposed() || !lastFocus[0].isFocusControl()) { + Control currentFocus = display.getFocusControl(); + if ( auto frame = cast(OleFrame)currentFocus ) { + currentFocus = frame.getCurrentDocument(); + } + if (lastFocus[0] !is currentFocus) { + Event event = new Event(); + if (( null !is cast(OleClientSite)lastFocus[0] ) && !lastFocus[0].isDisposed()) { + lastFocus[0].notifyListeners (DWT.FocusOut, event); + } + if (( null !is cast(OleClientSite)currentFocus ) && !currentFocus.isDisposed()) { + currentFocus.notifyListeners(DWT.FocusIn, event); + } + } + lastFocus[0] = currentFocus; + } + display.timerExec(time, this); + } + }; + display_.timerExec(time, timer); +} +private static void initMsgHook(Display display) { + if (display.getData(HHOOK) !is null) return; + //final Callback callback = new Callback(OleFrame.class, "getMsgProc", 3); //$NON-NLS-1$ + //int address = callback.getAddress(); + //if (address is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS); + int threadId = OS.GetCurrentThreadId(); + auto hHook_ = OS.SetWindowsHookEx(OS.WH_GETMESSAGE, &getMsgProc, null, threadId); + if (hHook_ is null) { + //callback.dispose(); + return; + } + display.setData(HHOOK, new ValueWrapperT!(void*)(hHook_)); + display.setData(HHOOKMSG, new ValueWrapperT!(MSG*)(new MSG())); + display.disposeExec(new class(hHook_) Runnable { + void* hHook; + this( void* hHook ){ this.hHook = hHook; } + public void run() { + if (hHook !is null) OS.UnhookWindowsHookEx(hHook); + //if (callback !is null) callback.dispose(); + } + }); +} +static extern(Windows) int getMsgProc(int code, int wParam, int lParam) { + Display display = Display.getCurrent(); + if (display is null) return 0; + auto hHook = cast(ValueWrapperT!(void*))display.getData(HHOOK); + if (hHook is null) return 0; + if (code < 0) { + return OS.CallNextHookEx(hHook.value, code, wParam, lParam); + } + MSG* msg = cast(MSG*)(cast(ValueWrapperT!(MSG*))display.getData(HHOOKMSG)).value; + OS.MoveMemory(msg, lParam, MSG.sizeof); + int message = msg.message; + if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) { + if (display !is null) { + Widget widget = null; + auto hwnd = msg.hwnd; + while (hwnd !is null) { + widget = display.findWidget (hwnd); + if (widget !is null) break; + hwnd = OS.GetParent (hwnd); + } + if (widget !is null && (null !is cast(OleClientSite)widget )) { + OleClientSite site = cast(OleClientSite)widget; + if (site.handle is hwnd) { + bool consumed = false; + /* Allow activeX control to translate accelerators except when a menu is active. */ + int thread = OS.GetWindowThreadProcessId(msg.hwnd, null); + GUITHREADINFO* lpgui = new GUITHREADINFO(); + lpgui.cbSize = GUITHREADINFO.sizeof; + bool rc = cast(bool) OS.GetGUIThreadInfo(thread, lpgui); + int mask = OS.GUI_INMENUMODE | OS.GUI_INMOVESIZE | OS.GUI_POPUPMENUMODE | OS.GUI_SYSTEMMENUMODE; + if (!rc || (lpgui.flags & mask) is 0) { + OleFrame frame = site.frame; + frame.setData(CONSUME_KEY, null); + consumed = frame.translateOleAccelerator(msg); + if (frame.getData(CONSUME_KEY) !is null) consumed = false; + frame.setData(CONSUME_KEY, null); + } + bool accentKey = false; + switch (msg.message) { + case OS.WM_KEYDOWN: + case OS.WM_SYSKEYDOWN: { + if (!OS.IsWinCE) { + switch (msg.wParam) { + case OS.VK_SHIFT: + case OS.VK_MENU: + case OS.VK_CONTROL: + case OS.VK_CAPITAL: + case OS.VK_NUMLOCK: + case OS.VK_SCROLL: + break; + default: { + /* + * Bug in Windows. The high bit in the result of MapVirtualKey() on + * Windows NT is bit 32 while the high bit on Windows 95 is bit 16. + * They should both be bit 32. The fix is to test the right bit. + */ + int mapKey = OS.MapVirtualKey (msg.wParam, 2); + if (mapKey !is 0) { + accentKey = (mapKey & (OS.IsWinNT ? 0x80000000 : 0x8000)) !is 0; + if (!accentKey) { + for (int i=0; i<ACCENTS.length; i++) { + int value = OS.VkKeyScan (ACCENTS [i]); + if (value !is -1 && (value & 0xFF) is msg.wParam) { + int state = value >> 8; + if ((OS.GetKeyState (OS.VK_SHIFT) < 0) is ((state & 0x1) !is 0) && + (OS.GetKeyState (OS.VK_CONTROL) < 0) is ((state & 0x2) !is 0) && + (OS.GetKeyState (OS.VK_MENU) < 0) is ((state & 0x4) !is 0)) { + if ((state & 0x7) !is 0) accentKey = true; + break; + } + } + } + } + } + break; + } + } + } + break; + } + } + /* Allow OleClientSite to process key events before activeX control */ + if (!consumed && !accentKey && !ignoreNextKey) { + auto hwndOld = msg.hwnd; + msg.hwnd = site.handle; + consumed = OS.DispatchMessage (msg) is 1; + msg.hwnd = hwndOld; + } + switch (msg.message) { + case OS.WM_KEYDOWN: + case OS.WM_SYSKEYDOWN: { + switch (msg.wParam) { + case OS.VK_SHIFT: + case OS.VK_MENU: + case OS.VK_CONTROL: + case OS.VK_CAPITAL: + case OS.VK_NUMLOCK: + case OS.VK_SCROLL: + break; + default: { + ignoreNextKey = accentKey; + break; + } + } + } + } + + if (consumed) { + // In order to prevent this message from also being processed + // by the application, zero out message, wParam and lParam + msg.message = OS.WM_NULL; + msg.wParam = msg.lParam = 0; + OS.MoveMemory(lParam, msg, MSG.sizeof); + return 0; + } + } + } + } + } + return OS.CallNextHookEx( hHook.value, code, wParam, lParam); +} +/** + * Increment the count of references to this instance + * + * @return the current reference count + */ +int AddRef() { + refCount++; + return refCount; +} +private int ContextSensitiveHelp(int fEnterMode) { + return COM.S_OK; +} +private void createCOMInterfaces() { + iOleInPlaceFrame = new _IOleInPlaceFrameImpl(this); +} +private void disposeCOMInterfaces () { + iOleInPlaceFrame = null; +} +private HRESULT GetBorder(LPRECT lprectBorder) { + /* + The IOleInPlaceUIWindow::GetBorder function, when called on a document or frame window + object, returns the outer rectangle (relative to the window) where the object can put + toolbars or similar controls. + */ + if (lprectBorder is null) return COM.E_INVALIDARG; + RECT* rectBorder = new RECT(); + // Coordinates must be relative to the window + OS.GetClientRect(handle, lprectBorder); + return COM.S_OK; +} +/** + * + * Returns the application menu items that will appear in the Container location when an OLE Document + * is in-place activated. + * + * <p>When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + * @return the application menu items that will appear in the Container location when an OLE Document + * is in-place activated. + * + */ +public MenuItem[] getContainerMenus(){ + return containerMenuItems; +} +/** + * + * Returns the application menu items that will appear in the File location when an OLE Document + * is in-place activated. + * + * <p>When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + * @return the application menu items that will appear in the File location when an OLE Document + * is in-place activated. + * + */ +public MenuItem[] getFileMenus(){ + return fileMenuItems; +} +IOleInPlaceFrame getIOleInPlaceFrame() { + return iOleInPlaceFrame; +} +private int getMenuItemID(HMENU hMenu, int index) { + int id = 0; + MENUITEMINFO lpmii; + lpmii.cbSize = MENUITEMINFO.sizeof; + lpmii.fMask = OS.MIIM_STATE | OS.MIIM_SUBMENU | OS.MIIM_ID; + OS.GetMenuItemInfo(hMenu, index, true, &lpmii); + if ((lpmii.fState & OS.MF_POPUP) is OS.MF_POPUP) { + id = cast(int)lpmii.hSubMenu; + } else { + id = lpmii.wID; + } + return id; +} +private int GetWindow(HWND* phwnd) { + if (phwnd !is null) { + *phwnd = handle; + } + return COM.S_OK; +} +/** + * + * Returns the application menu items that will appear in the Window location when an OLE Document + * is in-place activated. + * + * <p>When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + * @return the application menu items that will appear in the Window location when an OLE Document + * is in-place activated. + * + */ +public MenuItem[] getWindowMenus(){ + return windowMenuItems; +} +private HRESULT InsertMenus( HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths ) { + // locate menu bar + Menu menubar = getShell().getMenuBar(); + if (menubar is null || menubar.isDisposed()) { + int temp = 0; + COM.MoveMemory(lpMenuWidths, &temp, 4); + return COM.S_OK; + } + HMENU hMenu = menubar.handle; + + // Create a holder for menu information. This will be passed down to + // the OS and the OS will fill in the requested information for each menu. + MENUITEMINFO lpmii; + auto hHeap = OS.GetProcessHeap(); + int cch = 128; + int byteCount = cch * TCHAR.sizeof; + auto pszText = cast(TCHAR*) OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount); + lpmii.cbSize = MENUITEMINFO.sizeof; + lpmii.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_SUBMENU | OS.MIIM_DATA; + lpmii.dwTypeData = pszText; + lpmii.cch = cch; + + // Loop over all "File-like" menus in the menubar and get information about the + // item from the OS. + int fileMenuCount = 0; + int newindex = 0; + if (this.fileMenuItems !is null) { + for (int i = 0; i < this.fileMenuItems.length; i++) { + MenuItem item = this.fileMenuItems[i]; + if (item !is null) { + int index = item.getParent().indexOf(item); + lpmii.cch = cch; // lpmii.cch gets updated by GetMenuItemInfo to indicate the + // exact number of characters in name. Reset it to our max size + // before each call. + if (OS.GetMenuItemInfo(hMenu, index, true, &lpmii)) { + if (OS.InsertMenuItem(hmenuShared, newindex, true, &lpmii)) { + // keep track of the number of items + fileMenuCount++; + newindex++; + } + } + } + } + } + + // copy the menu item count information to the pointer + COM.MoveMemory(lpMenuWidths, &fileMenuCount, 4); + + // Loop over all "Container-like" menus in the menubar and get information about the + // item from the OS. + int containerMenuCount = 0; + if (this.containerMenuItems !is null) { + for (int i = 0; i < this.containerMenuItems.length; i++) { + MenuItem item = this.containerMenuItems[i]; + if (item !is null) { + int index = item.getParent().indexOf(item); + lpmii.cch = cch; // lpmii.cch gets updated by GetMenuItemInfo to indicate the + // exact number of characters in name. Reset it to a large number + // before each call. + if (OS.GetMenuItemInfo(hMenu, index, true, &lpmii)) { + if (OS.InsertMenuItem(hmenuShared, newindex, true, &lpmii)) { + // keep track of the number of items + containerMenuCount++; + newindex++; + } + } + } + } + } + + // copy the menu item count information to the pointer + COM.MoveMemory(lpMenuWidths + 8, &containerMenuCount, 4); + + // Loop over all "Window-like" menus in the menubar and get information about the + // item from the OS. + int windowMenuCount = 0; + if (this.windowMenuItems !is null) { + for (int i = 0; i < this.windowMenuItems.length; i++) { + MenuItem item = this.windowMenuItems[i]; + if (item !is null) { + int index = item.getParent().indexOf(item); + lpmii.cch = cch; // lpmii.cch gets updated by GetMenuItemInfo to indicate the + // exact number of characters in name. Reset it to a large number + // before each call. + if (OS.GetMenuItemInfo(hMenu, index, true, &lpmii)) { + if (OS.InsertMenuItem(hmenuShared, newindex, true, &lpmii)) { + // keep track of the number of items + windowMenuCount++; + newindex++; + } + } + } + } + } + + // copy the menu item count information to the pointer + COM.MoveMemory(lpMenuWidths + 16, &windowMenuCount, 4); + + // free resources used in querying the OS + if (pszText !is null) + OS.HeapFree(hHeap, 0, pszText); + return COM.S_OK; +} +void onActivate(Event e) { + if (objIOleInPlaceActiveObject !is null) { + objIOleInPlaceActiveObject.OnFrameWindowActivate(true); + } + if (objIOleInPlaceActiveObject !is null) { + objIOleInPlaceActiveObject.OnDocWindowActivate(true); + } +} +void onDeactivate(Event e) { + if (objIOleInPlaceActiveObject !is null) { + objIOleInPlaceActiveObject.OnFrameWindowActivate(false); + } + if (objIOleInPlaceActiveObject !is null) { + objIOleInPlaceActiveObject.OnDocWindowActivate(false); + } +} +private void onDispose(Event e) { + + releaseObjectInterfaces(); + currentdoc = null; + + this.Release(); + removeListener(DWT.Activate, listener); + removeListener(DWT.Deactivate, listener); + removeListener(DWT.Dispose, listener); + removeListener(DWT.Resize, listener); + removeListener(DWT.Move, listener); +} +private void onResize(Event e) { + if (objIOleInPlaceActiveObject !is null) { + RECT lpRect; + OS.GetClientRect(handle, &lpRect); + objIOleInPlaceActiveObject.ResizeBorder(&lpRect, iOleInPlaceFrame, true); + } +} +private HRESULT QueryInterface(REFIID riid, void** ppvObject) { +// implements IUnknown, IOleInPlaceFrame, IOleContainer, IOleInPlaceUIWindow + if (riid is null || ppvObject is null) + return COM.E_INVALIDARG; + + if (COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIOleInPlaceFrame) ) { + *ppvObject = cast(void*)iOleInPlaceFrame; + AddRef(); + return COM.S_OK; + } + + *ppvObject = null; + return COM.E_NOINTERFACE; +} +/** + * Decrement the count of references to this instance + * + * @return the current reference count + */ +int Release() { + refCount--; + if (refCount is 0){ + disposeCOMInterfaces(); + COM.CoFreeUnusedLibraries(); + } + return refCount; +} +private void releaseObjectInterfaces() { + if (objIOleInPlaceActiveObject !is null) { + objIOleInPlaceActiveObject.Release(); + } + objIOleInPlaceActiveObject = null; +} +private int RemoveMenus(HMENU hmenuShared) { + + Menu menubar = getShell().getMenuBar(); + if (menubar is null || menubar.isDisposed()) return COM.S_FALSE; + + auto hMenu = menubar.handle; + + int[] ids; + if (this.fileMenuItems !is null) { + for (int i = 0; i < this.fileMenuItems.length; i++) { + MenuItem item = this.fileMenuItems[i]; + if (item !is null && !item.isDisposed()) { + int index = item.getParent().indexOf(item); + // get Id from original menubar + int id = getMenuItemID(hMenu, index); + ids ~= id; + } + } + } + if (this.containerMenuItems !is null) { + for (int i = 0; i < this.containerMenuItems.length; i++) { + MenuItem item = this.containerMenuItems[i]; + if (item !is null && !item.isDisposed()) { + int index = item.getParent().indexOf(item); + int id = getMenuItemID(hMenu, index); + ids ~= id; + } + } + } + if (this.windowMenuItems !is null) { + for (int i = 0; i < this.windowMenuItems.length; i++) { + MenuItem item = this.windowMenuItems[i]; + if (item !is null && !item.isDisposed()) { + int index = item.getParent().indexOf(item); + int id = getMenuItemID(hMenu, index); + ids ~= id; + } + } + } + int index = OS.GetMenuItemCount(hmenuShared) - 1; + for (int i = index; i >= 0; i--) { + int id = getMenuItemID(hmenuShared, i); + if ( ids.contains(id)){ + OS.RemoveMenu(hmenuShared, i, OS.MF_BYPOSITION); + } + } + return COM.S_OK; +} +private int RequestBorderSpace(LPCBORDERWIDTHS pborderwidths) { + return COM.S_OK; +} +HRESULT SetActiveObject( LPOLEINPLACEACTIVEOBJECT pActiveObject, LPCOLESTR pszObjName ) { + if (objIOleInPlaceActiveObject !is null) { + objIOleInPlaceActiveObject.Release(); + objIOleInPlaceActiveObject = null; + } + if (pActiveObject !is null) { + objIOleInPlaceActiveObject = pActiveObject; + objIOleInPlaceActiveObject.AddRef(); + } + + return COM.S_OK; +} + +private HRESULT SetBorderSpace( LPCBORDERWIDTHS pborderwidths ) { + // A Control/Document can : + // Use its own toolbars, requesting border space of a specific size, or, + // Use no toolbars, but force the container to remove its toolbars by passing a + // valid BORDERWIDTHS structure containing nothing but zeros in the pborderwidths parameter, or, + // Use no toolbars but allow the in-place container to leave its toolbars up by + // passing NULL as the pborderwidths parameter. + if (objIOleInPlaceActiveObject is null) return COM.S_OK; + RECT* borderwidth = new RECT(); + if (pborderwidths is null || currentdoc is null ) return COM.S_OK; + + COM.MoveMemory(borderwidth, pborderwidths, RECT.sizeof); + currentdoc.setBorderSpace(borderwidth); + + return COM.S_OK; +} +/** + * + * Specify the menu items that should appear in the Container location when an OLE Document + * is in-place activated. + * + * <p>When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + * <p>This method must be called before in place activation of the OLE Document. After the Document + * is activated, the menu bar will not be modified until a subsequent activation. + * + * @param containerMenus an array of top level MenuItems to be inserted into the Container location of + * the menubar + */ +public void setContainerMenus(MenuItem[] containerMenus){ + containerMenuItems = containerMenus; +} +OleClientSite getCurrentDocument() { + return currentdoc; +} +void setCurrentDocument(OleClientSite doc) { + currentdoc = doc; + + if (currentdoc !is null && objIOleInPlaceActiveObject !is null) { + RECT lpRect; + OS.GetClientRect(handle, &lpRect); + objIOleInPlaceActiveObject.ResizeBorder(&lpRect, iOleInPlaceFrame, true); + } +} +/** + * + * Specify the menu items that should appear in the File location when an OLE Document + * is in-place activated. + * + * <p>When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + * <p>This method must be called before in place activation of the OLE Document. After the Document + * is activated, the menu bar will not be modified until a subsequent activation. + * + * @param fileMenus an array of top level MenuItems to be inserted into the File location of + * the menubar + */ +public void setFileMenus(MenuItem[] fileMenus){ + fileMenuItems = fileMenus; +} +HRESULT SetMenu( HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject ) { + IOleInPlaceActiveObject inPlaceActiveObject; + if (objIOleInPlaceActiveObject !is null) + inPlaceActiveObject = objIOleInPlaceActiveObject; + + Menu menubar = getShell().getMenuBar(); + if (menubar is null || menubar.isDisposed()){ + return COM.OleSetMenuDescriptor(null, getShell().handle, hwndActiveObject, iOleInPlaceFrame, inPlaceActiveObject); + } + + HWND handle = menubar.getShell().handle; + + if (hmenuShared is null && holemenu is null) { + // re-instate the original menu - this occurs on deactivation + hmenuShared = menubar.handle; + } + if (hmenuShared is null) return COM.E_FAIL; + + OS.SetMenu(handle, hmenuShared); + OS.DrawMenuBar(handle); + + return COM.OleSetMenuDescriptor(holemenu, handle, hwndActiveObject, iOleInPlaceFrame, inPlaceActiveObject); +} + +/** + * + * Set the menu items that should appear in the Window location when an OLE Document + * is in-place activated. + * + * <p>When an OLE Document is in-place active, the Document provides its own menus but the application + * is given the opportunity to merge some of its menus into the menubar. The application + * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window + * (far right just before Help). The OLE Document retains control of the Edit, Object and Help + * menu locations. Note that an application can insert more than one menu into a single location. + * + * <p>This method must be called before in place activation of the OLE Document. After the Document + * is activated, the menu bar will not be modified until a subsequent activation. + * + * @param windowMenus an array of top level MenuItems to be inserted into the Window location of + * the menubar + */ +public void setWindowMenus(MenuItem[] windowMenus){ + windowMenuItems = windowMenus; +} +private bool translateOleAccelerator(MSG* msg) { + if (objIOleInPlaceActiveObject is null) return false; + int result = objIOleInPlaceActiveObject.TranslateAccelerator(msg); + return (result != COM.S_FALSE && result != COM.E_NOTIMPL); +} + +HRESULT TranslateAccelerator( LPMSG lpmsg, WORD wID ){ + Menu menubar = getShell().getMenuBar(); + if (menubar is null || menubar.isDisposed() || !menubar.isEnabled()) return COM.S_FALSE; + if (wID < 0) return COM.S_FALSE; + + Shell shell = menubar.getShell(); + HWND hwnd = shell.handle; + HACCEL hAccel = cast(HACCEL)OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0); + if (hAccel is null) return COM.S_FALSE; + + MSG msg = *lpmsg; + int result = OS.TranslateAccelerator(hwnd, hAccel, &msg); + return result == 0 ? COM.S_FALSE : COM.S_OK; +} +} + +// implements IOleInPlaceFrame, IOleInPlaceUIWindow, IOleWindow, IUnknown +class _IOleInPlaceFrameImpl : IOleInPlaceFrame { + + OleFrame parent; + this(OleFrame p) { parent = p; } +extern (Windows) : + // interface of IUnknown + HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } + + // interface IOleWindow + HRESULT GetWindow( HWND * phwnd ) { return parent.GetWindow(phwnd); } + HRESULT ContextSensitiveHelp( BOOL fEnterMode ){ return COM.S_OK; } + + //interface IOleInPlaceUIWindow + HRESULT GetBorder( LPRECT lprectBorder ) { return parent.GetBorder(lprectBorder); } + HRESULT RequestBorderSpace( LPCBORDERWIDTHS pborderwidths ){ return COM.S_OK; } + HRESULT SetBorderSpace( LPCBORDERWIDTHS pborderwidths ) { return parent.SetBorderSpace(pborderwidths); } + HRESULT SetActiveObject( LPOLEINPLACEACTIVEOBJECT pActiveObject, LPCOLESTR pszObjName ) { + return parent.SetActiveObject(pActiveObject, pszObjName); + } + + // interface IOleInPlaceFrame : IOleInPlaceUIWindow + HRESULT InsertMenus( HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths ){ + return parent.InsertMenus(hmenuShared, lpMenuWidths); + } + HRESULT SetMenu( HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject ){ + return parent.SetMenu(hmenuShared, holemenu, hwndActiveObject); + } + HRESULT RemoveMenus( HMENU hmenuShared ) { + return parent.RemoveMenus(hmenuShared); + } + HRESULT SetStatusText( LPCOLESTR pszStatusText ) { return COM.E_NOTIMPL; } + HRESULT EnableModeless( BOOL fEnable ) { return COM.E_NOTIMPL; } + HRESULT TranslateAccelerator( LPMSG lpmsg, WORD wID ) { + return parent.TranslateAccelerator(lpmsg, wID); + } + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleFunctionDescription.d Sat Feb 09 03:36:27 2008 +0100 @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.ole.win32.OleFunctionDescription; + +import dwt.ole.win32.OleParameterDescription; + +public class OleFunctionDescription { + + public int id; + public char[] name; + public OleParameterDescription[] args; + public int optionalArgCount; + public short returnType; + public int invokeKind; + public int funcKind; + public short flags; + public int callingConvention; + public char[] documentation; + public char[] helpFile; + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleListener.d Sat Feb 09 03:36:27 2008 +0100 @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.ole.win32.OleListener; + +import dwt.ole.win32.OleEvent; + +/** + */ +public interface OleListener +{ +/** + * + */ +public void handleEvent(OleEvent event); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleParameterDescription.d Sat Feb 09 03:36:27 2008 +0100 @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.ole.win32.OleParameterDescription; + + +public class OleParameterDescription { + public char[] name; + public short flags; + public short type; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OlePropertyChangeSink.d Sat Feb 09 03:36:27 2008 +0100 @@ -0,0 +1,181 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.ole.win32.OlePropertyChangeSink; + + +import dwt.DWT; +import dwt.DWTException; +import dwt.internal.ole.win32.COM; +import dwt.internal.ole.win32.extras; +import dwt.internal.ole.win32.ifs; + +import dwt.ole.win32.OleControlSite; +import dwt.ole.win32.OleEventTable; +import dwt.ole.win32.OleListener; +import dwt.ole.win32.OleEvent; +import dwt.ole.win32.OleEventTable; +import dwt.ole.win32.OLE; + +final class OlePropertyChangeSink { + + private OleControlSite controlSite; + //private IUnknown objIUnknown; + + //private COMObject iUnknown; + private _IPropertyNotifySinkImpl iPropertyNotifySink; + + private int refCount; + + private int propertyCookie; + + private OleEventTable eventTable; + +this(OleControlSite controlSite) { + + this.controlSite = controlSite; + + createCOMInterfaces(); +} +void addListener(int propertyID, OleListener listener) { + if (listener is null) OLE.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) eventTable = new OleEventTable (); + eventTable.hook(propertyID, listener); +} +int AddRef() { + refCount++; + return refCount; +} +void connect(IUnknown objIUnknown) { + + // Set up property change notification sink + IConnectionPointContainer cpc; + if (objIUnknown.QueryInterface(&COM.IIDIConnectionPointContainer, cast(void**)&cpc) is COM.S_OK) { + IConnectionPoint cp; + if (cpc.FindConnectionPoint(&COM.IIDIPropertyNotifySink, &cp) is COM.S_OK) { + uint cookie; + if (cp.Advise(iPropertyNotifySink, &cookie) is COM.S_OK) { + propertyCookie = cookie; + } + cp.Release(); + } + cpc.Release(); + } +} +protected void createCOMInterfaces() { + // register each of the interfaces that this object implements + iPropertyNotifySink = new _IPropertyNotifySinkImpl(this); +} +void disconnect(IUnknown objIUnknown) { + + // disconnect property notification sink + if (propertyCookie !is 0 && objIUnknown !is null) { + IConnectionPointContainer cpc; + if (objIUnknown.QueryInterface(&COM.IIDIConnectionPointContainer, cast(void**)&cpc) is COM.S_OK) { + IConnectionPoint cp; + if (cpc.FindConnectionPoint(&COM.IIDIPropertyNotifySink, &cp) is COM.S_OK) { + if (cp.Unadvise(propertyCookie) is COM.S_OK) { + propertyCookie = 0; + } + cp.Release(); + } + cpc.Release(); + } + } +} +private void disposeCOMInterfaces() { + iPropertyNotifySink = null; +} +/** +* Notify listeners of an event. +* <p> +* This method notifies all listeners that an event +* has occurred. +* +* @param eventType the desired DWT event +* @param event the event data +* +* @exception IllegalArgumentException <ul> +* <li>ERROR_NULL_ARGUMENT when handler is null</li> +* </ul> +* @exception DWTException <ul> +* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> +* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> +* </ul> +*/ +private void notifyListener (int eventType, OleEvent event) { + if (event is null) OLE.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + event.type = eventType; + event.widget = controlSite; + eventTable.sendEvent (event); +} +package int OnChanged(int dispID) { + if (eventTable is null || !eventTable.hooks(dispID)) return COM.S_OK; + OleEvent event = new OleEvent(); + event.detail = OLE.PROPERTY_CHANGED; + notifyListener(dispID,event); + return COM.S_OK; +} +package int OnRequestEdit(int dispID) { + if (eventTable is null || !eventTable.hooks(dispID)) return COM.S_OK; + OleEvent event = new OleEvent(); + event.doit = true; + event.detail = OLE.PROPERTY_CHANGING; + notifyListener(dispID,event); + return (event.doit) ? COM.S_OK : COM.S_FALSE; +} +protected HRESULT QueryInterface(REFIID riid, void ** ppvObject) { + if (riid is null || ppvObject is null) + return COM.E_INVALIDARG; + + if (COM.IsEqualGUID(riid, &COM.IIDIPropertyNotifySink)) { + *ppvObject = cast(void*)iPropertyNotifySink; + AddRef(); + return COM.S_OK; + } + *ppvObject = null; + return COM.E_NOINTERFACE; +} +int Release() { + refCount--; + if (refCount is 0) { + disposeCOMInterfaces(); + } + return refCount; +} +void removeListener(int propertyID, OleListener listener) { + if (listener is null) OLE.error (__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (propertyID, listener); +} +} + + +private class _IPropertyNotifySinkImpl : IPropertyNotifySink { + + OlePropertyChangeSink parent; + this(OlePropertyChangeSink p) { parent = p; } +extern (Windows): + // interface of IUnknown + HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } + ULONG AddRef() { return parent.AddRef(); } + ULONG Release() { return parent.Release(); } + + // interface of IPropertyNotifySink + int OnChanged(int dispID) { return parent.OnChanged(dispID); } + int OnRequestEdit(int dispID) { return parent.OnRequestEdit(dispID); } +} + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OlePropertyDescription.d Sat Feb 09 03:36:27 2008 +0100 @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.ole.win32.OlePropertyDescription; + + +public class OlePropertyDescription { + public int id; + public char[] name; + public int type; + public int flags; + public int kind; + public char[] description; + public char[] helpFile; +}
--- a/dwt/ole/win32/Variant.d Fri Feb 08 19:49:32 2008 +0100 +++ b/dwt/ole/win32/Variant.d Sat Feb 09 03:36:27 2008 +0100 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> *******************************************************************************/ module dwt.ole.win32.Variant; @@ -278,30 +280,27 @@ */ public OleAutomation getAutomation() { if (type is COM.VT_EMPTY) { - OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); } if (type is COM.VT_DISPATCH) { return new OleAutomation(dispatchData); } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - HRESULT result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_DISPATCH); + getData(&oldPtr); + HRESULT result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_DISPATCH); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant autoVar = new Variant(); - autoVar.setData(newPtr); + autoVar.setData(&newPtr); return autoVar.getAutomation(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); // Note: This must absolutely be done AFTER the // OleAutomation object is created as Variant Clear // will result in a Release being performed on the // Dispatch object - OS.GlobalFree(newPtr); } } /** @@ -321,30 +320,28 @@ */ public IDispatch getDispatch() { if (type is COM.VT_EMPTY) { - OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); } + if (type is COM.VT_DISPATCH) { return dispatchData; } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_DISPATCH); + getData(&oldPtr); + HRESULT result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_DISPATCH); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant autoVar = new Variant(); - autoVar.setData(newPtr); + autoVar.setData(&newPtr); return autoVar.getDispatch(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); // Note: This must absolutely be done AFTER the // OleAutomation object is created as Variant Clear // will result in a Release being performed on the // Dispatch object - OS.GlobalFree(newPtr); } } /** @@ -362,28 +359,24 @@ */ public bool getBoolean() { if (type is COM.VT_EMPTY) { - OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); } if (type is COM.VT_BOOL) { return booleanData; } - // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_BOOL); + getData(&oldPtr); + HRESULT result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_BOOL); if (result !is COM.S_OK) - OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + OLE.error(__FILE__, __LINE__, OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant boolVar = new Variant(); - boolVar.setData(newPtr); + boolVar.setData(&newPtr); return boolVar.getBoolean(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); - OS.GlobalFree(newPtr); + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); } } /** @@ -427,21 +420,18 @@ } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_I1); + getData(&oldPtr); + int result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_I1); if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant byteVar = new Variant(); - byteVar.setData(newPtr); + byteVar.setData(&newPtr); return byteVar.getByte(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); - OS.GlobalFree(newPtr); + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); } } /** @@ -467,21 +457,18 @@ } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_UI2); + getData(&oldPtr); + int result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_UI2); if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant charVar = new Variant(); - charVar.setData(newPtr); + charVar.setData(&newPtr); return charVar.getChar(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); - OS.GlobalFree(newPtr); + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); } } void getData(VARIANT* pData){ @@ -581,21 +568,18 @@ } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_R8); + getData(&oldPtr); + int result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_R8); if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant doubleVar = new Variant(); - doubleVar.setData(newPtr); + doubleVar.setData(&newPtr); return doubleVar.getDouble(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); - OS.GlobalFree(newPtr); + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); } } @@ -620,21 +604,18 @@ } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_R4); + getData(&oldPtr); + int result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_R4); if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant floatVar = new Variant(); - floatVar.setData(newPtr); + floatVar.setData(&newPtr); return floatVar.getFloat(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); - OS.GlobalFree(newPtr); + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); } } @@ -659,21 +640,18 @@ } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_I4); + getData(&oldPtr); + int result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_I4); if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant intVar = new Variant(); - intVar.setData(newPtr); + intVar.setData(&newPtr); return intVar.getInt(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); - OS.GlobalFree(newPtr); + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); } } /** @@ -699,21 +677,18 @@ } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_I8); + getData(&oldPtr); + int result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_I8); if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant longVar = new Variant(); - longVar.setData(newPtr); + longVar.setData(&newPtr); return longVar.getLong(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); - OS.GlobalFree(newPtr); + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); } } /** @@ -737,21 +712,18 @@ } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_I2); + getData(&oldPtr); + int result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_I2); if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant shortVar = new Variant(); - shortVar.setData(newPtr); + shortVar.setData(&newPtr); return shortVar.getShort(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); - OS.GlobalFree(newPtr); + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); } } @@ -776,23 +748,20 @@ } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_BSTR); + getData(&oldPtr); + int result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_BSTR); if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant stringVar = new Variant(); - stringVar.setData(newPtr); + stringVar.setData(&newPtr); return stringVar.getString(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); - OS.GlobalFree(newPtr); + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); } } /** @@ -830,24 +799,21 @@ } // try to coerce the value to the desired type - auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); - auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + VARIANT oldPtr, newPtr; try { - getData(oldPtr); - int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_UNKNOWN); + getData(&oldPtr); + int result = COM.VariantChangeType(&newPtr, &oldPtr, 0, COM.VT_UNKNOWN); if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); Variant unknownVar = new Variant(); - unknownVar.setData(newPtr); + unknownVar.setData(&newPtr); return unknownVar.getUnknown(); } finally { - COM.VariantClear(oldPtr); - OS.GlobalFree(oldPtr); - COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the + COM.VariantClear(&oldPtr); + COM.VariantClear(&newPtr); // Note: This must absolutely be done AFTER the // IUnknown object is created as Variant Clear // will result in a Release being performed on the // Dispatch object - OS.GlobalFree(newPtr); } } /**
--- a/tango_sys_win32/Types.d Fri Feb 08 19:49:32 2008 +0100 +++ b/tango_sys_win32/Types.d Sat Feb 09 03:36:27 2008 +0100 @@ -163,13 +163,13 @@ alias uint WPARAM; alias int ACL_INFORMATION_CLASS; -struct GUID { // size is 16 -align(1): - DWORD Data1; - WORD Data2; - WORD Data3; - BYTE[8] Data4; -} +// struct GUID { // size is 16 +// align(1): +// DWORD Data1; +// WORD Data2; +// WORD Data3; +// BYTE[8] Data4; +// } enum { AclRevisionInformation = 1, AclSizeInformation, }; alias ACL_INFORMATION_CLASS _ACL_INFORMATION_CLASS; @@ -10993,6 +10993,7 @@ alias __GUID* LPGUID; alias __GUID _GUID; +alias __GUID GUID; alias __GUID TGUID; alias __GUID* PGUID; alias __GUID __CLSID;