简体   繁体   中英

How do I keep an OpenCV namedWindow with a HWND handle on top of all other windows in Windows 8?

The title pretty much says it all. I've created a window with namedWindow() and filled it with a matrix. I then assign it to a HWND using cvGetWindowHandle() so that I can use the Windows function SetWindowPos(). Using this I'm supposed to be able to set the flags HWND_TOPMOST, SWP_NOMOVE and SWP_NOSIZE in order to keep it above all other windows even when I click on a window behind it.

I've either misread something here and got the wrong idea or I believe that the problem might be the fact that I have upgraded to Windows 8 and they have deprecated this function or something. Is there another way to go about this?

I don't have a setup to try this in c++, but I wanted to do something similar in python so I ended up using a python win32 library. With a combination of the following calls (I assume you can find them for win32 in c++), I always managed to get the screen on top. But it didn't stay there. I had to bring it up when I wanted it.

win32gui.SetForegroundWindow(hwnd)  # I use just this. apparently it can trigger permission error but I never had a problem with it
win32gui.SetFocus(hwnd)  # apparently doesn't trigger error without permission like setforegroundwindow
win32gui.BringWindowToTop(hwnd)  # not sure if this helps any
win32gui.SetActiveWindow(hwnd) #not sure if this helps any

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM