Originally posted by: markus
why do you all cry: it doesn't work, it doesn't work! it works, change those (really) small 5 pixels to 20 and see!
this sample works on all windows platforms, there isn't any win2k-specific code in it. you can even do this with visual basic (which is almost always compatible to win3.1!).
so be quiet and blame yourself, or try to get it working!
ps: go to aac.net.tf for the best audio grabber, written in vb!
Originally posted by: Guillaume APOSTOLY
I'm looking for a long time for a tool that will allow all application of windows to snap on the edges and together.
This could be achieved by tracking the windows resizing and moving at the mouse level.
When you're resizing a window, by example, your "customised mouse driver" must then see that you're reaching the edge of another application (or the border of the screen) and speed up your mouse to make it snap.
It must'nt be hard to do but I haven't got time to do MFC programming now ...
If you make it, tell me about it !!! :o)
Originally posted by: LastCall_
Hi,
I was looking on the web a tricks to "undock" windows in Windows 2000... Is there any way I can do that? (registry setting, etc.) Or I have to change the code of the application in cause?
Originally posted by: Alec
Come on people. It does work, it's just that it has a very low threshold. Some of you don't even know what it's SUPPOSED to do. What it does is to SNAP the window to the edge of the screen when you move it close enough. I'm sure you've seen this enough times in other places...
Try running the program. Then shrink the window somewhat, it makes it easier to see. Then move the window near to the edge of the screen. Now SLOWLY move it closer and closer to the edge of the screen. When you get close enough, the window will jump to align itself with the edge. Move the window off screen and move it's edge back close to the screen-edge and it does the same.
If you still don't see it, open the workspace, and change the line in SnapWnd.cpp from
m_nSnapPixels = 5;
to
m_nSnapPixels = 50;
rebuild and run it. You CAN'T miss it now.
To Anish, good job. It works properly and it even works when you resize the window even when it's attached. I made a similar thing last year with the help of Christian Weiske <cweiske@cweiske.de>. We eventually got it working and I couldn't have been happier. Good work.
Originally posted by: wujp
Not Work in NT4
Reply
Originally posted by: mike hogan
see title
ReplyOriginally posted by: Hans Wedemeyer
Does not work, at least I don't see anything expect a frame window...
Reply
Originally posted by: Tom Malik
Congratulations on a job extremely well done. This class works very well (awesome for MDI's). I have tested it and it works seamlessly. Hats off to you.. and thank you!
ReplyOriginally posted by: Jason
Why don't you post a screen shot, which many people find helps?
Reply
Originally posted by: Chris
However - I would add these refinements...
1)
instead of
GetWindowRect(GetDesktopWindow(),&m_rDesktopRect);
to get the desktop rect use
SystemParametersInfo(SPI_GETWORKAREA, NULL, &m_rDesktopRect, 0);
and when snapped you can resize the desktop using
SystemParametersInfo(SPI_SETWORKAREA, NULL, &m_rDesktopRect, 0);
so that other applications are restricted to the available area
2)
When snapping use
m_rDesktopRect.left instead of 0
Now the window will always snap to the edge of the client area no matter where the taskbar is placed.
3)
Handle WM_SETTINGCHANGE as well as WM_DISPLAYCHANGE to update the desktop when the client area is changed.
4)
Use ::EnumWindows to go through open windows and resize them. I did this to allow the docking app to remain always on top and not obscure the caption bars of any other apps. Something like this:
BOOL CALLBACK CTickerDlg::EnumWindowsProc(HWND hwnd, LPARAM lParam)
try
if((::IsWindowVisible(hwnd)) && (!::IsIconic(hwnd)) && (lStyle&WS_VISIBLE) && (hwnd != hTray) && hwnd != g_hTicker)
I found the original class a great help. Hope someone finds this helpful.
Cheers
Chris
Don't know what everyone's moaning about. Seems to work ok on the platforms I've used it on.
and
m_rDesktopRect.top instead of 0
{
long lStyle;
HWND hTray = NULL;
RECT workRect, windowRect;
{
hTray = ::FindWindow("Shell_TrayWnd", "");
lStyle = ::GetWindowLong(hwnd, GWL_STYLE);
workRect = *(RECT*)lParam;
{
if(lStyle&WS_MAXIMIZE)
{
::MoveWindow(hwnd, workRect.left, workRect.top, workRect.right-workRect.left, workRect.bottom-workRect.top, true);
}
else
{
::GetWindowRect(hwnd, &windowRect);
if(windowRect.top < workRect.top)
{
windowRect.top=workRect.top;
}
if(windowRect.bottom-windowRect.top > workRect.bottom-workRect.top)
{
windowRect.bottom=windowRect.top + (workRect.bottom-workRect.top);
}
::MoveWindow(hwnd, windowRect.left, windowRect.top, windowRect.right-windowRect.left, windowRect.bottom-windowRect.top, true);
}
}
return true;
}
catch(...)
{
TRACE("ERROR: exception thrown in CTickerDlg::EnumWindowsProc()");
return false;
}
}
I have refined the code to create a docking HTML ticker application which docks to the top or bottom of the client area. If anyone would like the code then let me know.