Jump to content
xisto Community
magiccode91405241511

How To Make A Window Form Smooth Snap To Desktop Edge ?

Recommended Posts

Hi, All, Now I got another issues that I wanted to implment a window that will snap to desktop edge.What I'am do now was creating it with timer and some windows api to check positionssay if within a range then move the form window to any edge.But this has an issue with it the window will flicker.Any ideas with this issue ?Thanks,---Magiccode9

Share this post


Link to post
Share on other sites

Why not listen for Form.Move event, since you would only want to snap the form when it's moving right?

Then in the event handler just compare Form.Bound against Screen.PrimaryScreen.Bounds. Do take into consideration of pc with multiple display.

Btw, if you just need this feature for your own use, take a look at Pitaschio. It does what you're looking for to all windows and form, plus added some more great features, good for daily use.

Share this post


Link to post
Share on other sites

Faulty, Thanks your help !I have been tested it with Form.Move event and related bounds.But this still has flicker when I assign the top property of a form to 0.Also, I have found a vb6 sample that does somethings similar to what I want to do.That is a sample that restricted a window won't over the screen bound with a smooth moving.With this example, it is much harder to get it works.It basically work with windows message directly by intercept some messages.I'am looking for this to see how it work.Actually, it is used for my own small app that I build to get RSS feed and store some structure data.I still looking for some sample code for this.Thanks,P.S. I'am using the RapidTools as a reference.---Magiccode9

Edited by magiccode9 (see edit history)

Share this post


Link to post
Share on other sites

Have you try to enable doublebuffering?
Do this inside your form's constructor after InitializeComponent()

this.SetStyle(  ControlStyles.AllPaintingInWmPaint |  ControlStyles.UserPaint |  ControlStyles.DoubleBuffer,true);

Share this post


Link to post
Share on other sites

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...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.