簡體   English   中英

C++ Win32:將子 window 附加到主 window

[英]C++ Win32 : Attach a child window to main window

我正在開發基於 C++ 的程序,並且還使用 SiliconSoftware 界面。 正如您從所附的圖片中看到的那樣,我正在使用 c++ win32 代碼運行主要的 window,但是顯示 window 是使用幀采集卡接口創建的,代碼如下:

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,"");

但我想要這個 Diplay window,在 Main Window 中打開。我該怎么做? 任何的想法?在此處輸入圖像描述

假設你有

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

假設它們是無論如何獲得的兄弟姐妹 window 的本地句柄。 要讓 ba 成為 a 的孩子,你必須做

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

現在您必須處理 a 中的 WM_SIZE 並相應地移動 b,以便它與其(新)父級一起調整大小。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM