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(The seAreMyArgument s)
Me.Show
Me.WindowState = FormWindowState .Normal
Me.TopMost = True
Me.TopMost = False
End Sub
However, my form doesn't pop on top like I'd expect it to. BTW the form
is an MDIParent.
I wrote a simple proof-of-concept VB.NET application with a timer
control on an MDI Parent form. I do the same steps as above it works as
I'd expect. When the timer_tick event fires my MDIParent form pops on
top. I can then move another app on top of it or minimize my MDIParent
form. The next time the timer_tick event fires it pops back on top.
The only thing that I could figure out is that another form in my app
had it's TopMost property set to True. I have a StatusBar form that
does this, but I did some checking and its unloaded by the time I do my
"Me.TopMost = True
" Any idea what could be going on?
Thanks,
Eric
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! 12 7535
In article <Oc************ **@TK2MSFTNGP10 .phx.gbl>, E Goforth wrote: 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(The seAreMyArgument s) Me.Show Me.WindowState = FormWindowState .Normal Me.TopMost = True Me.TopMost = False End Sub
However, my form doesn't pop on top like I'd expect it to. BTW the form is an MDIParent.
I wrote a simple proof-of-concept VB.NET application with a timer control on an MDI Parent form. I do the same steps as above it works as I'd expect. When the timer_tick event fires my MDIParent form pops on top. I can then move another app on top of it or minimize my MDIParent form. The next time the timer_tick event fires it pops back on top.
The only thing that I could figure out is that another form in my app had it's TopMost property set to True. I have a StatusBar form that does this, but I did some checking and its unloaded by the time I do my "Me.TopMost = True " Any idea what could be going on?
Thanks, Eric
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Since windows 98 you can't force a window to the foreground if another
application window has focus. The only way, I know of to get around
this behavior on all os's is to use P/Invoke to find the threadid of the
current foreground window and then call AttachThreadInp ut to attach to
that threads input queue - you can then call SetForegroundWi ndow to move
your application to the front, andt then call AttachThreadInp ut again to
detach from the thread input queue...
I know it sounds complex, but it goes something like (air code):
Dim currentForegrou nd As IntPtr = GetForegroundWi ndow()
If currentForegrou nd = Me.Handle Then
SetForegroundWi ndow(Me.Handle)
Else
Dim processId As IntPtr
Dim threadId As IntPtr = GetWindowThread ProcessId( _
currentforegrou nd, processId)
Dim currenThread as IntPtr = GetCurrentThrea d()
AttachTheadInpu t(currentThread , threadId, True)
SetForegroundWi ndow(currentFor eground)
AttachThreadInp ut(currentThrea d, threadId, False)
End If
In Windows ME and above, you can call AllowSetForegro undWindow to give
the other process specific permission to steal focus - but it won't work
on windows 98, so I prefere the above method. I hope I haven't forgot
anythign :) I do have a working example of this - though it is in C#,
so if you can't get it working I can try and dig it out.
--
Tom Shelton
MVP [Visual Basic]
In article <uq************ **@TK2MSFTNGP11 .phx.gbl>, Tom Shelton wrote: In article <Oc************ **@TK2MSFTNGP10 .phx.gbl>, E Goforth wrote: 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(The seAreMyArgument s) Me.Show Me.WindowState = FormWindowState .Normal Me.TopMost = True Me.TopMost = False End Sub
However, my form doesn't pop on top like I'd expect it to. BTW the form is an MDIParent.
I wrote a simple proof-of-concept VB.NET application with a timer control on an MDI Parent form. I do the same steps as above it works as I'd expect. When the timer_tick event fires my MDIParent form pops on top. I can then move another app on top of it or minimize my MDIParent form. The next time the timer_tick event fires it pops back on top.
The only thing that I could figure out is that another form in my app had it's TopMost property set to True. I have a StatusBar form that does this, but I did some checking and its unloaded by the time I do my "Me.TopMost = True " Any idea what could be going on?
Thanks, Eric
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Since windows 98 you can't force a window to the foreground if another application window has focus. The only way, I know of to get around
I should clarify, that it is a window of another process. If the window
is in your own process, then all is ok :)
<snip>
--
Tom Shelton
MVP [Visual Basic]
Hello,
I'm doing my development/testing on an XP box, which is what the users
will be running. Maybe some Win2k, but certainly no Win9x. If you
can't force a window to the foreground if another application window has
focus, how come my proof-of-concept app VB.NET app works so nicely. I
minimize my VB.NET form open up several applications and it pops on top
when the timer fires. I then shift focus back to my other apps or
minimize my VB.NET form and it pops back on top when the timer fires
again, ad infinitum
-Eric
Tom Shelton wrote: In article <Oc************ **@TK2MSFTNGP10 .phx.gbl>, E Goforth wrote: 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(The seAreMyArgument s) Me.Show Me.WindowState = FormWindowState .Normal Me.TopMost = True Me.TopMost = False End Sub
However, my form doesn't pop on top like I'd expect it to. BTW the
form is an MDIParent.
I wrote a simple proof-of-concept VB.NET application with a timer control on an MDI Parent form. I do the same steps as above it works
as I'd expect. When the timer_tick event fires my MDIParent form pops
on top. I can then move another app on top of it or minimize my
MDIParent form. The next time the timer_tick event fires it pops back on top.
The only thing that I could figure out is that another form in my app had it's TopMost property set to True. I have a StatusBar form that does this, but I did some checking and its unloaded by the time I do
my "Me.TopMost = True " Any idea what could be going on?
Thanks, Eric
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Since windows 98 you can't force a window to the foreground if another application window has focus. The only way, I know of to get around
I should clarify, that it is a window of another process. If the window
is in your own process, then all is ok :)
<snip>
--
Tom Shelton
MVP [Visual Basic]
..
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
In article <ee************ **@TK2MSFTNGP11 .phx.gbl>, E Goforth wrote: Hello,
I'm doing my development/testing on an XP box, which is what the users will be running. Maybe some Win2k, but certainly no Win9x. If you can't force a window to the foreground if another application window has focus, how come my proof-of-concept app VB.NET app works so nicely. I minimize my VB.NET form open up several applications and it pops on top when the timer fires. I then shift focus back to my other apps or minimize my VB.NET form and it pops back on top when the timer fires again, ad infinitum
-Eric
It seems I misread what your trying to do... I thought you were trying
to take the input focus. That is accomplished via the
SetForegroundWi ndow API and that does not work accross processes. What
you are describing is the SetWindowPos function - moving a window to the
top of the z-order. That does work, but it does not steal the input
focus - in other words, the window pops forward, but the window that
previously had focus still does...
Simple test, open notepad and start typing. Even after the window pops,
you will still be typing in notepad (this is the behavior that I get on
my XP box). The only way to gain input focus is to use the method I
described (or you can use the AllowSetForegro undWindow API since your
on 2K and XP)
Making a topmost window with setwindowpos (which is what is happing with
the TopMost property), is only valid until another window is made
topmost. I presume that there is another window that is stealing the
topmost position.
Is there any way you can post some code that recreates the problem? It
would be much easier to diagnose if there was a small example.
--
Tom Shelton
MVP [Visual Basic]
Hello,
Is there a good way to tell which window is getting stealing TopMost
away from my Window? I put some trace statements in my code and they
indicated that the only likely culprit I could think of was closed and
set to Nothing by the time that my form was set TopMost.
Is it possible that the Garbage Collector hasn't cleaned up the suspect
form by the time my form is set TopMost? Does TopMost care if there's
another TopMost form in the garbage?
Tom Shelton wrote:
-------------------------------------
In article <ee************ **@TK2MSFTNGP11 .phx.gbl>, E Goforth wrote: Hello,
I'm doing my development/testing on an XP box, which is what the users will be running. Maybe some Win2k, but certainly no Win9x. If you can't force a window to the foreground if another application window
has focus, how come my proof-of-concept app VB.NET app works so nicely. I minimize my VB.NET form open up several applications and it pops on
top when the timer fires. I then shift focus back to my other apps or minimize my VB.NET form and it pops back on top when the timer fires again, ad infinitum
-Eric
It seems I misread what your trying to do... I thought you were trying
to take the input focus. That is accomplished via the
SetForegroundWi ndow API and that does not work accross processes. What
you are describing is the SetWindowPos function - moving a window to the
top of the z-order. That does work, but it does not steal the input
focus - in other words, the window pops forward, but the window that
previously had focus still does...
Simple test, open notepad and start typing. Even after the window pops,
you will still be typing in notepad (this is the behavior that I get on
my XP box). The only way to gain input focus is to use the method I
described (or you can use the AllowSetForegro undWindow API since your
on 2K and XP)
Making a topmost window with setwindowpos (which is what is happing with
the TopMost property), is only valid until another window is made
topmost. I presume that there is another window that is stealing the
topmost position.
Is there any way you can post some code that recreates the problem? It
would be much easier to diagnose if there was a small example.
-------------------------------------
Eric Goforth
Raleigh, NC
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
On 2003-10-15, E Goforth <an*******@devd ex.com> wrote: Hello,
Is there a good way to tell which window is getting stealing TopMost away from my Window? I put some trace statements in my code and they indicated that the only likely culprit I could think of was closed and set to Nothing by the time that my form was set TopMost.
Is it possible that the Garbage Collector hasn't cleaned up the suspect form by the time my form is set TopMost? Does TopMost care if there's another TopMost form in the garbage?
Well, you may try to call Dispose on the form when your done with it -
but I don't think that will solve the problem. If you set a new TopMost
window, then that should automatically invalidate any other window as
the topmost....
What you may try is to use the GetTopWindow function, do see which is
the topmost window...
Declare Function GetTopWindow Lib "user32.dll " (ByVal hWnd As IntPtr) As IntPtr
You can pass in your main forms handle, and it should return the handle
of the window at the top of the zorder... This may serve as a check
anyway...
HTH
--
Tom Shelton
MVP [Visual Basic]
Hi E, Tom,
I may be wrong on this but it makes sense that FormX.Close calls
FormX.Dispose. And this should release all unmanaged resources immediately as
it knows that FormX has been finshed with. Then FormX can sit in the GCs pile
until Doomsday. My understanding is that the cleaning up that's done in
Finalize should be the just-in-case-they-didn't-call-Dispose type of stuff.
Regards,
Fergus
On 2003-10-16, Fergus Cooney <fi******@tesco .net> wrote: Hi E, Tom,
I may be wrong on this but it makes sense that FormX.Close calls FormX.Dispose. And this should release all unmanaged resources immediately as it knows that FormX has been finshed with. Then FormX can sit in the GCs pile until Doomsday. My understanding is that the cleaning up that's done in Finalize should be the just-in-case-they-didn't-call-Dispose type of stuff.
Regards, Fergus
You maybe right on the Close calling dispose... I'll have to check that
out. Either way, I don't think that's his problem. I think it is going
to boil down to his communication method myself, but just trying to
cover all the bases :)
--
Tom Shelton
MVP [Visual Basic]
Hello,
Do the AllowSetForegro undWindow and SetForegroundWi ndow APIs make the
window in the foreground permanently? I just want it to pop to the top
of the z-order, but then allow the user to put other windows on top, if
they want to.
Eric Goforth
Raleigh, NC
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JaguarX |
last post by:
I have an application that needs a window to stay on top of the other ones, I thought that TopMost = true would be suitable for this feature but it also makes this window to stay on top of all other application running on my PC, Does anybody know How can I prevent this TopMost window appear when I switch to the other applications??
_______________________
JaguarX
|
by: Hovhannes Asatryan |
last post by:
Hello guys.
I have a problem with a topmost form.
I am writting in C#.
I have Mdi Form wich has 2 child forms.
I want to set one of them as a topmost window, but when I sets MdiParent the
TopMost property does not working.
How can I set the one form as a topmost?
Can anyone send me code example?
|
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"
|
by: SamSpade |
last post by:
I learned about the TopMost property from a recent post which solved some
problems.
But I have a situation where a control wants to make the form it is on be
the topmost.
It could raise an event but be cleaner if it could do it directly.
I tried the following but the compiler thinks Parent is a control (they
don't have a topmost property.)
|
by: Strahimir Antoljak |
last post by:
I'm running VS.NET 2002 and keep having problems with form keeping on top
with its TopMost property. Sometimes my program places the invoked form on
top sometimes not. Sometimes when I click on the form it stays on top as it
should, but sometimes TopMost property does not pick up so if I click to
some other program it covers the form which supposed to remain on the top.
Has anyone experienced similar problems? is there a fix? or I am...
| |
by: facicad |
last post by:
I would like to set topmost another prog. from my program.
Ex: I use AutoCAD, run my prog. from autocad. My prog. is topmost but went I
would like to pick some object in autocad, I set TopMost to false and I
would like to autocad bring to front, but for autocad object, it not have
TopMost properties
|
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...
|
by: Phil Galey |
last post by:
I have a small application, which is to always stay on top. Another
application, which it is supposed to stay on top of, is QuarkXPress 5. I'm
using Me.TopMost = True in the Form1_Deactivate event, and it works almost
perfectly. It always stays on top, except when I click on one of the tools
in the floating tool bar of QuarkXPress. Anything else in QuarkXPress is no
problem ... document, menus, etc. But click on anything on...
|
by: Gary Brown |
last post by:
Hi,
I have a dialog box that must behave as MessageBox does
with regard to the TopMost property. It must be TopMost if
and only if the calling form is TopMost. A static method
creates the dialog box. Is there a way of determining if the
application is TopMost from a static method?
There are some inelegant workarounds but I would prefer to
do whatever MessageBox does.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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...
|
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,...
|
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...
|
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();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |