DirectX Area inside a CLR/WFA or MFC window?

Hello!

I'd like to write an application which should use DirectX, but not in the whole window, only a part of the window.

In the other parts of the window there should be buttons and input areas to controll what is happening inside the DirectX area.

So appart of the DirectX part, that looks like a normal CLR windows forms application or a MFC application.


My questions are:

Is it possible to include such a DirectX area in a windows forms application or MFC application
(Is windows forms application better for this than MFC or the other way round )
How can I include this area in a windows forms application or MFC application
Are there some sample applications/codes for that


I searched but I haven't found matching questions, sorry.
Also I'm pretty new to that, so sorry if these questions are stupid.
One or two good links is all I need as an answer. :)

Thanks!




Answer this question

DirectX Area inside a CLR/WFA or MFC window?

  • Joie Cariaga

    Yes it is completely possible. The only draw back and this will be most noticeable on older video cards is you will take a performance hit. This performance hit is really dependent upon what you are doing. Most of the samples that come with the DirectX SDK operate in both windowed and full screen mode. Remember that all controls are windows. So you would merely take a sample and point it to the Window that filled the area you want to display the dx on in your application.

  • LPXO

    Thanks, that's great!

    Performance hit doesn't matter, actually it's not for a game but for a scientific application. (In which some data should be presented in a 3-D view...)

    But sorry, yet it is totally unclear to me how I can point this 3-D window to a CLR/windows forms application.
    (As I said, I'm a absolute beginner in graphic programing...)

    According to the tutorial, this is how I create the DirectX window:


    ....
    INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
    {
    // Register the window class
    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
    GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
    "window name", NULL };
    RegisterClassEx( &wc );

    // Create the application's window
    HWND hWnd = CreateWindow( "window name", "window title",
    WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
    NULL, NULL, wc.hInstance, NULL );

    // Initialize Direct3D
    if( SUCCEEDED( InitD3D( hWnd ) ) )
    {
    // Create the vertex buffer
    if( SUCCEEDED( InitVB() ) )
    {
    // Show the window
    ShowWindow( hWnd, SW_SHOWDEFAULT );
    UpdateWindow( hWnd );

    // Enter the message loop
    MSG msg;
    ZeroMemory( &msg, sizeof(msg) );
    while( msg.message!=WM_QUIT )
    {
    if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
    {
    TranslateMessage( &msg );
    DispatchMessage( &msg );
    }
    else
    Render();
    }
    }
    }

    UnregisterClass( "window name", wc.hInstance );
    return 0;
    }



    But in a CLR/windows forms application, I got a totally different main() function, how can I call the 3D window there

    Thanks!

  • Vibhu Bansal

    You're looking at the C++ applications. If you are using C# you need be looking at the C# sample applications and you ned to be working with Managed DirectX. You need to grab the Managed DirectX SDK from here
    You will want the DiurectX SDK April 2006 - this is the latest of the Managed DX SDK and from what i hear they usualy make lots of improvements with every bi-monthly release.


  • withersd

    So combining C++ and windows form application isn't possible

    OK, now I tried managed code.

    But there is a new problem:

    I can edit the windows properties in the graphic editor*, but when compiling that, it is simply ignored:

    I only get the DirectX window, but not the self-designed window.

    So how can I apply my design changes to the windows form application window
    Thanks...



    (*) I simply installed a managed Code example from the DirectX SDK and tried to edit the window.


  • DirectX Area inside a CLR/WFA or MFC window?