Simplified Windows 7 code path: form now displays in ALT+TAB but should be more reliable.

This commit is contained in:
Lorenz Cuno Klopfenstein 2011-04-04 22:37:28 +02:00
parent 9d8d723b0c
commit be0a5e38f7
3 changed files with 16 additions and 17 deletions

View file

@ -491,13 +491,13 @@
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(264, 204);
this.ControlBox = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(40, 40);
this.Name = "MainForm";
this.Text = "OnTopReplica";
this.Text = Strings.ApplicationName;
this.TopMost = true;
this.ShowInTaskbar = true;
this.menuContext.ResumeLayout(false);

View file

@ -32,9 +32,6 @@ namespace OnTopReplica {
//WinForms init pass
InitializeComponent();
KeepAspectRatio = false;
GlassEnabled = true;
GlassMargins = new Margins(-1);
//Store default values
DefaultNonClickTransparencyKey = this.TransparencyKey;
@ -53,9 +50,6 @@ namespace OnTopReplica {
menuContext, menuWindows, menuOpacity, menuResize, menuFullscreenContext
);
//Init message pump extensions
_msgPumpManager.Initialize(this);
//Set to Key event preview
this.KeyPreview = true;
}
@ -78,7 +72,6 @@ namespace OnTopReplica {
//Needed to hide caption, while keeping window title in task bar
var parms = base.CreateParams;
parms.Style &= ~0x00C00000; //WS_CAPTION
parms.Style &= 0x00040000; //WS_SIZEBOX
return parms;
}
}
@ -86,7 +79,14 @@ namespace OnTopReplica {
protected override void OnHandleCreated(EventArgs e){
base.OnHandleCreated(e);
//Window init
KeepAspectRatio = false;
GlassEnabled = true;
GlassMargins = new Margins(-1);
//Window handlers
_windowSeeker.OwnerHandle = this.Handle;
_msgPumpManager.Initialize(this);
//Platform specific form initialization
Program.Platform.PostHandleFormInit(this);

View file

@ -16,8 +16,6 @@ namespace OnTopReplica.Platforms {
DwmManager.SetWindowFlip3dPolicy(form, Flip3DPolicy.ExcludeAbove);
DwmManager.SetExludeFromPeek(form, true);
DwmManager.SetDisallowPeek(form, true);
SetWindowStyle(form);
}
public override void HideForm(MainForm form) {
@ -33,14 +31,15 @@ namespace OnTopReplica.Platforms {
form.Opacity = 1.0;
form.Show();
SetWindowStyle(form);
}
public override void OnFormStateChange(MainForm form) {
SetWindowStyle(form);
}
/*public override void OnFormStateChange(MainForm form) {
//SetWindowStyle(form);
}*/
/// <summary>
/// Used to alter the window style. Not used anymore.
/// </summary>
private void SetWindowStyle(MainForm form) {
if (!form.IsFullscreen) {
//This hides the app from ALT+TAB
@ -49,7 +48,7 @@ namespace OnTopReplica.Platforms {
long exStyle = WindowMethods.GetWindowLong(form.Handle, WindowMethods.WindowLong.ExStyle).ToInt64();
exStyle |= (long)(WindowMethods.WindowExStyles.ToolWindow);
exStyle &= ~(long)(WindowMethods.WindowExStyles.AppWindow);
//exStyle &= ~(long)(WindowMethods.WindowExStyles.AppWindow);
WindowMethods.SetWindowLong(form.Handle, WindowMethods.WindowLong.ExStyle, new IntPtr(exStyle));