private static void ShowHTMLFile(Control parent, string url, HelpNavigator command, object param) { Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHTMLHelp:: " + url + ", " + command.ToString("G") + ", " + param); Uri file = Resolve(url); if (file == null) { throw new ArgumentException(string.Format(SR.HelpInvalidURL, url), "url"); } switch (command) { case HelpNavigator.TableOfContents: case HelpNavigator.Find: case HelpNavigator.Index: // nothing needed... // break; case HelpNavigator.Topic: if (param != null && param is string) { file = new Uri(file.ToString() + "#" + (string)param); } break; } HandleRef handle; if (parent != null) { handle = new HandleRef(parent, parent.Handle); } else { handle = new HandleRef(null, UnsafeNativeMethods.GetActiveWindow()); } Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "\tExecuting '" + file.ToString() + "'"); UnsafeNativeMethods.ShellExecute_NoBFM(handle, null, file.ToString(), null, null, NativeMethods.SW_NORMAL); }
/// <include file='doc\Help.uex' path='docs/doc[@for="Help.ShowHTML10Help"]/*' /> /// <devdoc> /// Displays HTML 1.0 Help with the specified parameters /// </devdoc> /// <internalonly/> private static void ShowHTML10Help(Control parent, string url, HelpNavigator command, object param) { Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHTML10Help:: " + url + ", " + command.ToString("G") + ", " + param); // See if we can get a full path and file name and if that will // resolve the out of memory condition with file names that include spaces. // If we can't, though, we can't assume that the path's no good: it might be in // the Windows help directory. Uri file = null; string pathAndFileName = url; //This is our best guess at the path yet. file = Resolve(url); if (file != null) // Can't assume we have a good url { pathAndFileName = file.AbsoluteUri; } if (file == null || file.IsFile) { StringBuilder newPath = new StringBuilder(); string localPath = (file != null && file.IsFile) ? file.LocalPath : url; // If this is a local path, convert it to a short path name. Pass 0 as the length the first time uint requiredStringSize = UnsafeNativeMethods.GetShortPathName(localPath, newPath, 0); if (requiredStringSize > 0) { //It's able to make it a short path. Happy day. newPath.Capacity = (int)requiredStringSize; requiredStringSize = UnsafeNativeMethods.GetShortPathName(localPath, newPath, requiredStringSize); //If it can't make it a short path, just leave the path we had. pathAndFileName = newPath.ToString(); } } HandleRef handle; if (parent != null) { handle = new HandleRef(parent, parent.Handle); } else { handle = new HandleRef(null, UnsafeNativeMethods.GetActiveWindow()); } object htmlParam; string stringParam = param as string; if (stringParam != null) { int htmlCommand = MapCommandToHTMLCommand(command, stringParam, out htmlParam); string stringHtmlParam = htmlParam as string; if (stringHtmlParam != null) { SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, stringHtmlParam); } else if (htmlParam is int) { SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, (int)htmlParam); } else if (htmlParam is NativeMethods.HH_FTS_QUERY) { SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, (NativeMethods.HH_FTS_QUERY)htmlParam); } else if (htmlParam is NativeMethods.HH_AKLINK) { // According to MSDN documentation, we have to ensure that the help window is up // before we call ALINK lookup. // SafeNativeMethods.HtmlHelp(NativeMethods.NullHandleRef, pathAndFileName, HH_DISPLAY_TOPIC, (string)null); SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, (NativeMethods.HH_AKLINK)htmlParam); } else { Debug.Fail("Cannot handle HTML parameter of type: " + htmlParam.GetType()); SafeNativeMethods.HtmlHelp(handle, pathAndFileName, htmlCommand, (string)param); } } else if (param == null) { SafeNativeMethods.HtmlHelp(handle, pathAndFileName, MapCommandToHTMLCommand(command, null, out htmlParam), 0); } else if (param is NativeMethods.HH_POPUP) { SafeNativeMethods.HtmlHelp(handle, pathAndFileName, HH_DISPLAY_TEXT_POPUP, (NativeMethods.HH_POPUP)param); } else if (param.GetType() == typeof(int)) { throw new ArgumentException(string.Format(SR.InvalidArgument, "param", "Integer")); } }
private unsafe static void ShowHTML10Help(Control parent, string url, HelpNavigator command, object param) { Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHTML10Help:: " + url + ", " + command.ToString("G") + ", " + param); // See if we can get a full path and file name and if that will // resolve the out of memory condition with file names that include spaces. // If we can't, though, we can't assume that the path's no good: it might be in // the Windows help directory. Uri file = null; string pathAndFileName = url; //This is our best guess at the path yet. file = Resolve(url); if (file != null) { // Can't assume we have a good url pathAndFileName = file.AbsoluteUri; } if (file == null || file.IsFile) { string localPath = (file != null && file.IsFile) ? file.LocalPath : url; // If this is a local path, convert it to a short path name. Pass 0 as the length the first time uint requiredStringSize = Kernel32.GetShortPathNameW(localPath, null, 0); if (requiredStringSize > 0) { // It's able to make it a short path. char[] shortName = ArrayPool <char> .Shared.Rent((int)requiredStringSize); fixed(char *pShortName = shortName) { requiredStringSize = Kernel32.GetShortPathNameW(localPath, pShortName, requiredStringSize); // If it can't make it a short path, just leave the path we had. pathAndFileName = new string(pShortName, 0, (int)requiredStringSize); } ArrayPool <char> .Shared.Return(shortName); } } HandleRef handle; if (parent != null) { handle = new HandleRef(parent, parent.Handle); } else { handle = new HandleRef(null, User32.GetActiveWindow()); } object htmlParam; if (param is string stringParam) { HH htmlCommand = MapCommandToHTMLCommand(command, stringParam, out htmlParam); if (htmlParam is string stringHtmlParam) { HtmlHelpW(handle, pathAndFileName, htmlCommand, stringHtmlParam); } else if (htmlParam is int intParam) { HtmlHelpW(handle, pathAndFileName, htmlCommand, (IntPtr)intParam); } else if (htmlParam is HH_FTS_QUERYW query) { fixed(char *pszSearchQuery = stringParam) { query.pszSearchQuery = pszSearchQuery; HtmlHelpW(handle, pathAndFileName, htmlCommand, ref query); } } else if (htmlParam is HH_ALINKW aLink) { // According to MSDN documentation, we have to ensure that the help window is up // before we call ALINK lookup. HtmlHelpW(IntPtr.Zero, pathAndFileName, HH.DISPLAY_TOPIC, IntPtr.Zero); fixed(char *pszKeywords = stringParam) { aLink.pszKeywords = pszKeywords; HtmlHelpW(handle, pathAndFileName, htmlCommand, ref aLink); } } else { Debug.Fail("Cannot handle HTML parameter of type: " + htmlParam.GetType()); HtmlHelpW(handle, pathAndFileName, htmlCommand, (string)param); } } else if (param == null) { HtmlHelpW(handle, pathAndFileName, MapCommandToHTMLCommand(command, null, out htmlParam), IntPtr.Zero); } else if (param is HH_POPUPW popup) { HtmlHelpW(handle, pathAndFileName, HH.DISPLAY_TEXT_POPUP, ref popup); } else if (param.GetType() == typeof(int)) { throw new ArgumentException(string.Format(SR.InvalidArgument, nameof(param), "Integer"), nameof(param)); } }
public override string ToString() { return("{HelpFilePath=" + helpFilePath + ", keyword =" + keyword + ", navigator=" + navigator.ToString() + "}"); }
/// <include file='doc\Help.uex' path='docs/doc[@for="Help.ShowHTMLFile"]/*' /> /// <devdoc> /// Displays HTMLFile with the specified parameters /// </devdoc> /// <internalonly/> private static void ShowHTMLFile(Control parent, string url, HelpNavigator command, object param) { Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHTMLHelp:: " + url + ", " + command.ToString("G") + ", " + param); Uri file = Resolve(url); if (file == null) { throw new ArgumentException(SR.GetString(SR.HelpInvalidURL, url), "url"); } switch (file.Scheme) { case "http": case "https": Debug.WriteLineIf(IntSecurity.SecurityDemand.TraceVerbose, "WebPermission Demanded"); new WebPermission(NetworkAccess.Connect, url).Demand(); break; default: Debug.WriteLineIf(IntSecurity.SecurityDemand.TraceVerbose, "UnmanagedCode Demanded"); IntSecurity.UnmanagedCode.Demand(); break; } switch (command) { case HelpNavigator.TableOfContents: case HelpNavigator.Find: case HelpNavigator.Index: // nothing needed... // break; case HelpNavigator.Topic: if (param != null && param is string) { file = new Uri(file.ToString() + "#" + (string)param); } break; } Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "\tExecuting '" + file.ToString() + "'"); UnsafeNativeMethods.ShellExecute_NoBFM(new HandleRef(parent, parent.Handle), null, file.ToString(), null, null, NativeMethods.SW_NORMAL); }
/// <include file='doc\Help.uex' path='docs/doc[@for="Help.ShowHTML10Help"]/*' /> /// <devdoc> /// Displays HTML 1.0 Help with the specified parameters /// </devdoc> /// <internalonly/> private static void ShowHTML10Help(Control parent, string url, HelpNavigator command, object param) { Debug.WriteLineIf(Help.WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowHTML10Help:: " + url + ", " + command.ToString("G") + ", " + param); object htmlParam; if (param is string) { int htmlCommand = MapCommandToHTMLCommand(command, (string)param, out htmlParam); if (htmlParam is string) { SafeNativeMethods.HtmlHelp(new HandleRef(parent, parent.Handle), url, htmlCommand, (string)htmlParam); } else if (htmlParam is NativeMethods.HH_FTS_QUERY) { SafeNativeMethods.HtmlHelp(new HandleRef(parent, parent.Handle), url, htmlCommand, (NativeMethods.HH_FTS_QUERY)htmlParam); } else if (htmlParam is NativeMethods.HH_AKLINK) { // According to MSDN documentation, we have to ensure that the help window is up // before we call ALINK lookup. // SafeNativeMethods.HtmlHelp(new HandleRef(parent, parent.Handle), url, HH_DISPLAY_TOPIC, (string)null); SafeNativeMethods.HtmlHelp(new HandleRef(parent, parent.Handle), url, htmlCommand, (NativeMethods.HH_AKLINK)htmlParam); } else { Debug.Fail("Cannot handle HTML parameter of type: " + htmlParam.GetType()); SafeNativeMethods.HtmlHelp(new HandleRef(parent, parent.Handle), url, htmlCommand, (string)param); } } else if (param == null) { SafeNativeMethods.HtmlHelp(new HandleRef(parent, parent.Handle), url, MapCommandToHTMLCommand(command, null, out htmlParam), 0); } else if (param is NativeMethods.HH_POPUP) { SafeNativeMethods.HtmlHelp(new HandleRef(parent, parent.Handle), url, HH_DISPLAY_TEXT_POPUP, (NativeMethods.HH_POPUP)param); } else if (param.GetType() == typeof(Int32)) { SafeNativeMethods.HtmlHelp(new HandleRef(parent, parent.Handle), url, MapCommandToHTMLCommand(command, null, out htmlParam), (int)param); } }