locked
Where do I ask a question on Visual C++ Forms programming? RRS feed

  • Question

  • I can't tell where I should post this question. I'm trying to take a filename opened with a buttonclick and pass that filename back to the main .cpp file using visual studio 2008. Here's snippets of code to help you understand what I mean. First I'll show where I declare the item as a public variable.

     

     

     

    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
    
    System::String^ filename;
    
    Form1(void)
    


    Then here's the buttonclick event.

     

     

    private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    
    openFileDialog1->ShowDialog();
    
    if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
    
    openFileDialog1->OpenFile();
    
    filename = (openFileDialog1->FileName);
    
    pictureBox1->Image = Bitmap::FromFile(openFileDialog1->FileName);
    
    
    

    Finally what I need to do in the main CPP file is to get the filename in order to read from that file to a memory object.

    BMP pic;
    pic.ReadFromFile(need filename from form1.h here);

    Please let me know where to post this or the answer of how to do it if you know :)


    Chris

    Monday, May 4, 2009 11:25 PM

Answers