Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:20:20+00:00 2026-06-10T06:20:20+00:00

My .NET app is running in the background, and occasionally creates and shows a

  • 0

My .NET app is running in the background, and occasionally creates and shows a form. The form should be visible above all other windows, but without focus.

My first approach was to set the TopMost property of the form, but that fails in many cases for reasons I can’t explain.

Then I tried calling BringToFront in the Shown event handler, but that didn’t do anything.

I also tried BringWindowToTop API, which returned true (= success), but without result.

Now I’m stuck with SetForegroundWindow, which works, but also gives focus to the window (as it should).

Any suggestions would be appreciated.

(Also, is it normal that I can just steal focus without any problem?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:20:22+00:00Added an answer on June 10, 2026 at 6:20 am

    This may help you:

    [DllImport("user32.dll")]
    public static extern bool SetWindowPos (IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
    void Exmpl() {
        IntPtr HWND_TOPMOST = new IntPtr(-1);
        uint SWP_NOACTIVATE = 0x0010;
        uint SWP_NOMOVE = 0x0002;
        uint SWP_NOSIZE = 0x0001;
        SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have about 7 app servers running .NET windows services that ping a single
I have a .NET 4 app running on Windows Server 2008 R2 which I
I have an ASP.NET app running in IIS that is hosting files all great
I have a .Net Compact app running on Windows Mobile, and I want to
I have a .NET console app running on Windows Server 2003, as a scheduled
I am running a large .net 4.0 x86 app on Windows Server 2003 x64
Background : I have a .Net 3.5 WPF Prism-based application running on Windows XP
I'd like to add dvd burning functionality to my .Net app (running on Windows
Does the results of IntPtr.Size show the OS that the .NET app is running
I’ve got an SVN hook written as a .NET console app and running on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.