mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 09:37:03 +00:00
Ready event added. Also after when browser ready it is automatically resize it to control size. (Dirty commit, may not compiles).
This commit is contained in:
@@ -64,9 +64,17 @@ namespace CefSharp
|
||||
throw gcnew Exception("RunScript Exception:" + _jsError);
|
||||
}
|
||||
|
||||
void BrowserControl::OnReady(EventArgs^ e)
|
||||
{
|
||||
OnSizeChanged(this, EventArgs::Empty);
|
||||
|
||||
// todo: raise Ready event with control begininvoke
|
||||
Ready(this, e);
|
||||
}
|
||||
|
||||
void BrowserControl::OnHandleCreated(EventArgs^ e)
|
||||
{
|
||||
if(DesignMode == false)
|
||||
if (DesignMode == false)
|
||||
{
|
||||
_handlerAdapter = new HandlerAdapter(this);
|
||||
CefRefPtr<HandlerAdapter> ptr = _handlerAdapter.get();
|
||||
@@ -87,7 +95,7 @@ namespace CefSharp
|
||||
|
||||
void BrowserControl::OnSizeChanged(EventArgs^ e)
|
||||
{
|
||||
if(DesignMode == false)
|
||||
if (DesignMode == false && _handlerAdapter != nullptr && _handlerAdapter->GetIsReady())
|
||||
{
|
||||
HWND hWnd = static_cast<HWND>(Handle.ToPointer());
|
||||
RECT rect;
|
||||
|
||||
@@ -30,11 +30,15 @@ namespace CefSharp
|
||||
String^ _jsResult;
|
||||
String^ _jsError;
|
||||
|
||||
//TODO: add manual event to signal browser ready
|
||||
|
||||
protected:
|
||||
|
||||
virtual void OnHandleCreated(EventArgs^ e) override;
|
||||
virtual void OnSizeChanged(EventArgs^ e) override;
|
||||
|
||||
protected internal:
|
||||
virtual void OnReady(EventArgs^ e);
|
||||
|
||||
internal:
|
||||
|
||||
void SetTitle(String^ title);
|
||||
@@ -108,6 +112,7 @@ namespace CefSharp
|
||||
}
|
||||
|
||||
virtual event PropertyChangedEventHandler^ PropertyChanged;
|
||||
event EventHandler^ Ready;
|
||||
|
||||
event ConsoleMessageEventHandler^ ConsoleMessage;
|
||||
};
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace CefSharp
|
||||
{
|
||||
_browserHwnd = browser->GetWindowHandle();
|
||||
_cefBrowser = browser;
|
||||
|
||||
_browserControl->OnReady(EventArgs::Empty);
|
||||
}
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,10 @@ namespace CefSharp
|
||||
HWND _browserHwnd;
|
||||
CefRefPtr<CefBrowser> _cefBrowser;
|
||||
|
||||
void ThrowIfCefBrowserIsNotReady()
|
||||
private:
|
||||
void ThrowIfIsNotReady()
|
||||
{
|
||||
if (_cefBrowser == nullptr)
|
||||
if (!GetIsReady())
|
||||
{
|
||||
//TODO: make own exception type?
|
||||
throw gcnew InvalidOperationException("CefBrowser is not ready.");
|
||||
@@ -63,9 +64,13 @@ namespace CefSharp
|
||||
HWND GetBrowserHwnd() { return _browserHwnd; }
|
||||
CefRefPtr<CefBrowser> GetCefBrowser()
|
||||
{
|
||||
ThrowIfCefBrowserIsNotReady();
|
||||
ThrowIfIsNotReady();
|
||||
return _cefBrowser;
|
||||
}
|
||||
|
||||
bool GetIsReady()
|
||||
{
|
||||
return _cefBrowser != nullptr;
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user