Create Window larger than desktop (display resolution)
Asked Answered
P

10

11

I need to resize a window larger than screen resolution or size of desktop, programmatically & preferably also manually.

Since MS-Windows XP/Vista disallows a window size larger than screen, does anybody have any ideas to work around this limitation?

I trying to make pan effect on a laptop to give me more space to work. An older laptop with a smaller LCD size did have such a feature.

See this: http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/98/Q_21832063.html

Phantasm answered 15/1, 2009 at 7:4 Comment(0)
B
18

If you would like to resize a window that you do not own (and without using any kind of hook), you can use the Windows SetWindowPos API with the SWP_NOSENDCHANGING (0x0400) flag set:

BOOL WINAPI SetWindowPos(
__in      HWND hWnd,
__in_opt  HWND hWndInsertAfter,
__in      int X,
__in      int Y,
__in      int cx,
__in      int cy,
__in      UINT uFlags // ** SWP_NOSENDCHANGING must be passed here **
);

This will prevent the WM_WINDOWPOSCHANGING message from being sent which is what triggers the WM_GETMINMAXINFO restriction. Any other sizing of the window will cause the restriction to snap the window back to desktop restricted sizes, as the message will be sent and the window size enforced.

Window Resizer (C#)

The following is a tiny example program that will resize Notepad to 6000x6000 (change the string "Untitled - Notepad" to the title of the window you want to resize, or take the window name and desired size from the command line args)

namespace Example
{
 class Program
 {
  [DllImport("USER32.DLL")]
  public static extern IntPtr FindWindow(String className, String windowName);

  [DllImport("USER32.DLL", SetLastError = true)]
  public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int left, int top, int width, int height, uint flags);

  static void Main(string[] args)
  {
   var TOP = new IntPtr(0);
   uint SHOWWINDOW = 0x0040, NOCOPYBITS = 0x0100, NOSENDCHANGING = 0x0400;
   var hwnd = FindWindow(null, "Untitled - Notepad");
   SetWindowPos(hwnd, TOP, 0, 0, 6000, 6000, NOCOPYBITS | NOSENDCHANGING | SHOWWINDOW);
  }
 }
}

Limitations and caveats

This approach is generally functional, but there are a number of limitations that might prevent a window from being resized, or resized in any useful manner.

Security

Starting with Windows Vista, Microsoft has implemented increasing security around window messages. An executable can only interact with windows at or below its own security context. For example, to resize the "Computer Management" window (which always runs elevated), this program would have to run elevated as well.

Fixed Windows and layout logic

Window sizes might be enforced passively or actively by a program. A window with a size enforced passively sets the initial size and simply exposes no ability for the user to resize the window (e.g., no size grip control). These windows can usually be resized by sending a message as described but, lacking layout logic, will not show anything other that additional empty client area.

Windows with active enforcement monitor the size, either by catching the windows messages such as WM_SIZE, or in more sophisticated layout logic. These windows may accept the message, but will restrict or limit the final size in their own code.

In either case, Windows with fixed sizes generally lack any layout logic to take advantage of larger sizes so, even if you can force it, resizing them confers no benefits.

WPF

The Window class in WPF has an HwndSource that handles window messages sent to the WPF window. The private method LayoutFilterMessage catches the WM_SYSCOMMAND, WM_SIZING, WM_WINDOWPOSCHANGING, and WM_SIZE messages. In this case, the WM_SIZE message is then handled by the private Process_WM_SIZE which, in effect, bypasses the NOSENDCHANGING flag and alters the RenderSize of the WPF client area. This is part of an overall process of adapting legacy Win32 messages to WPF events.

The net effect is that the Win32 host window is resized (unless SizeToContent is set to SizeToContent.WidthAndHeight), but the WPF render area is locked to the desktop area, as if the NOSENDCHANGING flag weren't set. When the above code sample is run against a WPF app, you can see the 6000x6000 window in Aero Peek from the task bar or the window preview in the Windows-Tab switcher, but you can also see the WPF content and layout logic being clipped to the desktop area. In this way, the WPF window is like the actively enforced window but, rather than enforcing a specific size, enforces a specific maximum (for RenderArea) and does not consider the WM_WINDOWPOSCHANGING message.

If it is your own app and you host the WPF within a Windows Forms window (via ElementHost) you can resize the window and the WPF content will respect the larger-than-desktop Windows Form window.

Other frameworks

Other frameworks such as GTK and Qt may or may not enforce size behavior and limits, and may have various workarounds possible to overcome those limits. Any given program may ignore, rewrite, or bypass a window message and a framework can enforce it across an entire class of application such as with WPF above.

More about the SetWindowPos API:

Reference Source for Process_WM_SIZE method of HwndSource:

