0

I changed cefsharp winforms example.

it bound callback. browser.RegisterJsObject("bound", new BrowserForm()); it bound BrowserForm to can access from java to call AddTab from java

I successfully called c# methods from javascript via bound.

my problem is I cant hide image object when calling from java. but with button on form we can do.

c# code

public void Load_successfull()
    {
        MessageBox.Show("working good.");
        loading_animation.Visible = false;

    }

private void button2_Click(object sender, EventArgs e) { Load_successfull(); }

java code: bound.load_successfull();

when called from java cant hide loading_animation

  • You need to marshal your calls back onto the UI thread. E.g BeginInvoke – amaitland Feb 06 '16 at 22:41
  • can you send full example or complete my code above? – Jafar Ashkany Feb 08 '16 at 10:22
  • See https://msdn.microsoft.com/en-us/library/0b1bf3y3%28v=vs.110%29.aspx for details – amaitland Feb 08 '16 at 10:31
  • I changed to this code. by click button worked but from java bound call bound.load_successful no hide object public delegate void InvokeDelegate(); public void Load_successfull() { loading_animation.BeginInvoke(new InvokeDelegate(hide_animation)); } public void hide_animation() { loading_animation.Visible = false; MessageBox.Show("called ok"); } – Jafar Ashkany Feb 08 '16 at 11:11
  • What's your question exactly? – amaitland Feb 08 '16 at 12:24
  • Looking at your original code again, you need to pass in the current instance of the form, not create a new one. should be `browser.RegisterJsObject("bound", this);` – amaitland Feb 08 '16 at 13:31
  • loading_animation.Visible = false not worked when called by java bound callback. or when runed by timer interval. just worked by click button call – Jafar Ashkany Feb 08 '16 at 22:42
  • Fact that it doesn't work by timer should tell you something. Anyway, the problem isn't `CefSharp` related. You'll need to read up on `WinForms Threading`, particularly `BeginInvoke`. I'm sure `StackOverflow` has plenty of questions that already cover the topic. – amaitland Feb 08 '16 at 22:46
  • hi again. thanks for spend time. I call from c# timer it worked and hide. but from cefsharp winform.example can not. because of browser.RegisterJsObject are in class BrowserTabUserControl I cant use this for bound. all methods are in BrowseForm and lables are in it. then I forced to use new BrowserForm() . – Jafar Ashkany Feb 08 '16 at 23:12
  • Passing in a reference to `new BrowserForm()` is not the same as passing in a reference to the already running instance of `BrowerForm`, do you understand that? Use https://github.com/cefsharp/CefSharp.MinimalExample as the basis of your testing, it's much simpler. – amaitland Feb 08 '16 at 23:20
  • thanks. how I can change active form lables and images position and visibility from other class? if re new BrowserForm is not good method ? – Jafar Ashkany Feb 08 '16 at 23:34
  • http://stackoverflow.com/questions/8820606/get-access-to-parent-control-from-user-control-c-sharp If your new to `WinForms` or `.Net` then I suggest you start reading some tutorials, get a better understand for the framework. – amaitland Feb 09 '16 at 01:05

0 Answers0