// JP opened flex table

Click to See Complete Forum and Search --> : C# dll with winform used in C++ dll


Rich Reese
October 11th, 2001, 12:52 PM
Please Help,

Problem:
I am developing a set of programs (interactive and batch operation) that
I
would like to have a common set of forms for the user interface.
Interactively the program will be a dll that is called in Unigraphics CAD
system (c or c++). Batch mode will be an executable (c, c++, or c#). I
want
to develop the forms using c# winforms using the beta 2 MS.net
development
studio.

Has anyone done anything similar to this? If yes, do you have a skeleton
program
that I can start with?

Here is what I have so far:

c# winform -> dll:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsCon
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent
call
//
}

///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(48, 56);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(184, 32);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(40, 120);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(200, 22);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "textBox1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(928, 541);
this.Controls.AddRange(new System.Windows.Forms.Control[] {

this.textBox1,

this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion
}
}

c++ dll used in UG -> dll:

#using
using namespace System;

// required dlls for WinForms
#using "System.dll"
#using "System.Windows.Forms.dll"
#using "System.Drawing.dll"

#using "C:\\KERunner_stuff\\UG_examples\\UF_Cycle\\Debug\\WindowsCon.dll"

// required namespaces for WinForms
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using namespace System::Drawing;
using namespace System::Collections;
using namespace WindowsCon;

/*
============================================================================
====

Copyright (c) 1998 Unigraphics Solutions Inc.
Unpublished - All rights reserved

============================================================================
====
File description:

This file contains the internal Cycle example program.

============================================================================
====
*/

//
****************************************************************************
// Include files for needed types
//
****************************************************************************

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include
using std::ostream;
using std::cout;
using std::endl;
#else
# include
#endif
#include
#include
#include

#include "UF_Cycle.h"
//

__gc class WinForm: public Form
{
public:
WinForm()
{
InitForm();
}

void Dispose()
{
// Form is being destroyed. Do any necessary clean-up here.

Form::Dispose();
}

void InitForm()
{
// Setup controls here
}
};


// The entry point for the Internal UG/Open++ application
// that generates a part report via the Cycle example class.

extern void ufusr ( char *param, int *retcod, int param_len )
{
try
{
UgSession session ( true ); // Start a UG Session

Application::Run(new WindowsCon::Form1());
// Application::Run(new WinForm());
}
catch ( UgException &exception ) // Begin exception handling
{
printf("\nAN ERROR !!!!");
printf("\n%s",exception.askErrorText ( ).c_str());
}
}

Note. When I use the winform class that is in the c++ code - it works. But I
want to uset the c# interface to build the form.

Thanks for you help,

Rich

//JP added flex table