Results 1 to 7 of 7

Thread: Direct X and VB.Net...

  1. #1

    Thread Starter
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602

    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.
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  3. #3

    Thread Starter
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    .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,
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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...
    Code:
    *pointer;
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5

    Thread Starter
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    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.
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  7. #7

    Thread Starter
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    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,
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width