473,757 Members | 3,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_SHOWNOACTIVA TE 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 9404
Hi Robert,

Try the following(code for C#):

private const int SW_SHOWNA = 8;
[DllImport("user 32", CharSet = CharSet.Auto)]
private extern static int ShowWindow(IntP tr hWnd, int
nCmdShow);

public void ShowWindow()
{
ShowWindow(owne rForm.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*******@disc ussions.microso ft.com> wrote in message
news:1c******** *************** *****@phx.gbl.. .
Hi Robert,

Try the following(code for C#):

private const int SW_SHOWNA = 8;
[DllImport("user 32", CharSet = CharSet.Auto)]
private extern static int ShowWindow(IntP tr hWnd, int
nCmdShow);

public void ShowWindow()
{
ShowWindow(owne rForm.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
1337
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 com to access C# object which pops up AppBar -When the appbar is floating it works fine, but when it is docked it wants to have the focus all the time. -If you click on the main app window the focus will blink and go back to the
12
7537
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 public sub I'm doing: Public Sub ThisIsMySub(TheseAreMyArguments) Me.Show Me.WindowState = FormWindowState.Normal Me.TopMost = True
2
3839
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 not the active form. Everything works as expected, but if the user selects another application by pressing a tab in the taskbar, then my "topmost" form still occupies the "topmost"
0
1388
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 form loses focus. In that scenario of YM, the notify window is animated without stealing focus from the main window. I have tried using ShowWindow noactivate but it doesn't work with animatewindow, in which case, the window is show nonactive but is...
1
1689
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. It's very handy to use an image to show the progress of execution for my program, but the computer is unusable when focus keeps on being stolen every few seconds. How can I prevent Image.show() from stealing
21
9982
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; cell.RowNumber = dv.Count; m_DataGrid.CurrentCell = cell; } But this the last line of this code is putting the focus on the current
0
1788
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 (so that the form is always on top). During the execution of the application, a new process is created using "Process.Start(<some app>)". The problem is that after I start a new process, my main form no longer has focus, so all keyboard events are...
4
9440
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 the focus back.
7
11929
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' and it steals the focus from the user's current application. How can I prevent the hidden WebBrowser from stealing focus? (And better yet can I even suppress that click?_
0
10069
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9735
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8736
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.