http://referencesource.microsoft.com/#PresentationCore/Core/CSharp/System/Windows/Interop/HwndSource.cs,da4aa32ad121c1b9,references

Bellbird answered 9/11, 2011 at 3:27 Comment(11)
Sadly this is what works. It would be great if microsoft had some registry option or something that we could use to turn the default window size limitation off.Recidivism
wow. It actually worked! Why doesn't this have more votes? It's the best solution around!Skillless
Thanks Arsen. Not only that, it was downvoted twice with no comment as to why. C'est la vie. At least it's still here for people who need it.Bellbird
The original asker "Nelson" is no longer an account. The above "test" account appears to perhaps be the OP, but there's no accepted answer because of that, either.Bellbird
Tested with windows 10, seems not working any more. :(Marge
@TylerLong I just added a simple code example and tested it under Windows 10 (10586.29). Keep in mind that this code will have to run at or above the security context of whatever window it attempts to resize. For example, if this code is running as a normal user it cannot resize an elevated window nor a window running as a different user.Bellbird
@MaxxDaymon I explained in detail here why this doesn't work in windows 10: gist.github.com/tylerlong/7bdd18af120a6de3b471 It seems to work, but actually it doesn't, because the content of the window is still limited to screen size.Marge
@TylerLong I can see that the WPF window is not resizing, but other windows resize larger than desktop in Windows 10. For example, I just resized an instance of Firefox (showing Google Maps) to 6000x6000 and took a window capture of it. I ended up with a 6000x6000 pixel image of a map framed by a very large Firefox window. So there would appear to be an issue with WPF specifically, but not Windows 10 itself.Bellbird
@MaxxDaymon agreed, what you said makes sense. So this method works for windows 10 windows but WPF windows. I managed to make it work via WM_ GETMINMAXINFO since I am the creator of the window.Marge
I precisely needed this in Xojo to overcome the screen dimensions window limitation. I had tried SetWindowPos before, but SWP_NOSENDCHANGING really did the trick. Best is Xojo reports the right window size afterward. Thks :)Arrowwood
I'm trying to use this method to take "high resolution" screenshots, did you successfully take screenshots of windows enlarged with this method? I just tried with notepad, and I end up with an image that is 6000x6000, but the part of notepad that is not currently not visible is just blackBeaver
C
3

This code in C# does what you ask. The window is way wider than the desktop.

 protected override void WndProc(ref Message m) {
        if (m.ToString().Contains("GETMINMAXINFO")) {
            //Hent data
            MINMAXINFO obj = (MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(MINMAXINFO));
            //Endre
            if (obj.ptMaxSize.X > 0) {
                obj.ptMaxSize.X = 60000;
                obj.ptMaxSize.Y = 60000;
                obj.ptMaxTrackSize.X = 60000;
                obj.ptMaxTrackSize.Y = 60000;
                //Oppdater
                Marshal.StructureToPtr(obj, m.LParam, true);
            }
        }
        if (m.ToString().Contains("WINDOWPOSCHANGING")) {
            //Hent data
            WINDOWPOS obj = (WINDOWPOS)Marshal.PtrToStructure(m.LParam, typeof(WINDOWPOS));
            //Endre
            if (obj.cx > 0) {
                obj.cx = 8000;
                //Oppdater
                Marshal.StructureToPtr(obj, m.LParam, true);
            }
        }
        //Debug.WriteLine(m.ToString());
        base.WndProc(ref m);
    }











    [StructLayout(LayoutKind.Sequential)]
    internal struct WINDOWPOS {
        internal IntPtr hwnd;
        internal IntPtr hWndInsertAfter;
        internal int x;
        internal int y;
        internal int cx;
        internal int cy;
        internal uint flags;
    }

    [StructLayout(LayoutKind.Sequential)]
    internal struct MINMAXINFO {
        internal POINT ptReserverd;
        internal POINT ptMaxSize;
        internal POINT ptMaxPosition;
        internal POINT ptMinTrackSize;
        internal POINT ptMaxTrackSize;
    }
    [StructLayout(LayoutKind.Sequential)]
    internal struct POINT {
        internal int X;
        internal int Y;
    }
Censurable answered 25/1, 2011 at 14:32 Comment(4)
He said, "I trying to make pan effect on a laptop to give me more space to work. An older laptop with a smaller LCD size did have such a feature." which implies that he wants to resize windows he is not writing the code for.Bellbird
Way more advanced, but should be doable with a little code injection...?Censurable
Every program is going to be different. Injecting into Python vs. .net vs. C++ is going to be different. The answer I outlined below, combined with setting a global window hook would remove the window sizing restriction generally, regardless of executable target.Bellbird
-1 for no example was given of usage and code not provided for base.WndProc(ref m);. Without this, I feel that the answer is uselessSkillless
C
3

