• Welcome to Valhalla Legends Archive.
 

Window Docking

Started by MyndFyre, June 22, 2005, 10:25 PM

Previous topic - Next topic

MyndFyre

Does anyone know how to dock a window to a desktop?  Pretty much, I want to be able to have my form object attach itself to the left or right and increase its height to match the screen's height when it's within a specified margine (right now I have it at 10px), otherwise go back to its old size.

Right now, I have a Form object called DockedForm, that implements an event handler on moving:

private void DockedForm_Move(object sender, System.EventArgs e)
{
if (m_storedSize == Size.Empty)
{
m_storedSize = Size;
m_docked = false;
}

if (Screen.AllScreens.Length == 1)
{
if ((Left <= m_mgn) &&
((this.m_pos & WindowDockPositions.Left) != 0))
{
Left = 0;

if (!m_docked)
{
if (m_storedSize.Height != Screen.PrimaryScreen.Bounds.Height)
{
if (Size.Height != Screen.PrimaryScreen.Bounds.Height)
{
m_storedSize = Size;
}
}
else
{
m_storedSize = Size;
}
m_docked = true;
}
Invoke(new SetSizeCallback(setSize),
new object[] { new Size(Width, Screen.PrimaryScreen.Bounds.Height) });

Top = 0;
}
else if ((Right >= (Screen.PrimaryScreen.Bounds.Width - m_mgn)) &&
((m_pos & WindowDockPositions.Right) != 0))
{
Left = (Screen.PrimaryScreen.Bounds.Width - Width);
if (!m_docked)
{
m_storedSize = Size;
m_docked = true;
}
Top = 0;
Invoke(new SetSizeCallback(setSize),
new object[] { new Size(Width, Screen.PrimaryScreen.Bounds.Height) });

}
else
{
if (m_docked)
{
#if DEBUG
T.WriteLine("Undocking", "Status");
#endif
Invoke(new SetSizeCallback(setSize),
new object[] { m_storedSize });
this.Width = m_storedSize.Width;
this.Height = m_storedSize.Height;
m_docked = false;
Invalidate();
}
}
}
}


Two problems with this:

1.) It flickers when docking to the side.  By "flickers" I mean it looks like it can't decide whether to keep its old size or new.
2.) Once it's been resized, dragging the window away from the side does nothing.  I see through a trace that the old size is actually set to the window's size.  However, the window's actual size does not shrink.

Any thoughts?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

dxoigmn

I'm pretty sure there is an API for this, at least it seems like it is something that should be handled by the window manager. A quick search on google reveals http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_programming/appbars.asp