C# Help

C Scripting questions and answers
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: C# Help

Post by gburk »

Art

Don't know if it was worth it but i figured out how to create forms in visual studio C++
and use the form designer with C++..

so i assume i will have to modify my search code function, and all the strings now, but haven't got that far yet..

Gary 
ArtF
Global Moderator
Global Moderator
Posts: 4556
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: C# Help

Post by ArtF »

Gary:

Its a long learning experience. Ive been using Visual Studio since it was released,
theres a lot to know about it, but youve started that path. Takes the first step to
get anywhere.. :)

Art
User avatar
tweakie
Site Admin
Posts: 171
Joined: Wed Dec 01, 2010 11:58 am

Re: C# Help

Post by tweakie »

ArtF wrote:
while( !Rested ) sheep++;
;D ;D ;D

Tweakie.
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: C# Help

Post by gburk »

Art

run into my first major brick wall..

Seems classes and function are handled a lot different in c++.

I have a form.h and form.cpp, so i created another class, called class1 it also has a class1.h and a class1.cpp.

my problem is i can't seem to figure out how to call the function in class1 form a button click in the form.h button click event. anything i have tried doesn't work..
looks like a whole new ball game form i have it my forms created in c .

any thoughts, or pointers as where to lookup the info.

Gary
ArtF
Global Moderator
Global Moderator
Posts: 4556
Joined: Sun Sep 05, 2010 5:14 pm
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
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

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