Click here to Skip to main content
15,885,868 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I use thread->start to show a splash form but dont know how to close it.

Try the thread->abort but it will always raise an exception.

So I try the splashform->close() but get cross thread error.

Search through google, most of the people saying that an invoke method to close it will be better.

How do I declare a delegate function that can close my splash form?

Please help.

working in c++.net.
Posted
Updated 7-Sep-10 23:05pm
v2
Comments
Dalek Dave 8-Sep-10 5:05am    
Edited for Readability and Grammar.

1 solution

Assuming your talking about C++.Net

public ref class Form1 : public System::Windows::Forms::Form
{
public:
    delegate void CloseFuncDelegate();
    void CloseFunc()
    {
        this->Close();
    }
}

void funcOutside()
{
	Form1^ myForm = gcnew Form1();
    Form1::CloseFuncDelegate^ closeDel = gcnew Form1::CloseFuncDelegate(myForm, &Form1::CloseFunc);

	myForm->Invoke(closeDel);
}
 
Share this answer
 
v4
Comments
tuolesi 8-Sep-10 10:41am    
awesome solution,thx for your help.
tuolesi 8-Sep-10 21:38pm    
erm...can u teach me how to use delegate function with parameter??
I want something like void closeFunc(int i);
tuolesi 8-Sep-10 21:48pm    
juut ignore my stupid question,i had found the way to do it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900