Getting Started -- where do I put my functions? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Getting Started -- where do I put my functions?

cp1cp1 Posts: 2Member
Hi guys, I have a very basic question.

I've managed to figure out how to setup a form. It has a button which opens the open file dialog to select a file. Now I want to do some processing on that file when I click a "GO" button.

Dumb question: where do I put all the code that I've written to process that file? Do I stick it in Form1.h in the button_Click event handler? This is kind of awkward as it is a long bit of code and seems out of place in this file.

What I'd like to do is call a function like processFile() that I put in the program.cpp file VisualC++ created for me (the file with main() in it). But, when I put my processFile there and #include "program.cpp" in Form1.h, I get all sorts of namespace errors. I admit I don't quite understand all this .net type stuff, but I am trying to learn.

If I get my code to live in an appropriate .cpp file, can I access things like form1->textBox1->Text from there?

There is no form1.cpp file either, should there be?

Apologies for this very basic question, I tried to search, but couldn't find anything on it. I found a lot of help setting up my form, but not actually using it to do anything useful.
Thanks in Advance

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [color=Blue]What type of project you created?
    What kind of VC++ you have? Express Edition? Do you have MFC?[/color]
  • cp1cp1 Posts: 2Member
    Thanks for the reply, sorry for not adding these details.

    To create the project I used New Project -> CLR -> Windows Forms Application using Visual C++ 2005 Express Edition. The platform is "Win32". I'm not sure if I have MFC, I would guess no.

    I have debated updating to a newer version through the years, but I am afraid that it may break one of my projects, which would be a disaster because it would likely take me a long time to figure out why.


    The following files are in my project: (assume the project name is "project").

    Form1.h
    Form1.resX
    resource.h
    stdafx.h

    app.ico
    app.rc

    AssemblyInfo.cpp
    project.cpp
    stdafx.cpp
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [color=Blue]I see.
    Express does not have MFC.
    The project you created is a managed C++ code.
    I am not an expert in this language.
    Try to right click on a button and select "Properties" - then in the opened panel select "MouseClick" event and type a name of a function in that field - VS 2005 should create a function body for that button, but for some reason it creates in .H file.[/color]
Sign In or Register to comment.