2017-03-05 23:44:37 +01:00
|
|
|
// Copyright © 2010-2017 The CefSharp Authors. All rights reserved.
|
2014-12-30 12:19:24 +10:00
|
|
|
//
|
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
#include "Stdafx.h"
|
|
|
|
|
|
2015-09-29 15:14:18 +10:00
|
|
|
#include "NativeMethodWrapper.h"
|
2014-12-30 12:19:24 +10:00
|
|
|
|
|
|
|
|
namespace CefSharp
|
|
|
|
|
{
|
2014-12-30 16:29:07 +10:00
|
|
|
void NativeMethodWrapper::CopyMemoryUsingHandle(IntPtr dest, IntPtr src, int numberOfBytes)
|
2014-12-30 16:23:36 +10:00
|
|
|
{
|
2014-12-30 16:29:07 +10:00
|
|
|
CopyMemory(dest.ToPointer(), src.ToPointer(), numberOfBytes);
|
2014-12-30 16:23:36 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NativeMethodWrapper::IsFocused(IntPtr handle)
|
|
|
|
|
{
|
|
|
|
|
// Ask Windows which control has the focus and then check if it's one of our children
|
|
|
|
|
auto focusControl = GetFocus();
|
|
|
|
|
return focusControl != 0 && (IsChild((HWND)handle.ToPointer(), focusControl) == 1);
|
|
|
|
|
}
|
2017-01-23 16:49:14 +10:00
|
|
|
|
|
|
|
|
void NativeMethodWrapper::SetWindowPosition(IntPtr handle, int x, int y, int width, int height)
|
|
|
|
|
{
|
|
|
|
|
HWND browserHwnd = static_cast<HWND>(handle.ToPointer());
|
|
|
|
|
if (browserHwnd)
|
|
|
|
|
{
|
|
|
|
|
if (width == 0 && height == 0)
|
|
|
|
|
{
|
|
|
|
|
// For windowed browsers when the frame window is minimized set the
|
|
|
|
|
// browser window size to 0x0 to reduce resource usage.
|
|
|
|
|
SetWindowPos(browserHwnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetWindowPos(browserHwnd, NULL, x, y, width, height, SWP_NOZORDER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-30 12:19:24 +10:00
|
|
|
}
|