title: Windows Form Window Always Focused?
body: <p>I know there are a few threads about this already. What I need is to have a windows form window always focused meaning if I click on notepad or whatever program it will not enter any data in it and only enter data in my windows form textbox. </p>
  
  <p>I found this code which works somewhat will explain more </p>
  
  <pre><code>    //Delegates for safe multi-threading.
      delegate void DelegateGetFocus();
      private DelegateGetFocus m_getFocus;
      Thread newThread;
  
      public MemberLogin()
      {
  
          m_getFocus = new DelegateGetFocus(this.getFocus);  
          InitializeComponent();
          spawnThread(keepFocus);
          toggleFocusButton.Text = "OFF";
          timer1.Interval = 2000;
          textBox1.Select();
      }
  
      //test focus stuff
      //Spawns a new Thread.
      private void spawnThread(ThreadStart ts)
      {
          try
          {
              newThread = new Thread(ts);
              newThread.Start();
          }
          catch (Exception e)
          {
              MessageBox.Show(e.Message, "Exception!", MessageBoxButtons.OK,
                  MessageBoxIcon.Error);
          }
      }
  
      //Continuously call getFocus.
      private void keepFocus()
      {
          while (true)
          {
              getFocus();
          }
      }
  
      //Keeps Form on top and gives focus.
      private void getFocus()
      {
          //If we need to invoke this call from another thread.
          if (this.InvokeRequired)
          {
              this.Invoke(m_getFocus, new object[] { });
          }
          //Otherwise, we're safe.
          else
          {
              //having this seemed to have kept my windows onTop at all times even when off 
             // this.TopMost = true;
              this.TopMost = true;
              this.Activate();
              this.textBox1.Select();
              this.textBox1.Focus();
  
          }
      }
  </code></pre>
  
  <p>this code seems to work well only when my project is opened meaning when my Visual Studio Project is closed the window is top most but doesn't have focus meaning I can type inside other programs. Weird thing I found is that both notepad and my textbox had blinking line thing telling where you write the text. If I run my app from the Visual Studio project everything works as it should and when I try to click on other windows it won't let me access which is what I want. </p>
  
  <p>So I'm a bit confused on why it only works properly with the project opened</p>
  
  <p>Also note as long as the project is opened then even .exe and other copys I made work properly I close the project solution and the program does what I explained above. </p>
  
  <p>Just did some more testing and it seems to only work properly when this process is running vhost.exe which is the Visual Studio hosting process. I disabled it in the settings, and when I launch from VS it works fine but when I run just the exe in the bin folder I still get the weird results </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here's a quick video I made with my results <a href="http://www.youtube.com/watch?v=1ozpHSRGnMo" rel="nofollow noreferrer">http://www.youtube.com/watch?v=1ozpHSRGnMo</a></p>
  
  <p><strong>New Edit</strong></p>
  
  <p>What I did to fix this was set my app in a fullscreen mode kinda by doing this so the user can go clicking on other windows without closing this one first</p>
  
  <pre><code>this.FormBorderStyle = FormBorderStyle.None;
  this.WindowState = FormWindowState.Maximized;
  </code></pre>