andrlage

andrlage

  • NA
  • 10
  • 0

Show Windows Form in native client

May 10 2011 1:32 PM
I'm doing com interop from a native client.
The native client uses a native dll to call managed server dll.
All I want is to display a simple form when it load in my native application.
I really appreciate your help/thoughts on this.

Sincerely
Andla
------------------------------------------------------
This is the server

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;

namespace Server1
{
  [Guid("?????????????????")]
  public interface IPelle
  {
  string ShowPelle();
  }

  [Guid("?????????????????")]
  public class PelleClass : IPelle
  {
  public string ShowPelle()
  {
  Form1 test = new Form1();

  test.Activate();
  System.Threading.Thread.Sleep(5000);
  return "Pelle 1 was here";
  }
  }
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }
  }
}

This is the client native dll:

        IPellePtr pelleptr;
        HRESULT hr2 = pelleptr.CreateInstance(__uuidof(PelleClass));
        if (SUCCEEDED(hr2))
        {
            MessageBox(0,pelleptr->ShowPelle(),"",0);
           
        }





Answers (10)