Hello Robin,
I do not know if it is a problem coming after a Windows update or in SharpCap (4.1 or 4.2),
but in all my scripts, the form.TopMost or form.TopLevel functions are no more working properly.
It does not show the script window on the top of SharpCap at the first start of the software.
If I close the script and restart it ... then at the second start, it shows the script window on the top.
So the question is ... why not at the first start of the script ?
It is a little bit annoying. I know this and start my script 2 times for having the script window all the time visible on the top of SharpCap window.
Regards,
Jean-Francois
TopMost or TopLevel no more working properly
-
Jean-Francois
- Posts: 859
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
- admin
- Site Admin
- Posts: 17606
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: TopMost or TopLevel no more working properly
Hi,
Windows has become very fussy about allowing things to become topmost, or to set themselves as the foreground window - basically it will often ignore such requests unless various conditions are satisfied at the time of the request (and the conditions are long, complex and can change). Microsoft actually does this for a good reason - to make it hard to write software that springs into the foreground in front of what you were working on.
Rather than fighting with the moving target of topmost/foreground, it's probably easier to make the main SharpCap window the 'owner' of your forms. In that way the system will ensure that your windows are always in front of SharpCap, and they should minimize when SharpCap is minimized. This *should* be as simple as passing 'SharpCap.MainWindow' as the parameter when you call 'Show' on your forms...
ie
myform.Show()
becomes
myform.Show(SharpCap.MainWindow)
I hope this helps,
Robin
Windows has become very fussy about allowing things to become topmost, or to set themselves as the foreground window - basically it will often ignore such requests unless various conditions are satisfied at the time of the request (and the conditions are long, complex and can change). Microsoft actually does this for a good reason - to make it hard to write software that springs into the foreground in front of what you were working on.
Rather than fighting with the moving target of topmost/foreground, it's probably easier to make the main SharpCap window the 'owner' of your forms. In that way the system will ensure that your windows are always in front of SharpCap, and they should minimize when SharpCap is minimized. This *should* be as simple as passing 'SharpCap.MainWindow' as the parameter when you call 'Show' on your forms...
ie
myform.Show()
becomes
myform.Show(SharpCap.MainWindow)
I hope this helps,
Robin
-
Jean-Francois
- Posts: 859
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: TopMost or TopLevel no more working properly
Hello,
It works !

Sometimes the solution can be so simple.
Many thanks,
Jean-Francois
It works !
Sometimes the solution can be so simple.
Many thanks,
Jean-Francois