Fixed some platform code.

This commit is contained in:
Lorenz Cuno Klopfenstein 2011-04-04 21:31:07 +02:00
parent ea9f7a4643
commit 6a97df159a
8 changed files with 22 additions and 17 deletions

View file

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

View file

@ -29,7 +29,6 @@ namespace OnTopReplica {
public MainForm(Options startupOptions) {
_startupOptions = startupOptions;
Program.Platform.PreHandleFormInit(this);
//WinForms init pass
InitializeComponent();
@ -38,7 +37,8 @@ namespace OnTopReplica {
GlassMargins = new Margins(-1);
//Store default values
_nonClickThroughKey = TransparencyKey;
DefaultNonClickTransparencyKey = this.TransparencyKey;
DefaultBorderStyle = this.FormBorderStyle;
//Thumbnail panel
_thumbnailPanel = new ThumbnailPanel {

View file

@ -36,7 +36,7 @@ namespace OnTopReplica {
#region Click-through
bool _clickThrough = false;
Color _nonClickThroughKey;
readonly Color DefaultNonClickTransparencyKey;
public bool ClickThroughEnabled {
get {
@ -50,7 +50,7 @@ namespace OnTopReplica {
Opacity = 1.0;*/
//Enable transparency and force as top-most
TransparencyKey = (value) ? Color.Black : _nonClickThroughKey;
TransparencyKey = (value) ? Color.Black : DefaultNonClickTransparencyKey;
if (value)
TopMost = true;
@ -62,7 +62,7 @@ namespace OnTopReplica {
#region Chrome
const FormBorderStyle DefaultBorderStyle = FormBorderStyle.SizableToolWindow;
readonly FormBorderStyle DefaultBorderStyle; // = FormBorderStyle.Sizable; // FormBorderStyle.SizableToolWindow;
public bool IsChromeVisible {
get {

View file

@ -9,11 +9,11 @@ namespace OnTopReplica.Native {
[DllImport("shell32.dll")]
internal static extern void SetCurrentProcessExplicitAppUserModelID(
[MarshalAs(UnmanagedType.LPWStr)] string AppID);
[MarshalAs(UnmanagedType.LPWStr)] string appId);
[DllImport("shell32.dll")]
internal static extern void GetCurrentProcessExplicitAppUserModelID(
[Out(), MarshalAs(UnmanagedType.LPWStr)] out string AppID);
[Out(), MarshalAs(UnmanagedType.LPWStr)] out string appId);
}

View file

@ -42,7 +42,7 @@ namespace OnTopReplica {
/// <summary>
/// Initializes a form before it is fully constructed and before the window handle has been created.
/// </summary>
public virtual void PreHandleFormInit(MainForm form) {
public virtual void PreHandleFormInit() {
}
/// <summary>

View file

@ -7,9 +7,9 @@ namespace OnTopReplica.Platforms {
class WindowsSeven : WindowsVista {
public override void PreHandleFormInit(MainForm form) {
public override void PreHandleFormInit() {
//Set Application ID
WindowsSevenMethods.SetCurrentProcessExplicitAppUserModelID("OnTopReplica");
WindowsSevenMethods.SetCurrentProcessExplicitAppUserModelID("LorenzCunoKlopfenstein.OnTopReplica.MainForm");
}
public override void PostHandleFormInit(MainForm form) {
@ -46,8 +46,14 @@ namespace OnTopReplica.Platforms {
//This hides the app from ALT+TAB
//Note that when minimized, it will be shown as an (ugly) minimized tool window
//thus we do not minimize, but set to transparent when hiding
WindowMethods.SetWindowLong(form.Handle, WindowMethods.WindowLong.ExStyle,
(IntPtr)(WindowMethods.WindowExStyles.ToolWindow | WindowMethods.WindowExStyles.Layered));
long exStyle = WindowMethods.GetWindowLong(form.Handle, WindowMethods.WindowLong.ExStyle).ToInt64();
exStyle |= (long)(WindowMethods.WindowExStyles.ToolWindow);
exStyle &= ~(long)(WindowMethods.WindowExStyles.AppWindow);
WindowMethods.SetWindowLong(form.Handle, WindowMethods.WindowLong.ExStyle, new IntPtr(exStyle));
//WindowMethods.SetWindowLong(form.Handle, WindowMethods.WindowLong.HwndParent, WindowManagerMethods.GetDesktopWindow());
}
}

View file

@ -17,17 +17,14 @@ namespace OnTopReplica.Platforms {
NotificationIcon _icon;
public override void PreHandleFormInit(MainForm form) {
public override void PostHandleFormInit(MainForm form) {
//Do not show in task bar, but display notify icon
//NOTE: this effectively makes Windows ignore the Flip 3D policy set above (on Windows 7)
//NOTE: this also makes HotKey registration critically fail on Windows 7
form.ShowInTaskbar = false;
}
public override void PostHandleFormInit(MainForm form) {
DwmManager.SetWindowFlip3dPolicy(form, Flip3DPolicy.ExcludeAbove);
//Install tray icon
_icon = new NotificationIcon(form);
}

View file

@ -29,6 +29,7 @@ namespace OnTopReplica {
Platform = PlatformSupport.Create();
if (!Platform.CheckCompatibility())
return;
Platform.PreHandleFormInit();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);