简体   繁体   中英

.NET Invoke a control for VS2003

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM