473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

TopMost without stealing focus

Is it possible to display a window on top without it stealing focus? (and
I'm not talking about stealing focus from my application - I'm talking about
it stealing focus from any application.) I've read that calling
ShowWindow() with SW_SHOWNOACTIVATE would work but I tried and it didn't.
I'm implementing a Windows Messenger-style notification window that
occasionally pops up with information.

Thanks,
Robert
Nov 16 '05 #1
2 9355
Hi Robert,

Try the following(code for C#):

private const int SW_SHOWNA = 8;
[DllImport("user32", CharSet = CharSet.Auto)]
private extern static int ShowWindow(IntPtr hWnd, int
nCmdShow);

public void ShowWindow()
{
ShowWindow(ownerForm.Handle, SW_SHOWNA);
//ownerForm is the form that you want to retain the
//focus on
}

Please let me know if you still have problem getting it to
work. :)
regards,
Sean

Nov 16 '05 #2
Hi Sean-

Yes, it worked, thank you! I actually tried using SW_SHOWNA before I posted
but I also had TopMost set to true - calling it without setting TopMost
works fine.

Robert
"Sean" <an*******@discussions.microsoft.com> wrote in message
news:1c****************************@phx.gbl...
Hi Robert,

Try the following(code for C#):

private const int SW_SHOWNA = 8;
[DllImport("user32", CharSet = CharSet.Auto)]
private extern static int ShowWindow(IntPtr hWnd, int
nCmdShow);

public void ShowWindow()
{
ShowWindow(ownerForm.Handle, SW_SHOWNA);
//ownerForm is the form that you want to retain the
//focus on
}

Please let me know if you still have problem getting it to
work. :)
regards,
Sean

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: gkelly | last post by:
I have an AppBar that works fine, except for one problem. It's stealing focus -The AppBar is written in C# -Access to it is via a COM object -Main app is a C++ app. -Button on app will use...
12
by: E Goforth | last post by:
Hello, I have a VB6 app that calls a VB.NET app via named pipes and a third party component. Inside the VB.NET app I'm trying to force a form to the top, at least temporarily. Inside a form's...
2
by: Max | last post by:
Hello, My VB.NET application displays a Windows form in a panel on my main form. While my application has the focus, I want the form in the panel to have the "topmost" position, even if it is...
0
by: criscannon | last post by:
Hi, I need to something like a YM notification window that tells whether a user signs in or out. I am able to use animatewindow to show my form. however, whenever the form is shown, my parent...
1
by: damonwischik | last post by:
I'm using the Python Image Library (PIL) for Python 2.4. If I have an image and I show it from PIL import Image im = Image.new('RGB',100,100) im.show() then the output window steals focus....
21
by: Sharon | last post by:
I have added an auto scroll feature to my DataGrid control like this: private void DoAutoScroll() { DataView dv = m_DataGrid.DataSource as DataView; DataGridCell cell = m_DataGrid.CurrentCell;...
0
by: hzgt9b | last post by:
Using VB .NET 2003, I am having problems with a windows application that I have written: Here's the situation. The application I created has a main form that has its TopMost property set to True...
4
by: ATracy | last post by:
How do I load a form as the top most form without setting focus to it? I am using vb.net 2005 Using topmost it take the focus away from the application I am typing into then when it closes it send...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.