本文整理汇总了C++中IECommandExecutor::GetManagedBrowser方法的典型用法代码示例。如果您正苦于以下问题:C++ IECommandExecutor::GetManagedBrowser方法的具体用法?C++ IECommandExecutor::GetManagedBrowser怎么用?C++ IECommandExecutor::GetManagedBrowser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IECommandExecutor
的用法示例。
在下文中一共展示了IECommandExecutor::GetManagedBrowser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteInternal
void SetWindowPositionCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator id_parameter_iterator = command_parameters.find("windowHandle");
ParametersMap::const_iterator x_parameter_iterator = command_parameters.find("x");
ParametersMap::const_iterator y_parameter_iterator = command_parameters.find("y");
if (id_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(400, "Missing parameter in URL: windowHandle");
return;
} else if (x_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(400, "Missing parameter: x");
return;
} else if (y_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(400, "Missing parameter: y");
return;
} else {
int status_code = WD_SUCCESS;
int x = x_parameter_iterator->second.asInt();
int y = y_parameter_iterator->second.asInt();
std::string window_id = id_parameter_iterator->second.asString();
BrowserHandle browser_wrapper;
if (window_id == "current") {
status_code = executor.GetCurrentBrowser(&browser_wrapper);
} else {
status_code = executor.GetManagedBrowser(window_id, &browser_wrapper);
}
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Error retrieving window with handle " + window_id);
return;
}
HWND window_handle = browser_wrapper->GetTopLevelWindowHandle();
POINT desired_location;
desired_location.x = x;
desired_location.y = y;
BOOL set_window_pos_result = ::SetWindowPos(window_handle, NULL, desired_location.x, desired_location.y, 0, 0, SWP_NOSIZE);
if (!set_window_pos_result) {
response->SetErrorResponse(EUNHANDLEDERROR,
"Unexpected error setting window size (SetWindowPos API failed)");
return;
}
response->SetSuccessResponse(Json::Value::null);
}
}