We help IT Professionals succeed at work.
Get Started

Calling main from (console application) from (windows forms application)

panJames
panJames asked
on
1,008 Views
Last Modified: 2012-08-13
Please have a look at the code!

I get "All tags must have a closing tag." error if I try to do the other way.

Hello experts!

I have a C++ program example written as a console application.

It looks something like this:

#include <cv.h>
#include <highgui.h>
#include <stdio.h>

#define CVX_RED		CV_RGB(0xff,0x00,0x00)
#define CVX_GREEN	CV_RGB(0x00,0xff,0x00)
#define CVX_BLUE	                CV_RGB(0x00,0x00,0xff)


int main(int argc, char* argv[]) {
  //some code here

}

Now I would like to create windows form application and call the main function from my example- passing file names to it.

How can I do it?



This is my attempt:

(Added my example file to Source Files)

I have a form, a button and listBox on it + OpenFileDialog

User clicks the button:

private: System::Void button1_Click_1(System::Object^  sender, System::EventArgs^  e) {
				if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
				{
					for (int i; i < openFileDialog1->FileNames->Length; i ++)
					{
						listBox1->Items->Add(openFileDialog1->FileNames[i]);

					}
				}

			 }


Then user clicks the file name in a listBox:

private: System::Void listBox1_Click(System::Object^  sender, System::EventArgs^  e) {
//what should I put here?
				 
			 }


Thank you

panJames

Open in new window

Comment
Watch Question
Software Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE