What is the CefBrowser and how do I keep a reference to it?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

What is the CefBrowser and how do I keep a reference to it?

Postby KnIfER » Thu Oct 01, 2020 6:34 am

What is CefBrowser ? ……

Or how do I get CefBrowser from it’s identifier

Or how do I do anything to whatever the CefBrowserHost::CreateBrowser function created?
Last edited by KnIfER on Thu Oct 01, 2020 6:46 am, edited 1 time in total.
KnIfER
Newbie
 
Posts: 7
Joined: Sun Jul 15, 2018 5:33 am

Re: What is the CefBrowser and how do I keep a reference to

Postby KnIfER » Thu Oct 01, 2020 6:46 am

the CefBrowser object is always changing :

int OnContextMenuCommand test following code :


TCHAR buffer[100]={0};
wsprintf(buffer,TEXT("browser=%d"), browser.get());
::MessageBox(NULL, buffer, TEXT(""), MB_OK);

the pointer is of different value every test.
KnIfER
Newbie
 
Posts: 7
Joined: Sun Jul 15, 2018 5:33 am

Re: What is the CefBrowser and how do I keep a reference to

Postby ndesktop » Thu Oct 01, 2020 6:54 am

CefBrowser::GetIdentifier returns the browser unique ID.
browser.get() will return a pointer, which might vary (although CefRefPtr::ptr_ should be the same and only its refcount vary).
You might want to use
Code: Select all
wsprintf(buffer,TEXT("browser=%p"), browser.get());
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am

Re: What is the CefBrowser and how do I keep a reference to

Postby KnIfER » Thu Oct 01, 2020 7:42 am

Code: Select all
wsprintf(buffer,TEXT("browser=%p"), browser.get());
[/quote]

It's varying as well, why?

After reading this post https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=10237&p=14767&hilit=CefBrowser+from+identifier+get+CefBrowser#p14767


Answer to "how do I keep a reference to CefBrowser" is —— I need to keep my own CefRefPtr<CefBrowser> in the OnAfterCreated callback:

new CefRefPtr<CefBrowser>(browser)
KnIfER
Newbie
 
Posts: 7
Joined: Sun Jul 15, 2018 5:33 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 22 guests