||Posted - Jun 18 2007 : 10:19:32 AM
Hey guys, you may remember me as the landscape renderer idiot. Now I've got another seemingly simple question.
Instead of setting a userform as my window in which to render, I'd like to use a PictureBox. I try to create a device by passing the CreateDevice method the hWnd of my PictureBox, but I get an automation error. How descriptive those automation errors are.
I tried setting all my PictureBox properties to the same as the form's (note that the code DOES work when the PictureBox isn't the target), excluding LinkTopic (because I can't and shouldn't have to set that anyway). No dice.
Is there some flag I have to specify to get D3D to create a device inside a PictureBox?
Any advice is appreciated!
I'm using DirectX 8 and VB6. I'll have code as soon as I get to my other computer, but for now anyone who wants to help can simulate the problem by setting the DeviceWindow to the hWnd of a PictureBox.
||Posted - Jun 24 2007 : 6:05:45 PM
Thanks very much for your reply, Eric!
The bug actually had something to do with the current display mode: you can't set the BackBuffer height/width manually. Since it is WINDOWED (key point), you need to tell DirectX to use the current display mode.
I completely overlooked that.
Thanks again for the reply, though. (Those were all things I checked except for the ScaleMode; I have it set to pixels now as per your suggestion to prevent any future problems).
||Posted - Jun 24 2007 : 10:59:38 AM
make sure the scale mode on the picturebox is set to pixels.
also, make sure the picturebox is visible and created first. In your form_Load event, put "Me.Show" before you try to initialize directx.
Also, the picturebox AutoRedraw might have something to do with it.