/// <summary> /// Get a string resource given a resource Id /// </summary> /// <param name="resourceId">The resource Id</param> /// <returns>The string resource corresponding to the given resource Id. Returns null if the resource id /// is invalid or the string cannot be retrieved for any other reason.</returns> public static string GetStringResource(string resourceId) { string[] parts; string library; int index; if (string.IsNullOrEmpty(resourceId)) { return(string.Empty); } // Known folder "Recent" has a malformed resource id // for its tooltip. This causes the resource id to // parse into 3 parts instead of 2 parts if we don't fix. resourceId = resourceId.Replace("shell32,dll", "shell32.dll"); parts = resourceId.Split(new char[] { ',' }); library = parts[0]; library = library.Replace(@"@", string.Empty); library = Environment.ExpandEnvironmentVariables(library); IntPtr handle = CoreNativeMethods.LoadLibrary(library); parts[1] = parts[1].Replace("-", string.Empty); index = int.Parse(parts[1], CultureInfo.InvariantCulture); StringBuilder stringValue = new StringBuilder(255); int retval = CoreNativeMethods.LoadString(handle, index, stringValue, 255); return(retval != 0 ? stringValue.ToString() : null); }
/// <summary> /// Dispatches a window message so that the appropriate events /// can be invoked. This is used for the Taskbar's thumbnail toolbar feature. /// </summary> /// <param name="m">The window message, typically obtained /// from a Windows Forms or WPF window procedure.</param> /// <param name="taskbarWindow">Taskbar window for which we are intercepting the messages</param> /// <returns>Returns true if this method handles the window message</returns> internal bool DispatchMessage(ref Message m, TaskbarWindow taskbarWindow) { if (m.Msg == (int)TaskbarNativeMethods.WM_TASKBARBUTTONCREATED) { AddButtons(taskbarWindow); } else { if (!_buttonsAdded) { AddButtons(taskbarWindow); } switch (m.Msg) { case TaskbarNativeMethods.WM_COMMAND: if (CoreNativeMethods.HIWORD(m.WParam.ToInt64(), 16) == THUMBBUTTON.THBN_CLICKED) { int buttonId = CoreNativeMethods.LOWORD(m.WParam.ToInt64()); foreach (var button in taskbarWindow.ThumbnailButtons) { if (button.Id == buttonId) { button.FireClick(taskbarWindow); } } } break; } // End switch } // End else return(false); }