XNA Creators Club Online
Page 1 of 1 (9 items)
Sort Posts: Previous Next

Is it advisable to use WinForms with DirectX...

Last post 9/22/2009 11:07 PM by Narf the Mouse. 8 replies.
  • 8/30/2009 3:27 AM

    Is it advisable to use WinForms with DirectX...

    ...Or should I look elsewhere for menus and such?
  • 8/30/2009 8:06 AM In reply to

    Re: Is it advisable to use WinForms with DirectX...

    Are you talking about mixing Windows Forms and DirectX in C++? .NET and C++ don't really mix all that well. I think it's made easier if you do it with Microsoft's Managed C++, but I've never really used that. If you want to use Windows Forms with XNA then it's straight forward and totally advisable; there are even articles on ziggyware outlining how to do just that. If you want to build a nice Windows style UI for your DirectX project in C++, Borland has some free tools which work exceptionally well for Win32 C++ development. You can check that out here. Are you wanting to do this for in-game menus or just for debug/tools?
  • 8/30/2009 4:40 PM In reply to

    Re: Is it advisable to use WinForms with DirectX...

    Actually c++ works pretty well. They’ve implemented the stl templates, crt functions and win32 functions as managed code, if you don’t use safe mode then you can abuse it to your hearts content. If you want to use native dx then make sure you add a constructor and a finalizer to the class for proper cleanup, like:

    ~C()
    {
        // dispose of managed resources
        managedFile->Close();

        // dispose of unmanged resouses
        this->!C();
    }

    !C()
    {
        // dispose of dx
        d3dDevice->Release();
    }

    The compiler will change all that and implement a dispose interface for you.

  • 9/2/2009 3:43 AM In reply to

    Re: Is it advisable to use WinForms with DirectX...

    Sorry; I'm using C# and Managed DirectX. How does that change things?
  • 9/2/2009 9:59 AM In reply to

    Re: Is it advisable to use WinForms with DirectX...

    It doesn’t, I thought we were talking about C++ on .net. Download the Winforms samples from the tutorials section of the site, they use xna but the device set up should be similar to what you want. SlimDX might also be a better choice than MDX since it uses more up-to-date libraries.
  • 9/22/2009 8:32 PM In reply to

    Re: Is it advisable to use WinForms with DirectX...

    Sorry it took so long to get back to you guys on this, but my brain went on holidays.

    My current Game class takes two Windows.Forms.Control objects; one is the main control, the other is the control to display on.
    The Form I'm using has a PictureBox covering only part of the main form.
    I also have a test Context Menu (Hello->There;World) in the form.

    When windowed, everything works. Managed DirectX displays on the display control; I can open up the menu both on and off the display control just fine.
    However, when using fullscreen, the display area takes up the entire screen and, when I right-click, the context menu only displays for one frame.
    My guess is, the context menu expects itself to just be redisplayed - And the image on the screen gets wiped on the next frame by DirectX, which doesn't have a clue the context menu even exists.

    How do I fix this? Or should I be asking in the WinForms area?

    Thanks for any and all help.
  • 9/22/2009 8:52 PM In reply to

    Re: Is it advisable to use WinForms with DirectX...

    If you don't need functionality other than what's offered in DX9, I'd advise you to drop MDX. "It's dead, Jim!"

    Take a look at the WinForms sample.

    If you need something more look at SlimDX.
    Jim Perry - Microsoft XNA MVP
    If people spent a minute searching the forums and reading the FAQs before posting I'd be out of a job.
      Got some XNA Game Studio/XNA Framework development info to share with the community? Put it on the XNA Wiki.
        Please mark posts as Answers or Good Feedback when appropriate.
  • 9/22/2009 9:15 PM In reply to

    Re: Is it advisable to use WinForms with DirectX...

    Jim Perry:
    If you don't need functionality other than what's offered in DX9, I'd advise you to drop MDX. "It's dead, Jim!"

    Take a look at the WinForms sample.

    If you need something more look at SlimDX.

    Ah. I'll do that, then.

    I'm writing my own graphics library, so XNA can't help too much. I have, however, looked at that before. :)

    Downloaded.
  • 9/22/2009 11:07 PM In reply to

    Re: Is it advisable to use WinForms with DirectX...

    The problem persists with SlimDX.

    Oddly, I can set the Device to use displayOwner when windowed, but not when fullscreen - It throws an error. (Was the same with MDX)

    Thanks for any and all help.
Page 1 of 1 (9 items) Previous Next