开发者

SetWindowPos() not moving or resizing window

I have a GUI application that is using GStreamer to capture video from capture cards, and then play the video. The audio and video streams are sent to GStreamer, and GStreamer automatically opens its own window to play the video. Once the video window is open, I need to take the video window and remove the border and set the window size and position and make my GUI window the parent of that window so that it will be "anchored" to my GUI window.

Since I know the name of the video window I am using FindWindow() to get an HWND handle to the window. I am then passing that HWND to SetWindowPos() as follows SetWindowPos(VideoWindow, GUIWindow, GUIWindowLeft, GUIWindowTop开发者_运维问答, 640, 360, SWP_SHOWWINDOW). Then I set the parent of the video window SetParent(VideoWindow, GUIWindow).

When I start my application, for a very brief moment it looks like my window is being resized and placed correctly but then the window returns to its default position (almost like it is just neglecting that SetWindowPos() was even called). Is there an obvious reason for why this happens? I am new to window manipulation so it is very possible I am making a simple mistake, but it does not make since why my window would be positioned correctly for a very brief moment but then move back to default position.


This is because the SWP_SHOWWINDOW or SWP_HIDEWINDOW is set, the window won't be moved or resized (see SetWindowPos documentation). Seems a little strange. Try using a different flag.

From the docs:

If the SWP_SHOWWINDOW or SWP_HIDEWINDOW flag is set, the window cannot be moved or sized.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