0

I'm creating an installer which has WPF front end. When I launch a pre-requisite installation from my code, the installer loses focus. As a result the task bar is displayed. I do not want the task bar to be displayed at any stage when the UI is running. I tried to add hooks to the window activated and deactivated events but they do not work as well. Below is my code. Please advice.

<Window x:Class="CustomBA.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:resources="clr-namespace:KubeCustomBA.Resources"
    mc:Ignorable="d"
    Title="Installer" Activated="window_Activated" Deactivated="Window_Deactivated" Width="1431" MinWidth="400" Height="588.9" MinHeight="300" ResizeMode="NoResize" WindowStyle="None" WindowState="Maximized" ShowInTaskbar="False" Topmost="False" WindowStartupLocation="CenterOwner" Background="#FF222222">

 void window_Activated(object sender, EventArgs e)
    {
        this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
        this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
        this.Topmost = true;
        this.Top = 0;
        this.Left = 0;
    }

    private void Window_Deactivated(object sender, EventArgs e)
    {
        this.Topmost = true;
        this.Activate();
    }
AnOldSoul
  • 4,017
  • 12
  • 57
  • 118
  • 1
    Related : http://stackoverflow.com/questions/3729369/topmost-is-not-topmost-always-wpf –  Jul 07 '16 at 04:07
  • The solution in that question is the same as mine. Setting Topmost to true which doesn't work – AnOldSoul Jul 07 '16 at 04:09
  • 1
    Did you read the comment "There is no SuperDuperTopMost option" ? If every app in your windows use TopMost, where will be the TopMost ? –  Jul 07 '16 at 04:12
  • So there isn't a solution for making an application strictly fullscreen? Showing the desktop is a security concern in my situation. If other apps easily gain control over mine and show the desktop, then that is a huge threat in my scenario. Any solutions you can think of? – AnOldSoul Jul 07 '16 at 04:14
  • I write once a GUI for PLC. That was like that. Fullscreen. It means nobody can access that PC. Only you can access that PC and do something. Make your apps fullscreen. –  Jul 07 '16 at 04:16
  • The other "apps" here are not mine. Those are pre-requisites I install. Like Java installer, dot net installer etc. – AnOldSoul Jul 07 '16 at 04:37
  • Install it all, and remove all autoaupdates, remove autostart. So the only apps running is your apps. And no one can access that pc, only to your apps. TopMost to true, and Remove the Close button and deactivate Close also. –  Jul 07 '16 at 04:40
  • See also https://stackoverflow.com/questions/25646901/how-to-open-an-application-window-while-there-is-another-application-active-in-f and of course [How do I create a topmost window that is never covered by other topmost windows?](https://blogs.msdn.microsoft.com/oldnewthing/20110310-00/?p=11253) and [What if two programs did this?](https://blogs.msdn.microsoft.com/oldnewthing/20050607-00/?p=35413) – Peter Duniho Jul 07 '16 at 07:08
  • _"Showing the desktop is a security concern in my situation"_ -- seems unlikely. But in any case, you have no way to avoid it. Your program does not have the last word on what window the user's looking at. The user does. Even if you write a full-screen app, covering _everything_ else up, the user can always task-switch, show the desktop, whatever. If your security depends on the user not being able to see other things in their own login session, your security model is completely broken. – Peter Duniho Jul 07 '16 at 07:11

0 Answers0