2012-04-04 5 views
2

C++의 프로그램 기반에서 작업 중이며 SiliconSoftware 인터페이스도 사용하고 있습니다. 당신은 내가 C++에서 Win32 코드로 메인 윈도우를 실행하고 첨부 pisture에서 볼 수 있지만, 같은 디스플레이 창은 다음 코드를 사용하여 프레임 그래버 inteface을 만들어집니다 :C++ Win32 : 기본 창에 자식 창 부착

int Bits=8; int nId =::CreateDisplay(Bits,GrabberOptions::getWidth(),GrabberOptions::getHeight());SetBufferWidth(nId,GrabberOptions::getWidth(),GrabberOptions::getHeight());::DrawBuffer(nId,Fg_getImagePtrEx(fg,lastPicNr,0,_memoryAllc),lastPicNr,""); 

하지만 오픈이으로 모니터 창을 원하는 메인 윈도우 내에서. 어떻게해야합니까? 어떤 생각? enter image description here

+1

네이티브 Win32가 아닙니다. 실제로 더 C++ 랩퍼를 사용하고 있습니다. –

+0

Visual Stadio로 프로젝트를 만들었지 만 "빈 프로젝트"옵션을 사용하지 않아 Visual Studio에서 기본 창을 만들었습니다. 창에 대한 코드 : BOOL InitInstance (HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // 인스턴스 변수를 전역 변수에 저장 hWnd = CreateWindow (szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, NULL, hInstance, NULL); if (! hWnd) { return FALSE; } ShowWindow (hWnd, nCmdShow); UpdateWindow (hWnd); return TRUE; } – user261002

+0

창을 만든 후에 "첨부"할 방법이 없습니다. 프레임 그래버 API가 옵션을주지 않는다면 운이 없어집니다. –

답변

4

의 그들이 아무리 얻을 수없는 창을 형제의 기본 핸들이 assumig 당신이

HWND a = ... 
HWND b = ... 

있다고 가정 해 봅시다. 당신이에서 WM_SIZE를 처리하고 그것의 (새) 부모와 함께 크기를 조정할 수 있도록, 그에 따라 B를 이동해야 Nowm 가의 자식 b를 만들려면, 당신은

Setparent(b,a); //a will be the new parent b 
DWORD style = GetWindowLong(b,GWL_STYLE); //get the b style 
style &= ~(WS_POPUP|WS_CAPTION); //reset the "caption" and "popup" bits 
style |= WS_CHILD; //set the "child" bit 
SetWindowLong(b,GWL_STYLE,style); //set the new style of b 
RECT rc; //temporary rectangle 
GetClientRect(a,&rc); //the "inside border" rectangle for a 
MoveWindow(b,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top); //place b at (x,y,w,h) in a 
UpdateWindow(a); 

을해야한다.