473,325 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Calling C# Windows Form from C++

I have inherited a huge multi project VS2003 .NET solution:
Two of the projects call the same dialog boxes but have differences within
the classes.
For maintainability and future conversion to VS2005 C# for the Main GUI, I was
creating C# Windows Forms:

1) I finally managed to call the Windows Form.
2) I receive error C2039: 'm_nConnType' : is not a member of
'DialogLibrary::OpenSysbusSocket': see declaration of
'DialogLibrary::OpenSysbusSocket' when I build the solution.

Here is my condensed portion of C++ code:

#include "stdafx.h"
#include "genui.h"
#include "opensysb.h"
#include "genuidlg.h"
#include "cmdid.h"
#include "SysArray.h"

//I added the #using statements
#using <System.Windows.Forms.dll>
#using <system.dll>
#using <mscorlib.dll>
#using <DialogLibrary.dll>

IMPLEMENT_SERIAL (COpenSysbusIMDO, CIMDO, 1)
MIRAgEProcType COpenSysbusIMDO::m_nDest = user_defined;
struct OpenStruct
{
ConnectMethod CM;//defined in sysbsock.h
MIRAgEProcType nDest;
char szDestHostName [16];
};

COpenSysbusIMDO::COpenSysbusIMDO()
{
}

COpenSysbusIMDO::~COpenSysbusIMDO() {}

int COpenSysbusIMDO::RetrieveData(BOOL bEditFlag)
{
//COpenSysbusDlg dlg;
//I replaced the above line with the following line
DialogLibrary::OpenSysbusSocket *dlg = new
DialogLibrary::OpenSysbusSocket;

int nResult;

OpenStruct* pData = (OpenStruct*)m_sData.GetBufferSetLength(sizeof
OpenStruct);

if (bEditFlag)
{
if (m_mpDest != scmt)
{
// processing open sysbus socket
//dlg.m_nSim = (int)m_mpDest;
//I changed the notation from '.' to '->'
dlg->m_nConnType = (int)(pData->CM) - 1; //Here is were I get
the error
}
}

// set remaining member variables to indicate a Open SYSBUS Socket
command
m_dwParam = OpenSysbus;
m_nDest = pData->nDest;
m_sData.ReleaseBuffer(sizeof OpenStruct);
return nResult;
}

---------------------------------------------------------------------
Here is part of my C# class: (builds correctly and can be called from a C#
app)

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

namespace DialogLibrary
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class OpenSysbusSocket : Form
{
// private members
int m_nSim;
int m_nConnType;
int m_nDest;
int m_nDestPort;
int m_nPortNumber;

// empty constructor
public OpenSysbusSocket()
{
InitializeComponent();

this.m_nSim = 0;
this.m_nConnType = 0;
this.m_nDest = 0;
this.m_nDestPort = 0;
this.CalcPort();
}

// full constructor
public OpenSysbusSocket ( int nSim, int nConnType, int nDest, int
nDestPort, int nPortNumber)
{
this.m_nSim = nSim;
this.m_nConnType = nConnType;
this.m_nDest = nDest;
this.m_nDestPort = nDestPort;
this.CalcPort();
}

// public accessors
public int nSim
{
get { return m_nSim;}
set { m_nSim = value; }
}
public int nConnType
{
get { return m_nConnType;}
set { m_nConnType = value; }
}
public int nDest
{
get { return m_nDest;}
set { m_nDest = value; }
}
public int nDestPort
{
get { return m_nDestPort;}
set { m_nDestPort = value; }
}
public int nPortNumber
{
get { return m_nPortNumber;}
set { m_nPortNumber = value; }
}
}
}
--
Thanks,

Michael S. Wells \|/
Software Engineer ^O-O^
---------------------------o00o--(_)--o00o----------------------------

May 8 '06 #1
1 2322
Besides the mistake of trying to access the private variables instead of the
accessor methods, I added my DialogLibrary class as a reference to the
project that uses the Windows Form and it compiled/executed and updated the
variables.
--
Thanks,

Michael S. Wells \|/
Software Engineer ^O-O^
---------------------------o00o--(_)--o00o----------------------------

"RedJoy" wrote:
I have inherited a huge multi project VS2003 .NET solution:
Two of the projects call the same dialog boxes but have differences within
the classes.
For maintainability and future conversion to VS2005 C# for the Main GUI, I was
creating C# Windows Forms:

1) I finally managed to call the Windows Form.
2) I receive error C2039: 'm_nConnType' : is not a member of
'DialogLibrary::OpenSysbusSocket': see declaration of
'DialogLibrary::OpenSysbusSocket' when I build the solution.

Here is my condensed portion of C++ code:

#include "stdafx.h"
#include "genui.h"
#include "opensysb.h"
#include "genuidlg.h"
#include "cmdid.h"
#include "SysArray.h"

