does vizard handle input differently when it's embedded?
Is there something special I have to do for vizard embedded to get mouse and keyboard?
I need to embed my vizard window in a WPF control. I adapted this tutorial and this one(thanks farshizzo) to suit and made a nice control that starts up a vizard script and passes the handle to the window I've created as the first paramater. The script, if it sees the first parameter, takes that to be a window handle and embeds itself in that window. It almost entirely works. However, I can't seem to get input to go through. Microsoft's tutorial works just fine with their own listbox, but I'm not sure if vizard's input is handled differently. I know the script itself is properly receiving input. If I run this script with the only difference being that it isn't embedded, it responds properly to mouse and keyboard input. I know vizard isn't hanging or blocked out of input: The ball spins, and if I check the keyboard state manually (e.g., viz.key.isDown(' ', True)), I can see if keys are up or down. onkeydown doesn't seem to work, however. p/invoking win32's setfocus does not appear to do anything. here's the vizard script: Code:
import viz Code:
using System; |
I haven't embedded Vizard into a WPF application before, so I'm not too familiar with the subject. Can you verify that Vizard is receiving any Windows message? For example, if you resize the vizard window from within the WPF app, do you receive a viz.WINDOW_SIZE_EVENT or does Vizard adjust projection matrix automatically.
Also, I would suggest making a small change to your Vizard script. Your embedded update loop will never exit, since you are looping over True. Try the following instead: Code:
while not viz.done(): |
Actually I couldn't get vizard to respond to a resize. So I started searching for automatically resizing a hosted window and found a separate solution: involve winforms. Adapting this, I was able to get what I needed. Many thanks for pointing me in the right direction.
It now resizes, responds to input, etc etc. This method is reliant on the main window handle of the vizard process, so I regrettably can't support the console in my nicely encapsulated vizard control. It has to wait for vizard to start up the main form, so there's a quick flash of vizard's graphics window out of place. So to anyone looking to embed a win32 application in a WPF control, I'd say just use winforms. and I guess to answer my own original question, "nope." |
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() |
All times are GMT -7. The time now is 06:49 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC