rodecomp/Source/Client/Browser/WebBrowser.cpp
ragnarok-clanker b754cde45a Decompile fn_45434 (CWebBrowser::AttachExternalEvents)
Batch #14913 by SapitoSucio: 1 byte-identical, 0 confirmed by peer review.

- fn_45434 CWebBrowser::AttachExternalEvents: byte-identical

Merged automatically: every function is byte-identical to the original.
2026-11-08 07:48:12 +00:00

120 lines
3.4 KiB
C++

#include "Client/Application/ApplicationActivation.h"
#include "Client/Application/ApplicationWindow.h"
#include "Client/Browser/BrowserClientSite.h"
#include "UI/Window/UIWindowMgr.h"
#include "Client/Browser/WebBrowser.h"
#include "Client/Browser/WebEventReceiver.h"
#include "Client/Input/Mouse.h"
#include "Contents/Configuration/ServiceOptions.h"
#include <new>
#include <ocidl.h>
#include <utility>
// OFFSET: 0x00AB1DE0
// FUNCTION: fn_17409
CWebBrowser::CWebBrowser()
: browser(nullptr), externalEvents(nullptr), site(nullptr), host(nullptr), browserWindow(nullptr), cursorState(0), auxiliaryVisible(0),
screenWidth(GetSystemMetrics(SM_CXSCREEN)), screenHeight(GetSystemMetrics(SM_CYSCREEN)), cookie(0), rebar(nullptr), combo(nullptr), barHeight(0),
width(0), height(0), restoreOption(0) {
OutputDebugStringA("CWebBrowser() \n");
if (g_serviceOptions.Get(ServiceOption::ConfineCursor) == 0) {
return;
}
POINT position{g_mouse.x, g_mouse.y};
g_serviceOptions.Set(ServiceOption::ConfineCursor, 0);
g_mouse.SetX(position.x);
g_mouse.SetY(position.y);
this->restoreOption = 1;
ClientToScreen(hWnd, &position);
SetCursorPos(position.x, position.y);
}
// OFFSET: 0x00AB1F20
// FUNCTION: fn_17410
CWebBrowser::~CWebBrowser() {
OutputDebugStringA("~CWebBrowser() \n");
if (this->restoreOption != 0) {
POINT position;
GetCursorPos(&position);
ScreenToClient(hWnd, &position);
g_serviceOptions.Set(ServiceOption::ConfineCursor, 1);
g_mouse.SetX(position.x);
g_mouse.SetY(position.y);
SetActiveWindow(hWnd);
SetApplicationActive(1);
}
if (this->cursorState != 0) {
SetCursor(nullptr);
g_mouse.Reset();
ShowCursor(FALSE);
this->cursorState = 0;
}
if (this->site) {
IOleObject* object;
if (SUCCEEDED(this->browser->QueryInterface(IID_IOleObject, reinterpret_cast<void**>(&object)))) {
IConnectionPointContainer* container;
if (SUCCEEDED(object->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void**>(&container)))) {
IConnectionPoint* point;
if (SUCCEEDED(container->FindConnectionPoint(DIID_DWebBrowserEvents2, &point))) {
point->Unadvise(this->cookie);
point->Release();
}
container->Release();
}
object->Release();
}
delete this->site;
this->site = nullptr;
}
if (this->externalEvents) {
this->externalEvents->Release();
this->externalEvents = nullptr;
}
if (this->browser) {
this->browser->Stop();
SetWindowLongA(this->browserWindow, GWL_STYLE, WS_CHILD);
SetParent(this->browserWindow, hWnd);
this->browser->Quit();
this->browser->Release();
this->browser = nullptr;
}
if (this->host) {
DestroyWindow(this->host);
this->host = nullptr;
}
}
// OFFSET: 0x00AB2950
// FUNCTION: fn_45434
bool CWebBrowser::AttachExternalEvents() {
this->externalEvents = new CWebEventReceiver();
this->externalEvents->AddRef();
return static_cast<CWebEventReceiver*>(this->externalEvents)->Register(this->browser, this->host) != 0;
}
// OFFSET: 0x00AB3030
// FUNCTION: fn_17420
bool CWebBrowser::MatchesWindow(HWND window) const {
return this->host == window || this->host == GetParent(window);
}
// OFFSET: 0x00AB26D0
// FUNCTION: fn_17415
int CWebBrowser::AddressBarHeight() {
if (this->rebar && this->auxiliaryVisible) {
RECT rectangle;
GetClientRect(this->rebar, &rectangle);
return rectangle.bottom - rectangle.top + 4;
}
return 0;
}