//I added the #using statements
#using <System.Windows.Forms.dll>
#using <system.dll>
#using <mscorlib.dll>
#using <DialogLibrary.dll>

IMPLEMENT_SERIAL (COpenSysbusIMDO, CIMDO, 1)
MIRAgEProcType COpenSysbusIMDO::m_nDest = user_defined;
struct OpenStruct
{
ConnectMethod CM;//defined in sysbsock.h
MIRAgEProcType nDest;
char szDestHostName [16];
};

COpenSysbusIMDO::COpenSysbusIMDO()
{
}

COpenSysbusIMDO::~COpenSysbusIMDO() {}

int COpenSysbusIMDO::RetrieveData(BOOL bEditFlag)
{
//COpenSysbusDlg dlg;
//I replaced the above line with the following line
DialogLibrary::OpenSysbusSocket *dlg = new
DialogLibrary::OpenSysbusSocket;

int nResult;

OpenStruct* pData = (OpenStruct*)m_sData.GetBufferSetLength(sizeof
OpenStruct);

if (bEditFlag)
{
if (m_mpDest != scmt)
{
// processing open sysbus socket
//dlg.m_nSim = (int)m_mpDest;
//I changed the notation from '.' to '->'
dlg->m_nConnType = (int)(pData->CM) - 1; //Here is were I get
the error
}
}

// set remaining member variables to indicate a Open SYSBUS Socket
command
m_dwParam = OpenSysbus;
m_nDest = pData->nDest;
m_sData.ReleaseBuffer(sizeof OpenStruct);
return nResult;
}

---------------------------------------------------------------------
Here is part of my C# class: (builds correctly and can be called from a C#
app)

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

namespace DialogLibrary
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class OpenSysbusSocket : Form
{
// private members
int m_nSim;
int m_nConnType;
int m_nDest;
int m_nDestPort;
int m_nPortNumber;

// empty constructor
public OpenSysbusSocket()
{
InitializeComponent();

this.m_nSim = 0;
this.m_nConnType = 0;
this.m_nDest = 0;
this.m_nDestPort = 0;
this.CalcPort();
}

// full constructor
public OpenSysbusSocket ( int nSim, int nConnType, int nDest, int
nDestPort, int nPortNumber)
{
this.m_nSim = nSim;
this.m_nConnType = nConnType;
this.m_nDest = nDest;
this.m_nDestPort = nDestPort;
this.CalcPort();
}

// public accessors
public int nSim
{
get { return m_nSim;}
set { m_nSim = value; }
}
public int nConnType
{
get { return m_nConnType;}
set { m_nConnType = value; }
}
public int nDest
{
get { return m_nDest;}
set { m_nDest = value; }
}
public int nDestPort
{
get { return m_nDestPort;}
set { m_nDestPort = value; }
}
public int nPortNumber
{
get { return m_nPortNumber;}
set { m_nPortNumber = value; }
}
}
}
--
Thanks,

Michael S. Wells \|/
Software Engineer ^O-O^
---------------------------o00o--(_)--o00o----------------------------

May 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony Liu | last post by:
Hi, I want to get the name of the calling function of an executing function, I use the StackTrace class to do this and it seems working. However, does anyone think that there any side effect...
6
by: Jon Hyland | last post by:
Ok, I'm a little rusty on this, it should be a simple problem but I can't figure it out. How can I handle form events in my main code page?? I'm creating a Windows App in C#. Rather than make...
2
by: mark | last post by:
I am developing an application in .Net C# that needs to restore a number of tool windows to some previous location and size. The problem I have is that when I create the form and set the Location...
0
by: Rafael Veronezi | last post by:
I would know if ASP.Net prevent a way for calling Pop-up Windows directly, beside using javascript... And I would know if there's a way to exchange values between those windows. Look at my...
3
by: Gary | last post by:
I am using VS.Net 2002 with windows 2000 advanced server and windows 2000 professional. I have a requirement to use windows service with a GUI. I want to show my own User Interface(Dialog) to get...
6
by: Amjad | last post by:
Hi, I want to make a project that calls and executes a function (VB code) made in a seperate file in the Application Folder. I know I can create the function in my project and call it internally,...
7
by: WhiskRomeo | last post by:
I have a WIN .NET application that calls a web service to retrieve data. I deployed the application to a server and configured the webservice. The webservice and SQL Server 2000 database are on...
3
by: Opa | last post by:
Hi , I have a form with javasript which launches a popup via the showModalDialog() method. I get the dialog to open, now I am trying to first get a reference to the calling form from the popup...
6
by: ahmad.humyn | last post by:
I want to call a hidden form. My code goes something like in which the main calls form1. form1 has a button which creates & calls form2 and hides itself. Now I have a button in form2 which if...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.