GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Jul-2009, 12:44
'P.V. 'P.V. is offline
New Member
 
Join Date: Jul 2009
Posts: 1
'P.V. is on a distinguished road

Problem with Thread


Hi

I want to use an OpenFileDialog box. But when I try to show the dialog box, I get the following error:


"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process"

[STAThreadAttribute] is already defined on the Main function, but I still getting the error message.


CPP / C++ / C Code:
if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK ) // error in this line
	    {
			
		  	 

		  //System::String^ file = openFileDialog1->FileName;
		  
		  

		cli::array<System::String^,1>^file1 = openFileDialog1->FileNames;
		img = gcnew cli::array<IplImage*,1>(file1->Length);
  
		MessageBox::Show("Tamanho de File1: "+file1->Length);
		 
		  for(int i = 0;i < file1->Length; i++)
		  {
		  // cast de System::String^ para char*
		  char* str2 = (char*)Marshal::StringToHGlobalAnsi(file1[i]).ToPointer(); 
		  

		 
		  img[i]=cvLoadImage(str2,1); 
		 
		  }

		pictureBox1_Click(sender,e);
	
	  
	  }
				
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I call Fl::lock() and Fl::unlock() from the Main Thread? nharder FLTK Forum 1 15-May-2009 14:13
Thread synchronization Assignment help!! rossi143 C Programming Language 1 25-Mar-2007 21:10
Thread itch C++ Forum 7 10-May-2006 16:10
Sending message to GUI thread that ISNT the main thread mpviii MS Visual C++ / MFC Forum 1 20-Apr-2005 13:49
Problem with Thread r_m_zhang MS Visual C++ / MFC Forum 0 08-Mar-2005 08:59

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:13.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.