示例#1
0
        /// <summary>
        /// Queries MSHTML for the command info (enabled and checked) for the specified command
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        protected internal HtmlCommandInfo GetCommandInfo(int command)
        {
            //First query the command target for the command status
            int info;

            Interop.tagOLECMD oleCommand = new Interop.tagOLECMD();

            //Create an tagOLDCMD to store the command and receive the result
            oleCommand.cmdID = command;
            int hr = CommandTarget.QueryStatus(ref Interop.Guid_MSHTML, 1, oleCommand, 0);

            Debug.Assert(hr == Interop.S_OK, "IOleCommand.QueryStatus did not return S_OK");

            //Then translate the response from the command status
            //We can just right shift by one to eliminate the supported flag from OLECMDF
            info = oleCommand.cmdf;
            //REVIEW: Do we want to do a mapping instead of playing with the bits?
            return((HtmlCommandInfo)(info >> 1) & (HtmlCommandInfo.Enabled | HtmlCommandInfo.Checked));
        }