Changing Window's Screen Boundaries

Stopping windows in full screen from taking up a certain part of the s

Page 1 of 1

2 Replies - 1957 Views - Last Post: 15 October 2009 - 03:07 AM Rate Topic: -----

#1 CJG87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 04-October 09

Changing Window's Screen Boundaries

Posted 15 October 2009 - 01:08 AM

I don't know really where to start with this so I don't have any code to show I'm afraid but I'm just hoping to be pointed in the right direction to at least know which area I want to start looking in.

I want to create an application that can dock on the screen (this I can do) but I want the program to alter window's screen boundaries so when I maximize any other window, it does not go over the top of the docked window. I know setting the window to always on top will sort of do this, but I don't then want the docked window to hide any of the maximized window.

I think that I would probably have to either be making changes to the Windows API and maybe finding a way to look through every window that is open and set that window's properties to ensure it doesn't go completely full screen.

This is something I have wanted to achieve for years but have always given up looking after a quick search on google. I would be really grateful if anyone could point me in the right direction and maybe give me some links or ideas what to search for, or even code if you know how to do it yourself.

Thanks, Chris

Is This A Good Question/Topic? 0
  • +

Replies To: Changing Window's Screen Boundaries

#2 janne_panne  Icon User is offline

  • WinRT Dev
  • member icon

Reputation: 429
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

Re: Changing Window's Screen Boundaries

Posted 15 October 2009 - 01:38 AM

/me points towards the google

Windows already has this kind of program running: the taskbar. So that's a good keyword used for google search: "C# how to develop taskbar"

And the first result leads to:
http://social.msdn.m...9-68c301c83acb/

I think that thread has all the information you need. If it doesn't you can always come back here to ask for more help. Or if you run into troubles implementing those things mentioned in the thread.
Was This Post Helpful? 0
  • +
  • -

#3 CJG87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 04-October 09

Re: Changing Window's Screen Boundaries

Posted 15 October 2009 - 03:07 AM

Thanks, I think that was the sort of thing I was looking for. I tried the code it gave with the following class:

using System;

using System.Runtime.InteropServices;

public class WorkArea
{

	[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SystemParametersInfoA")]

	private static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, IntPtr lpvParam, Int32 fuWinIni);

	private const Int32 SPI_SETWORKAREA = 47;

	private const int SPIF_SENDWININICHANGE = 2;

	private const int SPIF_UPDATEINIFILE = 1;

	private const int SPIF_change = SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE;

	public WorkArea(Int32 Left, Int32 Right, Int32 Top, Int32 Bottom)
	{

		_WorkArea.Left = Left;

		_WorkArea.Top = Top;

		_WorkArea.Bottom = Bottom;

		_WorkArea.Right = Right;

	}

	public struct RECT
	{

		public Int32 Left;

		public Int32 Right;

		public Int32 Top;

		public Int32 Bottom;

	}

	private RECT _WorkArea;

	public void SetWorkingArea()
	{

		IntPtr ptr = IntPtr.Zero;

		ptr = Marshal.AllocHGlobal(Marshal.SizeOf(_WorkArea));

		Marshal.StructureToPtr(_WorkArea, ptr, false);

		//int i = SystemParametersInfo(SPI_SETWORKAREA, 0, ptr, 0);
		int i = SystemParametersInfo(SPI_SETWORKAREA, Marshal.SizeOf(_WorkArea), ptr, SPIF_change);
	}

}


Then called it in my form with

private void Form1_Load(object sender, EventArgs e)
{
	 WorkArea myArea = new WorkArea(50,60,70,80);
}


I'm not sure if thats at all right :S It doesn't seem to do anything anyway. I am using Windows 7 64 bit but in the sysWOW64 folder there is still a user32.dll file so I presume it should still work the same shouldn't it?

There is no option built into C# to allow this sort of functionality easily then? :(
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1