質問

I am trying to use the Microsoft web browser control on a form, however if you navigate to a site that takes a long time to load; the whole form UI locks up until everything is loaded. To combat this I am trying to run the web browser control seperate to everything else. I have created a small sample app using this tutorial: http://msdn.microsoft.com/en-us/library/ms171728.aspx

I have an error on the below function:

    void SetNavigate(String* text)
    {
        if(this->axWebBrowser1->InvokeRequired)
        {
            SetNavigateDelegate* d = __gc new SetNavigateDelegate(this, &Form1::SetNavigate);
            this->Invoke(d, __gc new Object[] { text });
        }
        else
        {
            this->axWebBrowser1->Navigate(text);
        }
    }

The line specifically is:

this->Invoke(d, __gc new Object[] { text });

error C2958: the left parenthesis '(' found at '\testbrowser\form1.h(56)' was not matched correctly

I had to sub delegate for __delegate, __gc new for gcnew and ^ for * so I am guessing this is another 2003 .NET being behind the times problem, does any one know the correct syntax I am looking for to stop the error appearing?

役に立ちましたか?

解決

In 2003, I don't think you could use the {} array initializers inline yet. Try assigning the __gc new Object[] { text } to a named variable.

... and do anything you can to get away from writing managed c++ in vs2003. It's completely awful, and C++/CLI introduced in 2005 is a big improvement.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top