You can do something like the following code in your WinProc();

case WM_GETMINMAXINFO:
    {
        LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; 
        GetWindowRect(GetDesktopWindow(), &actualDesktop);
        lpmmi->ptMaxTrackSize.x = 3000;// set the value that you really need.
        lpmmi->ptMaxTrackSize.y = 3000;// set the value that you really need.
    }
    break;

An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size.

Caviar answered 7/4, 2016 at 6:2 Comment(0)
G
1

If you have a video card with the possibility to connect more than one screen, another workaround is to setup your system as if it is using two screens next to eachother. Then you can resize your windows to the size of the two screens together.

Ghiberti answered 28/12, 2009 at 13:46 Comment(0)
B
1

The window size seems to be dependent on Desktop size, not screen resolution; however the Desktop conforms to resolution. The trick might be to change the Desktop size or start from there.

A while back, a developer named Robert Bresner (his website) made a product called sDesk (downloadable from here) which expanded Windows beyond the screen resolution.

What is SDesk? SDesk is not a multi-desktop program. It is a program that creates a single, giant desktop that extends beyond the visible region of the monitor. Only a portion of the SDesk is visible at a time, as defined by the Windows desktop settings.

The original homepage of the SDesk software is archived here There's no current page on the Internet (that I could find) but this archived version is accessed through the Way Back Machine which caches a lot of the Internet.

The SDesk product is freeware. No source code was included though. You might visit his contact page (also available in the archived version) to ask if the source is available or can be acquired for your research.

Buiron answered 5/1, 2010 at 22:1 Comment(1)
That's pretty neat but I didn't find a way to make the windows on this bigger virtual desktop actually as big as the virtual desktop. They're still limited by the true desktop size.Recidivism
S
1

Only the recommended screen resolutions are listed. For additional settings, click the Advanced button on the Settings tab, click the Adapter tab, and then click List all Modes. Select the resolution, color level, and refresh rate you want.

I've just did it, here you can find the answer in the last point.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/display_change_screen_resolution.mspx?mfr=true

Salian answered 6/11, 2011 at 21:14 Comment(0)
P
0

ok, I did try use keystrokes to move, resize windows. But system will automatically move windows back to visible region of desktop in my XP. I also tried SetWindowPos API, and no helps. The best chance will be to write a Video driver, but it may need more study. The 360 desktop claims you can expand desktop horizontally. But actually it just pan the current desktop in a virtual wider space. Any windows inside still have the size limitation of no larger than your screen resolution.

Video driver set the screen resolution(yes, have to compatibile to lcd/crt screen capability), and Windows did limit window-size by this thresholds. I just want to work around in user space API.

Phantasm answered 16/1, 2009 at 0:18 Comment(0)
D
0

I needed to push part of a window off the top of the screen and I was fnally able to do it using this AutoHotKey script:

SetTitleMatchMode, 2
WinTitle := "Visual Studio Code"

; --- WinMove version

; WinMove, %WinTitle%, , 0, -64, 1280, 1504

; -- DLL version

WinGet, id, , %WinTitle%
Result := DllCall("SetWindowPos", "uint", id, "uint", HWND_TOP, "Int", 0, "Int", -64, "Int", 1280, "Int", 1504, "UInt", 0x400)

(I wanted to maximize the editor area of VSCode by completely hiding the title bar and the tabs section, that are not configurable in the program itself.)

Dardar answered 12/11, 2018 at 11:9 Comment(0)
S
0

Since MS-Windows XP/Vista disallows a window size larger than screen, does anybody have any ideas to work around this limitation?

This limitation only applies to windows that are maximized. If you "restore" the window, then you can set it to a size larger than the desktop area.

I just tested it with Firefox on Windows 7 and successfully set it to 3000×3000 (my screen is only 1920×1080). It even worked with the Run dialog-box. (While Windows 10+ have drastically decreased user freedom and turned Windows into a locked-down Fisher-Price OS, there's no reason to believe this one aspect has changed, so it should work in later Windows as well.)

Note, that while Windows does not restrict non-maximized windows to the desktop, programs can impose their own limits by overriding WM_GETMINMAXINFO to restrict their windows' sizes. In that case, you'd have to override their message-handler somehow.

Shipowner answered 5/9, 2024 at 15:3 Comment(0)
G
-1

For the specific case of needing a more screen-friendly view of the MSDN, or on any other site (like StackOverflow) that makes poor use of screen real estate, I would suggest applying a custom stylesheet to the page, using a tool like IE7Pro (IE), Greasemonkey (Firefox), Stylish (Fireox), or the built in stylesheet picker in Opera.

Ganoid answered 15/1, 2009 at 7:45 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.