View Single Post
  #4  
Old 06-28-2012, 09:07 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I'm not sure this will work, but another method is to reparent the Vizard graphics window to the WPF window, instead of reusing the WPF window handle. This is what the Vizard Script -> Run Docked command does, and input messages still work properly.

Let the Vizard script create its own window as usual, but parent it to the handle passed to the command line:
Code:
viz.go()

import win32gui
import win32con

if(len(sys.argv) > 1):

    viz.window.setBorder(viz.BORDER_NONE)
    viz.window.setPosition([0,0])

    hwndChild = viz.window.getHandle()
    hwndParent = int(sys.argv[1])

    style = win32gui.GetWindowLong(hwndChild,win32con.GWL_STYLE)
    style = style | win32con.WS_CHILD
    style = style & ~(win32con.WS_OVERLAPPEDWINDOW | win32con.WS_POPUP)
    win32gui.SetWindowLong(hwndChild,win32con.GWL_STYLE,style)

    win32gui.SetParent(hwndChild ,hwndParent)
One important step with this method is that you will need to manually resize the Vizard graphics window when the parent window is resized. If you know the WPF control will always remain the same size, then you can hard code the size of the window in the Vizard script, or pass it as an argument.
Reply With Quote