XNA Creators Club Online
Page 2 of 2 (34 items) < Previous 1 2
Sort Posts: Previous Next

A better way to embed XNA into WinForms (full source)

Last post 2/15/2010 11:00 AM by SteelGolem. 33 replies.
  • 12/11/2007 6:09 PM In reply to
    • (0)
    • premium membership
    • Posts 6

    Re: WinForms with minimal fuss

    Brandon Bloom:
    I have no idea what the team is planning, but it is my suspicion that whatever solution they come up with will certainly not be 360 compatable and will live in a seperate, Windows-only assembly.

    If I had my way, it would take the form of a XnaView control which you could simply drag out of the toolbox onto a form. That would be nice because then you could easily make multiple viewports and such, but is actually substantially more sophisticated to setup and doesn't directly match the semantics of the Game class.

    It's never as easy as it first looks, especially when you have to write framework code that is going to be used by such a wide range of people. Even the seemingly simplist things have complications which can easily be overlooked by those who are not accustom to the framework-writing frame of mind. For example, a lot of people asked "Why isn't the chat pad supported in v1? Isn't it just a keyboard? It should work the same as any keyboard". The response was "because you can have more than one of them" and people said "oooooh. right." :-)

    I made a XNA Viewport control that you could drag out of the toolbox onto a form. I was trying to get XNA to work with VS2005 in VB and I thought it'd be handy to be able to host XNA as a control on a form. The project kinda died due to not being able to use the content pipeline with VB, but the control works... at least with my tests and limited knowledge of XNA. Anybody's welcome to check it out.

  • 12/15/2007 8:46 AM In reply to

    Re: WinForms with minimal fuss

    Well, this is another way of doing this:

    http://www.youtube.com/watch?v=vc72eYcQODc

    source:

    XNAFormsEditor

    http://www.youtube.com/alexmbr
  • 12/15/2007 10:56 PM In reply to

    Re: WinForms with minimal fuss

    I've been writing an article for a week or so regarding how to use XNA GS and VS2008.

    In one of the sections (entitled "XNA And WinForms: A Simple Approach") I present a way to avoid all the "fuss". Still, I consider that getting control of the GraphicDevice is the best option, but as I say in the article, I'm lazy ;)

    http://www.thecodeproject.com/KB/game/XNA_And_Beyond.aspx

    BTW, this is my first article for "The Code Project", so please be nice ... :)

     

    ~Pete - MSFT MVP for DirectX/XNA

    Need guidance? Just remember: Do as I say, not as I do ...
  • 12/27/2007 2:35 AM In reply to

    Re: WinForms with minimal fuss

    Gibba:
    The last bit of code was very nice, although it doesnt quite serve my purpose and im too much of a c# noob to get it working.

    I've created my own form and i want to display the XNA environment in a picturebox or equivalent, so i can place controls down the sides.  Problem is the main XNA window still opens as well as my form, although the XNA window is not updated.

    Anyway to stop the main XNA window opening and use a control to display the XNA on my custom form?

    To 'hide' the window simply put the following code in your Initialize method:

    protected override void Initialize()
    {
    // TODO: Add your initialization logic here

    base.Initialize();

    Form gameWindowForm = (Form)Form.FromHandle(this.Window.Handle);
    gameWindowForm.Shown += new EventHandler(gameWindowForm_Shown);
    }

    void gameWindowForm_Shown(object sender, EventArgs e)
    {
    ((Form)sender).Hide();
    }
    Dead_Illusionist
  • 12/28/2007 11:45 AM In reply to

    Re: WinForms with minimal fuss

    I havent tried this, but I would suspect you could just as easily set the Forms visible property to false as well.
  • 12/28/2007 3:39 PM In reply to

    Re: WinForms with minimal fuss

    I have updated my article.
    ~Pete - MSFT MVP for DirectX/XNA

    Need guidance? Just remember: Do as I say, not as I do ...
  • 5/14/2009 3:55 PM In reply to

    Re: A better way to embed XNA into WinForms (full source)

    I may be being a tad cynical here but I wouldn't hold my breath on seeing Winforms support being high on the XNA developers list of things to implement. I assume such features would only be applicable to the Windows platform and not Xbox360?

    As far as I can see the road down which XNA will develop with regards to more Windows functionaility will always be hampered by the fact that one leg is shackled to the Xbox360 requirements. Therefore any new features that only target the Windows platform will be dropped (or at least postponed) in favour of features that work on both platforms.

    As much as this bothers me, there are likely sound reasons for this limited development. As soon as you start introducing large numbers of platform-specific features in an API you introduce a split in the development path, which then causes issues for maintainability and slows down development progress for both platforms. Unless of course you also increase the size of the XNA development team to handle this.

  • 5/15/2009 1:08 PM In reply to

    Re: A better way to embed XNA into WinForms (full source)

    I think you are replying to a 2 year old article (?)

    And the team has given this: http://creators.xna.com/en-US/sample/winforms_series2 to help out, from which you can in not too many steps hack together your own winforms application with a game running in it (useful for edtiors n similar)

    :)
  • 2/15/2010 11:00 AM In reply to

    Re: WinForms with minimal fuss

    just to save people the fuss of going through the (not really much of a) hassle of signing up for that site to submit stuff with... here's an xnaCC solution link that was provided as a response to the link Z posted:

    http://creators.xna.com/en-us/sample/winforms_series1

    thanks Z, and good luck everyone!
Page 2 of 2 (34 items) < Previous 1 2 Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG