• 0

C#\VB Always Have Focus


Question

fusi0n

I'm in the process of writing an app that needs to launch using the Windows Logon Script. The issue, when it launches, the start menu steals the focus as it's being loaded causes the need to do a "double click" when a single click will work. After the start menu loads, it gets focus back. I've tried a few different ways and tried C# and VB. I couldn't pin down the issue on what was causing it, but this seems like it.

 

Here is my code so far, its basic and in a POC state.

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            FormBorderStyle = FormBorderStyle.None;
            WindowState = FormWindowState.Maximized;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Show();
            button1.Focus();
            this.TopMost = true;
            this.Activate();
        }
    }
}

If you know how to do this in C# or VB, that would be great.

Thanks

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
DevTech

What do you want your program to do/achieve? (i.e. provide context, objectives, the big picture)

 

Link to post
Share on other sites
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.