修改opencv的namedWindow窗口位置

来源:互联网 发布:引导弹升级数据 编辑:程序博客网 时间:2024/05/18 08:11

 

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

 

//by dongchunxiao shuleikeji


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);shuleikeji