Jump to content
Tuts 4 You

Kibloy's Blog

  • entries
    7
  • comments
    19
  • views
    51,210

Docking Windows To Screen Edges

Sign in to follow this  
Killboy

1,549 views

This is a rather simple but effective way to keep a window from being dragged out of the screen area.

Add this piece of code to your window/dialog procedure:

case WM_MOVING:
long scrx, scry;
RECT * rect;
rect = (RECT *)lParam;
scrx = GetSystemMetrics(SM_CXSCREEN);
scry = GetSystemMetrics(SM_CYSCREEN);
if(rect->right > scrx)
OffsetRect(rect, scrx - rect->right, 0);
if(rect->bottom > scry)
OffsetRect(rect, 0, scry - rect->bottom);
if(rect->left < 0)
OffsetRect(rect, -rect->left, 0);
if(rect->top < 0)
OffsetRect(rect, 0, -rect->top);
return true;

Just thought it might be useful to someone...

Sign in to follow this  


2 Comments


Recommended Comments

Yep, definitely a nice one - it's a nice effect, always good to add something like this. :>

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...