Hello, I would like to know how to manage the opening of a page in a new tab and new window from the popupmenu create pat the webgadget?
Thank you in advance.
Webgadget Open in a new tab and new window
- a_carignan
- User
- Posts: 81
- Joined: Sat Feb 21, 2009 2:01 am
- Location: Canada
Re: Webgadget Open in a new tab and new window
Take some time to think about it and I'm pretty sure you'll find a way!
Tombmyst
- a_carignan
- User
- Posts: 81
- Joined: Sat Feb 21, 2009 2:01 am
- Location: Canada
Re: Webgadget Open in a new tab and new window
Tombmyst wrote:Take some time to think about it and I'm pretty sure you'll find a way!
I do not have time to waste looking for solutions that already exists!
Re: Webgadget Open in a new tab and new window
You need COMatePlus for this, which you can download from https://www.rsbasic.de/backups/. This only handles "Open in new window". Someone more knowledgeable than me might know how to edit the context menu to enable "Open in new tab" and intercept it.
Windows only.
Windows only.
Code: Select all
EnableExplicit
XIncludeFile "COMatePLUS.pbi"
Declare WebEventProc(obj.COMateObject, evtName.s, paramCount)
Structure BrowserWindow
id.i
web.i
com.COMateObject
EndStructure
Global Quit.b, NewList BrowserWindows.BrowserWindow()
Procedure OnWindowSized()
Protected *dat
*dat = GetWindowData(EventWindow())
ChangeCurrentElement(BrowserWindows(), *dat)
ResizeGadget(BrowserWindows()\web, #PB_Ignore, #PB_Ignore, WindowWidth(BrowserWindows()\id) - 20, WindowHeight(BrowserWindows()\id) - 20)
EndProcedure
Procedure OnWindowClosed()
Protected *dat
*dat = GetWindowData(EventWindow())
ChangeCurrentElement(BrowserWindows(), *dat)
BrowserWindows()\com\Release()
CloseWindow(BrowserWindows()\id)
DeleteElement(BrowserWindows())
If ListSize(BrowserWindows()) = 0
Quit = #True
EndIf
EndProcedure
Procedure OpenBrowserWindow(url.s)
Protected iid.IID
AddElement(BrowserWindows())
BrowserWindows()\id = OpenWindow(#PB_Any, 0, 0, 640, 480, url, #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SystemMenu)
BrowserWindows()\web = WebGadget(#PB_Any, 10, 10, 620, 460, url)
BrowserWindows()\com = COMate_WrapCOMObject(GetWindowLongPtr_(GadgetID(BrowserWindows()\web), #GWL_USERDATA))
If COMate_GetIIDFromName("DWebBrowserEvents2", @iid.IID) = #S_OK
BrowserWindows()\com\SetEventHandler(#COMate_CatchAllEvents, @WebEventProc(), 0, iid)
EndIf
SetWindowData(BrowserWindows()\id, @BrowserWindows())
BindEvent(#PB_Event_SizeWindow, @OnWindowSized(), BrowserWindows()\id)
BindEvent(#PB_Event_CloseWindow, @OnWindowClosed(), BrowserWindows()\id)
EndProcedure
OpenBrowserWindow("https://www.purebasic.com")
Repeat : WaitWindowEvent() : Until Quit = #True
Procedure WebEventProc(obj.COMateObject, evtName.s, paramCount)
Protected *ptrBool.WORD
Select evtName
Case "NewWindow3"
OpenBrowserWindow(obj\GetStringEventParam(5))
If obj\IsEventParamPassedByRef(2, @*ptrBool)
*ptrBool\w = #VARIANT_TRUE
EndIf
EndSelect
EndProcedure
- a_carignan
- User
- Posts: 81
- Joined: Sat Feb 21, 2009 2:01 am
- Location: Canada
Re: Webgadget Open in a new tab and new window
Wow, This is exactly the example that was clawing me to manage the opening of a web page in a new window. Thank you so much.
I would like to know where to find information on the commands to use to manage a web browser with ComatePlus. With luck I would find a way to manage the web page in a new tab, otherwise I would do it differently.
Once again thank you very much to you Wombats.
I would like to know where to find information on the commands to use to manage a web browser with ComatePlus. With luck I would find a way to manage the web page in a new tab, otherwise I would do it differently.
Once again thank you very much to you Wombats.
Re: Webgadget Open in a new tab and new window
Hi a_carignan,
I had to solve similar issues when creating my PB browser (viewtopic.php?f=14&t=72166). I can't share the entire source, but if you have specific questions that I have already resolved, I'll be happy to help or point you to relevant MSDN documentation.
I had to solve similar issues when creating my PB browser (viewtopic.php?f=14&t=72166). I can't share the entire source, but if you have specific questions that I have already resolved, I'll be happy to help or point you to relevant MSDN documentation.
Re: Webgadget Open in a new tab and new window
You're welcome. This is where I got the information for the "NewWindow3" event.a_carignan wrote:Wow, This is exactly the example that was clawing me to manage the opening of a web page in a new window. Thank you so much.
I would like to know where to find information on the commands to use to manage a web browser with ComatePlus. With luck I would find a way to manage the web page in a new tab, otherwise I would do it differently.
Once again thank you very much to you Wombats.
- a_carignan
- User
- Posts: 81
- Joined: Sat Feb 21, 2009 2:01 am
- Location: Canada
Re: Webgadget Open in a new tab and new window
Thanks for your help.
- a_carignan
- User
- Posts: 81
- Joined: Sat Feb 21, 2009 2:01 am
- Location: Canada
Re: Webgadget Open in a new tab and new window
I have not found ways to make the menu accessible to open the link in a new tab.
I'm wondering if I could not use the #PB_Web_BlockPopupMenu attribute, in order to create my own popup-menu.
I would like to know if there are ways to know the object that was clicked to customize my popup-menu?
I'm wondering if I could not use the #PB_Web_BlockPopupMenu attribute, in order to create my own popup-menu.
I would like to know if there are ways to know the object that was clicked to customize my popup-menu?