Page 1 of 1

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

PostPosted: Thu Oct 01, 2020 6:34 am
by KnIfER
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?

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

PostPosted: Thu Oct 01, 2020 6:46 am
by KnIfER
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.

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

PostPosted: Thu Oct 01, 2020 6:54 am
by ndesktop
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());

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

PostPosted: Thu Oct 01, 2020 7:42 am
by KnIfER
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)