I'm currently working on developing a unique C++ function that can be invoked from JavaScript to resize the window.
The necessary components are located in various files:
Within appshell_extensions_platform.h:
#if defined(OS_WIN)
void ResizeWindow(CefRefPtr<CefBrowser> browser, int width, int height);
#endif
Inside appshell_extensions_win.cpp:
void ResizeWindow(CefRefPtr<CefBrowser> browser, int width, int height) {
OutputDebugString(L"ResizeWindow");
CefWindowHandle hWnd = browser->GetHost()->GetWindowHandle();
SetWindowPos(hWnd, 0, 0, 0, width, height, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
}
Within appshell_extensions.js:
/**
* Modifies the window size to the specified dimensions.
*
* @param {number} width
* @param {number} height
*
* @return None. This function is asynchronous and sends return information to the callback.
*/
native function ResizeWindow();
appshell.app.resizeWindow = function (width, height) {
ResizeWindow(width, height);
};
In appshell_extensions.cpp:
} else if (message_name == "ResizeWindow") {
// Parameters:
// 0: int32 - width
// 1: int32 - height
int width = argList->GetInt(0);
int height = argList->GetInt(1);
ResizeWindow(browser, width, height);
}
Using Visual Studio 2012, I compile and debug on the Debug Win32 release. The appshell.app.resizeWindow
function appears in the console as expected and functions correctly when called. Additional JavaScript code within the function also executes properly.
I've added
OutputDebugString(std::wstring(message_name.begin(), message_name.end()).c_str());
to the function in appshell_extensions.cpp
. While it outputs message names for other functions, I receive no output for the function I implemented.
Furthermore, I don't receive any output from the function itself.
It seems like the message isn't reaching the processing function, but I'm unsure of the issue. I'm using the provided solution from brackets-shell (converted to 2012) for compilation. Is there a possible build step that I might be overlooking?
Thank you.