vb.net - Calling sub in different class not working right -
i creating browser in vb.net using cefsharp. created custom lifespanhandler
handle popup windows, when try call public sub in different class, not giving expected output. created lifespanhandler
using following code:
public class lifespanhandler implements ilifespanhandler public event popuprequest action(of string) public function onbeforepopup(browser iwebbrowser, sourceurl string, targeturl string, byref x integer, byref y integer, byref width integer, byref height integer) boolean implements ilifespanhandler.onbeforepopup raiseevent popuprequest(targeturl) my.settings.newpage = targeturl call form1.intnewtab() return true end function public sub onbeforeclose(browser iwebbrowser) implements ilifespanhandler.onbeforeclose end sub end class
and have browser.lifespanhandler = new lifespanhandler
initialized. (with browser
being cefsharp.winforms.chromiumwebbrowser
)
i save targeturl
in my.settings.newpage
, when browser initialized, opens url. in different class (and different form), have code:
public sub intnewtab() dim tab new tabpage dim newtab new tabs newtab.show() newtab.dock = dockstyle.fill newtab.toplevel = false tab.controls.add(newtab) me.customtabcontrol1.tabpages.add(tab) me.picturebox1.location = new system.drawing.point(picturebox1.location.x + 150, 3) my.settings.newpage = my.settings.homepage me.customtabcontrol1.selectedtab = tab end sub
which code add new tab. in lifespanhandler
, when call form1.intnewtab()
, browser freezes out of focus. window grayed out (meaning it's out of focus) , can't drag around, , stays on top of else, , can't interact part of browser.
to test else out, added button form1
exact code intnewtab
, , when click on it, opens new tab specified page normal. tried leaving button visible, , onbeforepopup
adding form1.button1.performclick
, did not work either. else have experience doing this, or have suggestions?
edit:
i added following codes browser try , rid of default instance (the best understood it):
to form1
:
module program friend frmmain form1 end module
in form1_load
:
`frmmain = me`
then added code in lifespanhandler
reflect changes:
dim mainfrm = new form1() mainfrm.intnewtab()
and did not work. kept freezing out of focus before. tried adding frmmain.intnewtab()
(the code in form1_load
), , still did not work.
Comments
Post a Comment