public static bool FlashWindow(HWND hWnd, bool flashUntilForeground) { FLASHINFO fwi; fwi.cbSize = (UINT)Marshal.SizeOf(typeof(FLASHINFO)); // size fwi.hwnd = hWnd; // the window to flash fwi.dwFlags = (flashUntilForeground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL); // flash the caption and tray fwi.uCount = 5; // how many times to flash it fwi.dwTimeout = 0; // use the default cursor blink rate return (FlashWindowEx(ref fwi) == BOOL.TRUE); }
/// <summary> /// Flashes the window specified the number of times specified. /// </summary> /// <param name="hWnd">The window to flash.</param> /// <param name="flashCount">The number of times to flash it.</param> /// <returns></returns> public static bool FlashWindow(HWND hWnd, int flashCount) { FLASHINFO fwi; fwi.cbSize = (UINT)Marshal.SizeOf(typeof(FLASHINFO)); // size fwi.hwnd = hWnd; // the window to flash fwi.dwFlags = FLASHW_ALL; // flash the caption and tray fwi.uCount = (UINT)flashCount; // how many times to flash it fwi.dwTimeout = 0; // use the default cursor blink rate return (FlashWindowEx(ref fwi) == BOOL.TRUE); }
public GraphicsPlus(HWND hwnd, bool icm) { GpGraphics Graphics = new GpGraphics(); if (icm) { lastResult = NativeMethods.GdipCreateFromHWNDICM(hwnd, out Graphics); } else { lastResult = NativeMethods.GdipCreateFromHWND(hwnd, out Graphics); } SetNativeGraphics(Graphics); }
void DoThreading(EFile[] a_Files, List<LrentFile> a_FilesFin, API_Device D) { HWND v_MainBlock = ThreadManager.CreateSemaphore(0, 1); Queue<EFile> m_Files = new Queue<EFile>(a_Files.Length); foreach (EFile f in a_Files) m_Files.Enqueue(f); int c = Math.Max(Environment.ProcessorCount - 2, 1); c = Math.Min(c, m_Files.Count); c = 1; HWND[] m_Threads = new HWND[c]; object[] O = new object[] { m_Files, a_FilesFin, v_MainBlock, D}; for (int i = 0; i < m_Threads.Length; i++) { m_Threads[i] = ThreadManager.CreateThread(DoThreading2); ThreadManager.StartThread(m_Threads[i], O); } ThreadManager.WaitForSingleObject(v_MainBlock); ThreadManager.AbortObject(v_MainBlock); }
override public bool Equals(object oCompare) { HWND hr = Cast((HWND)oCompare); return(h == hr.h); }
public static extern ButtonStateFlags IsDlgButtonChecked(HWND hDlg, int nIDButton);
// Misc functions #if LATER BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM lParam) { *(HWND*)lParam = hwnd; return !IsWindowVisible(hwnd); }
public static extern BOOL BringWindowToTop(HWND hWnd);
internal extern static BOOL GetWindowRect(HWND windowHandle, out Win32Rectangle windowRectangle);
internal static extern int GetWindowText(HWND hWnd, [MarshalAs(UnmanagedType.LPTStr), In, Out] StringBuilder lpString, int nMaxCount);
internal static extern BOOL PostMessage( HWND hWnd, WindowMessage Msg, WPARAM wParam, LPARAM lParam );
public HRESULT SetReferent([NativeTypeName("PCSTR")] sbyte *pcszReferent, HWND hwnd) { return(((delegate * unmanaged <INewShortcutHookA *, sbyte *, HWND, int>)(lpVtbl[3]))((INewShortcutHookA *)Unsafe.AsPointer(ref this), pcszReferent, hwnd)); }
public HRESULT RequestAccessForAppWithAuditingInfoForWindowAsync(HWND appWindow, HSTRING sourceIdentity, HSTRING appPackageFamilyName, IUnknown *auditInfoUnk, [NativeTypeName("const IID &")] Guid *riid, void **asyncOperation) { return(((delegate * unmanaged <IProtectionPolicyManagerInterop2 *, HWND, HSTRING, HSTRING, IUnknown *, Guid *, void **, int>)(lpVtbl[9]))((IProtectionPolicyManagerInterop2 *)Unsafe.AsPointer(ref this), appWindow, sourceIdentity, appPackageFamilyName, auditInfoUnk, riid, asyncOperation)); }
public HRESULT RequestAccessWithMessageForWindowAsync(HWND appWindow, HSTRING sourceIdentity, HSTRING targetIdentity, IUnknown *auditInfoUnk, HSTRING messageFromApp, [NativeTypeName("const IID &")] Guid *riid, void **asyncOperation) { return(((delegate * unmanaged <IProtectionPolicyManagerInterop2 *, HWND, HSTRING, HSTRING, IUnknown *, HSTRING, Guid *, void **, int>)(lpVtbl[8]))((IProtectionPolicyManagerInterop2 *)Unsafe.AsPointer(ref this), appWindow, sourceIdentity, targetIdentity, auditInfoUnk, messageFromApp, riid, asyncOperation)); }
public HRESULT MakeWindowAssociation(HWND WindowHandle, uint Flags) { return(((delegate * unmanaged <IDXGIFactory7 *, HWND, uint, int>)(lpVtbl[8]))((IDXGIFactory7 *)Unsafe.AsPointer(ref this), WindowHandle, Flags)); }
public HRESULT RegisterOcclusionStatusWindow(HWND WindowHandle, uint wMsg, [NativeTypeName("DWORD *")] uint *pdwCookie) { return(((delegate * unmanaged <IDXGIFactory7 *, HWND, uint, uint *, int>)(lpVtbl[21]))((IDXGIFactory7 *)Unsafe.AsPointer(ref this), WindowHandle, wMsg, pdwCookie)); }
public HRESULT CreateSwapChainForHwnd(IUnknown *pDevice, HWND hWnd, [NativeTypeName("const DXGI_SWAP_CHAIN_DESC1 *")] DXGI_SWAP_CHAIN_DESC1 *pDesc, [NativeTypeName("const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *")] DXGI_SWAP_CHAIN_FULLSCREEN_DESC *pFullscreenDesc, IDXGIOutput *pRestrictToOutput, IDXGISwapChain1 **ppSwapChain) { return(((delegate * unmanaged <IDXGIFactory7 *, IUnknown *, HWND, DXGI_SWAP_CHAIN_DESC1 *, DXGI_SWAP_CHAIN_FULLSCREEN_DESC *, IDXGIOutput *, IDXGISwapChain1 **, int>)(lpVtbl[15]))((IDXGIFactory7 *)Unsafe.AsPointer(ref this), pDevice, hWnd, pDesc, pFullscreenDesc, pRestrictToOutput, ppSwapChain)); }
override public bool Equals(object oCompare) { HWND temp = Cast((HWND)oCompare); return(_value == temp._value); }
static extern UIntPtr GetWindowLongPtrInternal(HWND hWnd, GetWindowLongOffsets nIndex);
public static extern int SerialDisplayAdvancedSettings(HWND ParentHwnd, HDEVINFO DeviceInfoSet, [NativeTypeName("PSP_DEVINFO_DATA")] void *DeviceInfoData);
internal static extern BOOL ShowWindow(HWND hWnd, ShowWindowCommand nCmdShow);
private bool OpenEditorInternal(bool hidden, bool topmost) { Rectangle wndRect = new Rectangle(); if (hidden) { _editorWindow = new PluginWindow //make sure the window is invisible { Width = 100, Height = 100, WindowStyle = WindowStyle.None, ShowInTaskbar = false, ShowActivated = false, Left = 0, Top = 0, ResizeMode = ResizeMode.NoResize, Margin = new Thickness(0), SnapsToDevicePixels = true, UseLayoutRounding = false, AllowsTransparency = true, Opacity = 0, Background = Brushes.Transparent, SizeToContent = SizeToContent.WidthAndHeight }; } else { _editorWindow = new PluginWindow() //make sure the window is invisible { Width = 100, Height = 100, ShowInTaskbar = true, ShowActivated = true, Title = "Plugin Editor: " + PluginContext.PluginCommandStub.GetEffectName(), ResizeMode = ResizeMode.NoResize, Margin = new Thickness(0), SnapsToDevicePixels = true, UseLayoutRounding = false, Topmost = topmost, SizeToContent = SizeToContent.WidthAndHeight, }; } FrameworkElement pnlClient = _editorWindow.Content as FrameworkElement; _editorWindowHelper = new WindowInteropHelper(_editorWindow); _editorWindowHelper.EnsureHandle(); if (PluginContext.PluginCommandStub.EditorGetRect(out wndRect)) { pnlClient.Width = wndRect.Width; pnlClient.Height = wndRect.Height; PluginContext.PluginCommandStub.EditorOpen(_editorWindowHelper.Handle); } else { PluginContext.PluginCommandStub.EditorOpen(_editorWindowHelper.Handle); if (PluginContext.PluginCommandStub.EditorGetRect(out wndRect)) { pnlClient.Width = wndRect.Width; pnlClient.Height = wndRect.Height; } else { Logger.Warning( $"Unable to open the editor for the plugin {PluginContext.PluginCommandStub.GetEffectName()} because it didn't give us a rectangle to work with."); return(false); } } if (wndRect.Width == 0 || wndRect.Height == 0) { Logger.Warning( $"Unable to open the editor for the plugin {PluginContext.PluginCommandStub.GetEffectName()} because it give us an empty rectangle to work with."); return(false); } _editorWindow.Show(); if (hidden) { int value = 1; // TRUE to disable DwmSetWindowAttribute(_editorWindowHelper.Handle, DWMWA_TRANSITIONS_FORCEDISABLED, ref value, Marshal.SizeOf(value)); } var success = PluginContext.PluginCommandStub.EditorOpen(_editorWindowHelper.Handle); if (hidden) { var handle = new HWND(_editorWindowHelper.Handle); NativeMethods.SetWindowPos( handle, HWND.BOTTOM, 0, 0, 0, 0, SWP.NOMOVE | SWP.NOSIZE); } if (!success) { _editorWindow.Close(); return(false); } if (PluginContext.PluginCommandStub.EditorGetRect(out Rectangle wndRect2)) { if (wndRect2.Width != 0 && wndRect2.Height != 0) { pnlClient.Width = wndRect2.Width; pnlClient.Height = wndRect2.Height; } } IsEditorOpen = true; return(true); }
internal static extern BOOL ClientToScreen(HWND hWnd, ref Point point);
public HRESULT DisplayUI(HWND hwndParent, [NativeTypeName("LPCWSTR")] ushort *pszTitle, [NativeTypeName("LPCWSTR")] ushort *pszTypeOfUI, void *pvExtraData, [NativeTypeName("ULONG")] uint cbExtraData, IUnknown *punkObject) { return(((delegate * unmanaged <ISpObjectTokenInit *, HWND, ushort *, ushort *, void *, uint, IUnknown *, int>)(lpVtbl[23]))((ISpObjectTokenInit *)Unsafe.AsPointer(ref this), hwndParent, pszTitle, pszTypeOfUI, pvExtraData, cbExtraData, punkObject)); }
unsafe public static extern HRESULT DwmGetWindowAttribute(HWND hwnd, DwmWindowAttribute dwAttribute, void* pvAttribute, DWORD cbAttribute);
// window procedure LONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
public static extern LONG ChangeDisplaySettingsEx([MarshalAs(UnmanagedType.LPTStr)] LPCTSTR lpszDeviceName, LPDEVMODE lpDevMode, HWND hwnd, ChangeDisplaySettingsEnum dwflags, LPVOID lParam);
private static extern int GetWindowText(HWND hWnd, StringBuilder lpString, int nMaxCount);
public static HWND Cast(IntPtr h) { HWND hTemp = new HWND(); hTemp.h = h; return hTemp; }
private static extern int GetWindowTextLength(HWND hWnd);
static extern LONG SetWindowLongInternal(HWND hWnd, GetWindowLongOffsets nIndex, LONG dwNewLong);
static extern LONG_PTR SetWindowLongPtrInternal(HWND hWnd, GetWindowLongOffsets nIndex, [MarshalAs(UnmanagedType.FunctionPtr)]WindowProcedure dwNewLong);
private static extern bool IsWindowVisible(HWND hWnd);
private static extern HWND CreateDemoHelloWorldApp(HWND parent);
static extern LONG_PTR SetWindowLongPtrInternal(HWND hWnd, GetWindowLongOffsets nIndex, LONG_PTR dwNewLong);
private LRESULT WndProcWrapper(HWND hwnd, uint msg, WPARAM wParam, LPARAM lParam) { return(new LRESULT(this.WndProc(hwnd, msg, wParam, lParam))); }
static extern ULONG GetWindowLongInternal(HWND hWnd, GetWindowLongOffsets nIndex);
public HRESULT CreateSessionForWindow(HWND window, [NativeTypeName("const IID &")] Guid *iid, void **value) { return(((delegate * unmanaged <IUserActivityInterop *, HWND, Guid *, void **, int>)(lpVtbl[6]))((IUserActivityInterop *)Unsafe.AsPointer(ref this), window, iid, value)); }
internal static extern LRESULT SendMessage(HWND hWnd, WindowMessage Msg, WPARAM wParam, LPARAM lParam);
public static extern uint WNetDisconnectDialog(HWND hwnd, [NativeTypeName("DWORD")] uint dwType);
public extern static IntPtr DefWindowProc(HWND hWnd, WindowMessage msg, IntPtr wParam, IntPtr lParam);
public static extern uint WNetAddConnection3A(HWND hwndOwner, [NativeTypeName("LPNETRESOURCEA")] NETRESOURCEA *lpNetResource, [NativeTypeName("LPCSTR")] sbyte *lpPassword, [NativeTypeName("LPCSTR")] sbyte *lpUserName, [NativeTypeName("DWORD")] uint dwFlags);
internal static extern BOOL SetWindowText(HWND hWnd, [MarshalAs(UnmanagedType.LPTStr)] string lpString);
public static extern uint WNetAddConnection3W(HWND hwndOwner, [NativeTypeName("LPNETRESOURCEW")] NETRESOURCEW *lpNetResource, [NativeTypeName("LPCWSTR")] ushort *lpPassword, [NativeTypeName("LPCWSTR")] ushort *lpUserName, [NativeTypeName("DWORD")] uint dwFlags);
//internal static extern BOOL ScreenToClient(HWND hWnd, ref POINT point); internal static extern BOOL ScreenToClient(HWND hWnd, ref Point point);
public static extern uint WNetAddConnection4W(HWND hwndOwner, [NativeTypeName("LPNETRESOURCEW")] NETRESOURCEW *lpNetResource, [NativeTypeName("PVOID")] void *pAuthBuffer, [NativeTypeName("DWORD")] uint cbAuthBuffer, [NativeTypeName("DWORD")] uint dwFlags, [NativeTypeName("PBYTE")] byte *lpUseOptions, [NativeTypeName("DWORD")] uint cbUseOptions);
internal extern static BOOL GetClientRect(HWND windowHandle, out Win32Rectangle clientRectangle);
public static extern uint WNetRestoreSingleConnectionW(HWND hwndParent, [NativeTypeName("LPCWSTR")] ushort *lpDevice, BOOL fUseUI);
internal static extern BOOL GetWindowInfo(HWND hwnd, ref WindowInfo wi);
public static extern uint WNetUseConnectionW(HWND hwndOwner, [NativeTypeName("LPNETRESOURCEW")] NETRESOURCEW *lpNetResource, [NativeTypeName("LPCWSTR")] ushort *lpPassword, [NativeTypeName("LPCWSTR")] ushort *lpUserId, [NativeTypeName("DWORD")] uint dwFlags, [NativeTypeName("LPWSTR")] ushort *lpAccessName, [NativeTypeName("LPDWORD")] uint *lpBufferSize, [NativeTypeName("LPDWORD")] uint *lpResult);
public static extern BOOL SetForegroundWindow(HWND hWnd);
public static extern uint WNetUseConnection4A(HWND hwndOwner, [NativeTypeName("LPNETRESOURCEA")] NETRESOURCEA *lpNetResource, [NativeTypeName("PVOID")] void *pAuthBuffer, [NativeTypeName("DWORD")] uint cbAuthBuffer, [NativeTypeName("DWORD")] uint dwFlags, [NativeTypeName("PBYTE")] byte *lpUseOptions, [NativeTypeName("DWORD")] uint cbUseOptions, [NativeTypeName("LPSTR")] sbyte *lpAccessName, [NativeTypeName("LPDWORD")] uint *lpBufferSize, [NativeTypeName("LPDWORD")] uint *lpResult);
public static extern BOOL SetParent(HWND child, HWND newParent);
public HRESULT Synchronize([NativeTypeName("LPCWSTR *")] ushort **ppszItemIDs, [NativeTypeName("ULONG")] uint cItems, HWND hwndOwner, ISyncMgrSessionCreator *pSessionCreator, IUnknown *punk) { return(((delegate * unmanaged <ISyncMgrHandler *, ushort **, uint, HWND, ISyncMgrSessionCreator *, IUnknown *, int>)(lpVtbl[10]))((ISyncMgrHandler *)Unsafe.AsPointer(ref this), ppszItemIDs, cItems, hwndOwner, pSessionCreator, punk)); }
public static extern HMONITOR MonitorFromWindow(HWND hwnd, MonitorFrom dwFlags);
public HRESULT RequestTokenWithWebAccountForWindowAsync(HWND appWindow, IInspectable *request, IInspectable *webAccount, [NativeTypeName("const IID &")] Guid *riid, void **asyncInfo) { return(((delegate * unmanaged <IWebAuthenticationCoreManagerInterop *, HWND, IInspectable *, IInspectable *, Guid *, void **, int>)(lpVtbl[7]))((IWebAuthenticationCoreManagerInterop *)Unsafe.AsPointer(ref this), appWindow, request, webAccount, riid, asyncInfo)); }
public static GraphicsPlus FromHWND(HWND hwnd, bool icm) { return new GraphicsPlus(hwnd, icm); }
public static extern Int32 PostMessage(HWND hWnd, DWORD Msg, DWORD wParam, DWORD lParam);
/// <summary> /// /// </summary> /// <param name="hwnd"></param> /// <param name="pos"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="cx"></param> /// <param name="cy"></param> /// <param name="uFlags"></param> /// <returns></returns> public static bool SetWindowPos(IntPtr hwnd, HWND pos, int x, int y, int cx, int cy, SWP uFlags) { return NativeMethods.SetWindowPos(hwnd, pos, x, y, cx, cy, uFlags); }
public static extern bool SetForegroundWindow(HWND hWnd);