0

I created a window as a child window of a C++ window handler in C#, the code is like:

public void CreateHostHwnd(IntPtr parentHwnd)
        {
            // Set up the parameters for the host hwnd.
            parentHandle = parentHwnd;
            HwndSourceParameters parameters = new HwndSourceParameters("Video Window", 351, 295);
            parameters.WindowStyle += WS_CHILD;
            parameters.SetPosition(0, 0);
            parameters.ParentWindow = parentHwnd;

            // Create the host hwnd for the visuals.
            HwndSource myHwndSource = new HwndSource(parameters);
        }

However, after this child window is created, I cannot change its size by using

parameters.SetSize(width, height);

Are there any way to change its size after it is created? Thank you~!

  • I am not familiar with this but I saw in the MSDN that there is a SizeToContent property to the HwndSource. Try to set it to SizeToContent.WidthAndHeight. Try also to use width and height instead of SetSize. – ehh Mar 14 '17 at 14:23
  • Hi, I tried that before, it makes some change to it but not as what I want, I will read a little more about SizeToContent, maybe it is the one should be used, thank you~! – Xiangtianyu Kong Mar 14 '17 at 14:29
  • Ok, try to look also at this post: http://stackoverflow.com/questions/10676649/attach-window-to-window-of-another-process – ehh Mar 14 '17 at 14:29
  • Hi, still cannot change the size, this one shows how to initialize a window but after its created, still cannot change its size. – Xiangtianyu Kong Mar 14 '17 at 20:37

0 Answers0