简体   繁体   中英

Launch WinForm application Aerosnaped Right Aligned

This should be a simple question, but search-foo has failed me. My goal is to detect that I'm running under Aero (Vista or Windows 7) and have my application Aerosnap by default. (It turns out that a corporate application I wrote is run by pretty much everyone aerosnapped right, with their Outlook snapped left.)

The application is WinForms and I'm currently doing

Width = Screen.PrimaryScreen.WorkingArea.Size.Width / 2;
Height = Screen.PrimaryScreen.WorkingArea.Size.Height;
Top = Screen.PrimaryScreen.WorkingArea.Top;
Left = Screen.PrimaryScreen.WorkingArea.Left + 
       Screen.PrimaryScreen.WorkingArea.Size.Width / 2;

in my forms's load event. This works great, except that if they use WindowKey+Arrow, it acts as if it was just a normally located form. This means WindowKey+Right does nothing on first press and WindowKey+Left snaps left. This isn't a major problem, but I would prefer if I could specify a window size and then snap the application to the Right so those keys act as they would with any other application.

I'm not sure this is possible, here are the things I did find:

These seem to indicate that there is no special AeroSnap message available. Anyone know otherwise?

Not sure why checking for version wouldn't get you most of the way. How to determine the Windows version by using Visual C# http://support.microsoft.com/kb/304283

This might get you the rest of the way. http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/1a82ec8d-afc3-4eba-8189-6ee105aa6249

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM