public static GetClassLongPtr ( |
||
hWnd | Handle to the window and, indirectly, the class to which the window belongs. | |
nIndex | int | Specifies the value to retrieve. To retrieve a value from the extra class memory, specify the positive, zero-based byte offset of the value to be retrieved. Valid values are in the range zero through the number of bytes of extra class memory, minus eight; for example, if you specified 24 or more bytes of extra class memory, a value of 16 would be an index to the third integer. To retrieve any other value from the WNDCLASSEX structure, specify one of the following values. |
Résultat |
static ImageSource GetDefaultIcon(IntPtr hwnd) { if (hwnd != IntPtr.Zero) { try { var zero = NativeMethods.SendMessage(hwnd, 0x7f, new IntPtr(2), IntPtr.Zero); if (zero == IntPtr.Zero) { zero = NativeMethods.GetClassLongPtr(hwnd, -34); } if (zero == IntPtr.Zero) { zero = NativeMethods.LoadImage(IntPtr.Zero, new IntPtr(0x7f00), 1, (int)SystemParameters.SmallIconWidth, (int)SystemParameters.SmallIconHeight, 0x8000); } if (zero != IntPtr.Zero) { return(BitmapFrame.Create(Imaging.CreateBitmapSourceFromHIcon(zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight((int)SystemParameters.SmallIconWidth, (int)SystemParameters.SmallIconHeight)))); } } catch { return(null); } } return(null); }