none
Office Application AddIn And DirectX RRS feed

  • Question

  • Hi, I have written an office application level addin for Excel that I would like to add a 3D viewer using DirectX etc on a WinForm.  Is this possible and if so what is the best way to go about it?

    I have looked at:

    • DirectX viewer in a pictureBox on a winForm.
    • Separate windows application project in the same solution.
    • WPF User Control (briefly).

    The first two did not work as I kept getting mixed version errors whenever I tried to initialise DirectX.

    The only thing I have managed to get working was to create a separate Windows Application Solution and run the exe from that project from the add-in.  I'd rather not do this.

    Any help appreciated.  Thanks.

    Saturday, February 14, 2015 11:27 PM

All replies

  • Hi,

    I'm not familiar with DirectX and have never used it it in Windows Form.

    If It works for WPF user control, you could also embed the WPF user control to custom task pane.

    Monday, February 16, 2015 9:03 AM
  • Hi,

    >>The first two did not work as I kept getting mixed version errors whenever I tried to initialise DirectX.

    I think you'd better paste out the error message for we can get more information to narrow down the issue. And can you share your sample code if it is convenient ?Thanks.

    Best Regards

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 17, 2015 3:14 AM
    Moderator
  • Ok, I've got past the mixed version issue.  Now when I initialise DirectX nothing happens.  The app appears to be waiting.  There are no error messages.  Here's the code.  Is stops on the line f.InitializeDevice();

                try
                {
                    // in project DirectX Tutorial
                    Form1 f = new Form1();
                    f.InitializeDevice();
                    f.ShowDialog();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error starting directX Window.\nOriginal Message: " + ex);
                }

    and the form code

        public partial class Form1 : Form
        {
            private Device device;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            public void InitializeDevice()
            {
                PresentParameters presentParams = new PresentParameters();
                presentParams.Windowed = true;
                presentParams.SwapEffect = SwapEffect.Discard;
                device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
            }
    
            protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
            {
                device.Clear(ClearFlags.Target, Color.DarkSlateBlue, 1.0f, 0);
                device.Present();
            }
        }

    Tuesday, February 17, 2015 8:01 AM
  • Hi

    This is the forum for Excel developers.  I am suggesting you turn to DirectX forum for more help. For there are more professional community members could be involved in.

    Thanks for your understanding.

    Best Regards

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 24, 2015 5:58 AM
    Moderator