如何在父窗口中打开子窗口数据 [英] How to open child window data in parent window
问题描述
你好!
我做简单的图片编辑器,使用openCV libriary,我面对,当我使用openCV libriary时,我需要在hWnd中打开的图像在他自己的子窗口打开,我不知道,如何从子窗口获取图片,并在父窗口中设置。
什么我试过了:
Hello!
I do simple picture editor,using openCV libriary,and i faced , that when i use openCV libriary,image that i need to open in hWnd opens in his "own" child window,and i don't know,how to get picture from child window,and set in parent window.
What I have tried:
int MyOpenFile(HWND hWnd)
{
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hWnd;
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = L"Bitmap files(*.bmp)\0*.bmp\0JPEG files(*.jpg)\0*.jpg\0All files(*.*)\0*.*\0\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
GetOpenFileName(&ofn);
wcstombs(filename,szFile,255);
hdc = GetDC(hWnd);
memDC = CreateCompatibleDC(hdc);
image = cvLoadImage(filename, CV_LOAD_IMAGE_UNCHANGED);;
dst = cvCloneImage(image);
cvShowImage("image",image);//this func creates its own window,but i don't know
//how to display image in parent window
cvWaitKey(0);
cvReleaseImage(&image);
cvDestroyAllWindows();
ReleaseDC(hWnd, hdc);
UpdateWindow(hWnd);
return 0;
}
我试过这个MFC算法,但它在Winapi中不起作用,但我认为它是正确的,但不适用于winapi,请告诉我如何在winapi中正确使用
I've tried this MFC algorithm,but it doesn't work in Winapi,but i think it's correct,but not for winapi,please tell me how to use it correctly in winapi
cvNamedWindow("IDC_STATIC_OUTPUT", 0);
cvResizeWindow("IDC_STATIC_OUTPUT", 420, 240);
hWnd = (HWND)cvGetWindowHandle("IDC_STATIC_OUTPUT");
HWND hParent = ::GetParent(hWnd);
::SetParent(hWnd, GetDlgItem(hWnd, ));
::ShowWindow(hParent, SW_HIDE);
cvShowImage("IDC_STATIC_OUTPUT", frame_copy)
提前谢谢!
Thank you in advance!
推荐答案
您必须在窗口中显示正确的语法:
You must use the correct syntax by showing it in your window:
cvShowImage("MyWindowName",image);//use your windows (else it creates a new one
你不是使用MFC,但使用Windows-API。不要混用它们。
请花一些时间挖掘 OpenCV教程。通常有大量的代码,这对你有帮助。
You arent using MFC, but Windows-API. Dont mix them.
Please spend some time by digging trough the OpenCV Tutorials. Often are tons of code in it, which will helpful to you.
这篇关于如何在父窗口中打开子窗口数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!