DirectX in a Window form with controls!!!

Hi,

I need to create a software allowing to check welding spot of a robot.

I need to draw real-time charts of current, woltage, ultrsonic...

I try to draw using GDI+ in visual studio C#. The matter is it is too slow, even on

a good computer!!

I would like to know if it is possible to use directX on a widow form, which allows to use

the controls (buttons, text...) available. If yes, could you give some hints or a reference

Another point is that my chart does not need to be in 3 dimensions and I heared that DirectDraw is not being used anymore. Do I have to use Direct3D

Thank you for your response...

Eric




Answer this question

DirectX in a Window form with controls!!!

  • Alejandro Gutierrez

    Hi,
    I'm sorry, I don't know if I understood you well but do you want to make a form that has a part of it that does some render in directx and other part is buttons and stuff like that, the best way to do it is using the visual studio's designer. Build your form and put a panel where you want to do the render, then use the panel's handle to create the directx device.

    If you want to put buttons, text, etc.. inside directx, you can't use the designer. In this case you'll have to use/or build some kind of graphics library that has those components. DirectX has one in its samples.



  • nubie

    Whatever that means "..we couldn't add in the designer directly to DirectX," I'm not sure, but--From the Designer, you can still add controls to the panel (that is, the panel that is being hijacked as the DX panel).

    In case our original poster doesn't know how to do that from code, a line could look like this:

    ...

    panel1.Controls.Add(button1);

    ...

    where panel1 is the one he layed out in the designer, and button1 is a valid Button control, that he created somewhere in the proceeding "..."


  • Sid Stusinski

    What you will find is that the directx system will override the painting in the panel... If you want to use those controls or similar you will have to render them using the directx System. One example of this is the sample framework and the empty project sample that is shipped with the SDK. If you do drop over to the DX forums you will find that there is a lot of traffic on the topic of user interfaces in directx.

    If you are looking for a directX Panel control there are some links on www.thezbuffer.com that will help you.



  • Alan-CIT

    Glenn Wilson wrote:

    ...What you will find is that the directx system will override the painting in the panel...

    Not unless you only do DX stuff in the OnPaintBackground() and NOT the OnPaint().


  • Joe K

    Thank you everyone for the information... I hope it helps some other newbie... (-:

    The original poster!!!



  • Harendra_1976

    Yes, you're right, in fact i'm doing that in one application. What I mean't was that we couldn't add in the designer directly into DirectX.

    Sorry for misleading you.


  • SniperSlap

    Hi, thank you for your reply!!

    I can now use DirectX in a window form.

    But as you can notice I am a little numb...I can not find a tutorial which explains how to insert controls such as window buttons, text, captions... The software needs to looks like a industrial software, that is fast, ergonomic and reliable.

    I would like to share the window form with a DirectX surface and a window with contrlols.

    Could you give me some advice or a tutorial

    best regards,

    Eric



  • dkshah2711

    You can add any components to a panel that has its background as a directx rendered scene. What I meant is that these components will not make part of the directx scene itself.
    Another thing that we need to take care is the order that things are rendered. I once had a panel that was rendering a scene in dx and when I added other components there, they were always behind the rendered scene.


  • TimK74

    Hi,
    Yes, you can use DirectX in a window form, and well, if you want to draw stuff in there with directx you'll need to use Direct3D.

    You can follow these tutorials:
    http://www.drunkenhyena.com/cgi-bin/dx9_net.pl

    or the ones that come with DirectX SDK, or just use google: managed directx tutorial.


  • directSH

    n0n4m3 wrote:
    Hi,
    ...If you want to put buttons, text, etc.. inside directx, you can't use the designer. In this case you'll have to use/or build some kind of graphics library that has those components. DirectX has one in its samples.

    You can have GDI(+) calls on top of a DX render. The d3d device can return a Graphics g suitable to do gdi calls. At least, I've done it in windowed mode.

    Microsoft.DirectX.Direct3D.Surface bb = device.GetBackBuffer(0, 0);

    System.Drawing.Graphics g = bb.GetGraphics();

    g.DrawRectangle(...); // or whatever

    bb.ReleaseGraphics();

    bb.Dispose();

    Also, I don't see what's to stop somebody from adding controls to the panel one uses as the DX panel.


  • DirectX in a Window form with controls!!!