|
-
Mar 31st, 2002, 03:49 PM
#1
Thread Starter
Fanatic Member
Direct X and VB.Net...
Has anyone tried to write a VB.Net game yet?
I'm getting this error:
"Cast from type 'IntPtr' to type 'Integer' is not valid"
Here is where the error is happening:
g_D3DDevice = g_D3D.CreateDevice(D3DADAPTER_DEFAULT, DevType, hWnd, DevBehaviorFlags, g_D3DWindow)
It's hWnd that's causing the problem. I am passing picturebox.Handle as the hWnd parameter. If I change hWnd to hWnd.ToInt32 within the function I get a similar type of error:
"Specified cast is not valid"
How does one use windows handles with Directx and .Net? I can't find any documentation on the MS sites.
-
Mar 31st, 2002, 04:41 PM
#2
Good Ol' Platypus
If I'm not mistaken, the .Handle is equivalent to the .hDC of a control, not the .hWnd. Look for something like Window, Window Handle, etc.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 31st, 2002, 04:47 PM
#3
Thread Starter
Fanatic Member
.Handle returns a System.IntPtr . Which, I thought, was the same. I tried using hWnd.ToInt32 but then I get an "Invalid cast error". I'm still searching around for an answer but have been coming up short. I hoping that someone here has run into it and found a work around.
Thanks for your reply,
-
Mar 31st, 2002, 04:50 PM
#4
Good Ol' Platypus
Well that's just the thing - I've never used VB.NET, so everything I say here is just out of my mind (which, I must add, you can't trust. Keep that in mind ).
Oh, looking at your first post it looks like you're trying to cast a pointer to an integer. What you'll need to do is read the value of the pointer, which is already an integer. In C++, we do it like this, but I don't know about VB.NET...
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 31st, 2002, 04:56 PM
#5
Thread Starter
Fanatic Member
I believe that's what the .ToInt32 returns. In break mode it shows a number where as the hWnd by itself shows an object of system.IntPtr .
I must be out of my mind to try something like this LOL. I can't find any documentation on it anywhere. Kinda just feeling my way through it.
Thanks for your input.
-
Mar 31st, 2002, 05:29 PM
#6
Good Ol' Platypus
Maybe try signed/unsigned integers, and if that doesn't work, try Int16, because Int32 = Long and Int16 = Integer.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 31st, 2002, 08:09 PM
#7
Thread Starter
Fanatic Member
Believe it or not I found the problem out while trying the same thing in VB6.
Calling hWnd.ToInt32 was correct, the problem was that I declared g_D3DDevice as DxVBLibA.Direct3D8 and not as DxVBLibA.Direct3DDevice8 like I should have...oops
Thanks again,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|