Smart Device Functions:
coredll is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for setforegroundwindow in other DLLs exists, click on Find References to the right.
//NOTE: For Win32 Applications you can use [DllImport("User32.dll")] for this functionality. Coredll.dll is for the .NET Compact Framework.
Alternative Unmanaged API:
Alternative Managed API:
Do you know one? Please contribute it!
Tips & Tricks:
Note this tip from the Microsoft documentation:
If the window being set to the foreground is minimized, the window may not be visible to the end user. This function also does not reactivate the last active child window by default. To ensure that the window is restored and the last active child window is reactivated, combine the handle to the window with 0x01 using the logical OR operator
E.g. SetForegroundWindow((HWND)(((ULONG) hwnd) | 0x01) );
private static extern bool SetForegroundWindow (IntPtr hWnd);
private static extern IntPtr GetDesktopWindow ();
private void SendToBack ()
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 11:00:13 AM - tsahi-184.108.40.206
Please edit this page!
Do you have...