C# Help

C Scripting questions and answers
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: C# Help

Post by ArtF »

Gary:

  It does sound like your using C# you know, in the raw C++ settings, you have to design a dialog to use, not a form.
In C# use, you usually design a  form and attach events and such to it. I suspect that's where you are.

So you have a form.h and a form.cpp , together they all simply called a class.
Inside form.h you likely have some declaration of the class itself..

in C++ ( C# may differ in some syntax), youd have something like..

class CMyForm : public CDialog
{
  int myvariable;
  bool mybool;
  void  MyButtonWasPressed();
}

  So form.h can be thought of as a declaration file, it tells the system what functions or variables
the class form contains. The Form.cpp contains the actual use of those items and the code itself
for the functions. So in it we find..

void MyButonWasPressed()
{
  //you want to acces your other class here, right?
}

So to have you button press call your other class you need to have
your form own one of those classes.. So you change form.h to this..

#include "class1.h"

class CMyForm : public CDialog
{
  class1 MyClass1;
  int myvariable;
  bool mybool;
  void  MyButtonWasPressed();
}

  And finally , change the form.cpp function to ..

void MyButonWasPressed()
{
  MyClass1.NameofFuntionHere();
}

  Now, thats how you do it ( in one way anyway ) in C++. I dont use C#
enough to remember the syntax, the system fills in most of it as you go.
So the above has to be done in the way C# does it. So you may want to explore
some googled example code , theres quite a bit out there of every sort. Im
self taught as a programmer, so most of my education was gleaned from
taking apart others code and climbing on their shoulders. Its a frustrating,
maddening, disheartening and addictive process to go through, but the
most enjoyable skill in the world to have.

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: C# Help

Post by gburk »

Art

I think the major difference is i setup the form and compiled with C++/CLR and i haven't seen alot of info on CLR but i think it somewhat different in the way it passes functions between classes than in C++ 
I will keep searching..

Gary
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests