Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following code should work just fine:</p> <pre><code>// 1. Change the function to call the Unicode variant, where applicable. // 2. Ask the marshaller to alert you to any errors that occur. // 3. Change the parameter types to make marshaling easier. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool SystemParametersInfo( int uiAction, int uiParam, ref RECT pvParam, int fWinIni); private const Int32 SPIF_SENDWININICHANGE = 2; private const Int32 SPIF_UPDATEINIFILE = 1; private const Int32 SPIF_change = SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE; private const Int32 SPI_SETWORKAREA = 47; private const Int32 SPI_GETWORKAREA = 48; [StructLayout(LayoutKind.Sequential)] public struct RECT { public Int32 Left; public Int32 Top; // top is before right in the native struct public Int32 Right; public Int32 Bottom; } private static bool SetWorkspace(RECT rect) { // Since you've declared the P/Invoke function correctly, you don't need to // do the marshaling yourself manually. The .NET FW will take care of it. bool result = SystemParametersInfo(SPI_SETWORKAREA, IntPtr.Zero, ref RECT, SPIF_change); if (!result) { // Find out the error code MessageBox.Show("The last error was: " + Marshal.GetLastWin32Error().ToString()); } return result; } </code></pre> <p>But I'm not really sure what you're trying to do. By default, the work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars. You're not going to be able to make it any larger than the area that's available on your screen (neat trick if you could, though!). Do your windows not already fill the entire screen when you maximize them?</p> <p>And even on machines with multiple monitors, you can't set the working area to span multiple monitors. The <a href="http://msdn.microsoft.com/en-us/library/ms724947.aspx" rel="nofollow">MSDN documentation</a> says that it's constrained to setting the working area of the monitor that contains the specified rectangle:</p> <blockquote> <p>In a system with multiple display monitors, the function sets the work area of the monitor that contains the specified rectangle.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload