Thanks for the reply! Actually, I was compiling for 32-bit, so that's not the issue. Although, that's a good tip for someone who may read this later on in a search.
I finally found out what was wrong! I can't believe I couldn't find anyone online with the answer to this. Many people seem to want to be able to do this, but there's no documentation about why OpenCV behaves this way. It turns out that the function "cvNamedWindow" generates more than one window handle. I verified this with a tool called WinExplorer. When I was calling "cvGetWindowHandle", it was getting the wrong handle. Maybe I was using this function for the wrong purpose? Who knows? Who cares?
Instead of using "cvGetWindowHandle", I used a more direct approach. I used the Windows API function "FindWindow".
The syntax of this function is FindWindow(const char* className, const char* windowName). The class name that OpenCV uses for any USABLE window generated with "cvNamedWindow" is "Main HighGUI class". You could leave this argument null, but you may be modifying windows that have nothing to do with your program that just happened to be called something like "example1", so it's not recommended.
The section of code for changing the window's style now looks like this:
1 2 3 4
|
HWND hw = FindWindow("Main HighGUI class", "example1");
LONG nNewStyle = GetWindowLong(hw, GWL_STYLE) & ~WS_SYSMENU;
SetWindowLong(hw,GWL_STYLE,nNewStyle);
SetWindowPos(hw,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DRAWFRAME);
|