【VS开发】MFC修改Opencv namedWindow的风格

当在MFC中应用opencv的窗口来显示图片。希望namedWindow创建的窗口能根据需要改变风格:

 

//by dongchunxiao


cv::namedWindow("windows1",0); //创建一个窗口 
HWND hWnd = (HWND)cvGetWindowHandle("windows1");//获取子窗口的HWND
HWND hParentWnd = ::GetParent(hWnd);//获取父窗口HWND。父窗口是我们要用的

::SetWindowPos(hParentWnd,HWND_TOPMOST,100,1,500,500,SWP_NOSIZE | SWP_NOMOVE); //修改窗口为最顶部

//隐藏窗口标题栏 
long style = GetWindowLong(hParentWnd,GWL_STYLE); 
style &= ~(WS_CAPTION); 
// style &= ~(WS_MAXIMIZEBOX); 
SetWindowLong(hParentWnd,GWL_STYLE,style);

//改变窗口的位置和大小。这里主要前面的SetWindowPos不能改变位置和大小(为什么?)
::MoveWindow(hParentWnd,10,100,500,500,0);

原文地址:https://www.cnblogs.com/huty/p/8517226.html