UE C++一些记录
#include <windows/WindowsWindow.h>
#include "Windows/AllowWindowsPlatformTypes.h"
#include <windows.h>
#include <shellapi.h>
#include "Windows/HideWindowsPlatformTypes.h"
UUETuioBPLibrary::UUETuioBPLibrary(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
float UUETuioBPLibrary::UETuioSampleFunction(float Param)
{
return -1;
}
void UUETuioBPLibrary::MyWindowShow()
{
#if PLATFORM_WINDOWS
TSharedPtr<FGenericWindow> NativeWindow = GEngine->GameViewport->GetWindow()->GetNativeWindow();
FWindowsWindow* Window = static_cast<FWindowsWindow*>(NativeWindow.Get());
HWND hWnd = Window->GetHWnd();
#endif // #if PLATFORM_WINDOWS
::ShowWindow(hWnd, SW_SHOWNORMAL);
}
void UUETuioBPLibrary::MyWindowHide()
{
#if PLATFORM_WINDOWS
TSharedPtr<FGenericWindow> NativeWindow = GEngine->GameViewport->GetWindow()->GetNativeWindow();
FWindowsWindow* Window = static_cast<FWindowsWindow*>(NativeWindow.Get());
HWND hWnd = Window->GetHWnd();
#endif // #if PLATFORM_WINDOWS
::ShowWindow(hWnd, SW_MINIMIZE);
}
void UUETuioBPLibrary::MyWindowPos(int x, int y,int w,int h)
{
#if PLATFORM_WINDOWS
TSharedPtr<FGenericWindow> NativeWindow = GEngine->GameViewport->GetWindow()->GetNativeWindow();
FWindowsWindow* Window = static_cast<FWindowsWindow*>(NativeWindow.Get());
HWND hWnd = Window->GetHWnd();
#endif // #if PLATFORM_WINDOWS
DWORD mWindowExStyle;
DWORD mWindowStyle;
if (true)
{
mWindowExStyle = WS_EX_APPWINDOW;
mWindowStyle = WS_POPUP;
}
::SetWindowLongA(hWnd, GWL_STYLE, mWindowStyle);
::SetWindowLongA(hWnd, GWL_EXSTYLE, mWindowExStyle);
::SetWindowPos(hWnd, HWND_NOTOPMOST, x, y, w, h,SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOZORDER);
::InvalidateRect(0, NULL, true);
}
void UUETuioBPLibrary::SetFrameRate(int inrate)
{
FGenericPlatformRHIFramePacer::SetFramePace(inrate);
}
void BorderlessWindow::setBorderless(HWND hWnd, int x, int y, int w, int h, bool borderless) { mBorderless = false; //mWnd = WindowFromDC(wglGetCurrentDC()); if (mBorderless != borderless) { mBorderless = borderless; if (mBorderless) { mWindowExStyle = WS_EX_APPWINDOW; mWindowStyle = WS_POPUP; } else { mWindowExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style mWindowStyle = true ? WS_OVERLAPPEDWINDOW : (WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME); // Windows Style } //POINT upperLeft; //upperLeft.x = upperLeft.y = 0; //::ClientToScreen(hWnd, &upperLeft ); //RECT windowRect; //::GetClientRect(hWnd, &windowRect ); //printf("%i", ::GetLastError()); //windowRect.left += upperLeft.x; windowRect.right += upperLeft.x; //windowRect.top += upperLeft.y; windowRect.bottom += upperLeft.y; //::AdjustWindowRectEx( &windowRect, mWindowStyle, FALSE, mWindowExStyle ); // Adjust Window To True Requested Size ::SetWindowLongA(hWnd, GWL_STYLE, mWindowStyle); ::SetWindowLongA(hWnd, GWL_EXSTYLE, mWindowExStyle); /*::SetWindowPos(hWnd, HWND_TOP, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOZORDER );*/ ::SetWindowPos(hWnd, HWND_NOTOPMOST, x, y, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOZORDER); if (mBorderless) ::InvalidateRect(0, NULL, TRUE); } } void BorderlessWindow::setTransparent(HWND hWnd, COLORREF clr, BYTE byAlpha, DWORD dwFlags) { typedef BOOL(FAR PASCAL *Fun)(HWND, COLORREF, BYTE, DWORD); Fun SetTransparentFun; HMODULE hModule = LoadLibraryA("User32.DLL"); if (hModule) { SetTransparentFun = (Fun)GetProcAddress(hModule, "SetLayeredWindowAttributes"); if (SetTransparentFun&&hWnd) { SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | 0x80000L); SetTransparentFun(hWnd, clr, byAlpha, dwFlags); } FreeLibrary(hModule); } }
如果声明代理中需要传入数组,如下
DECLARE_DYNAMIC_DELEGATE_OneParam(FSerachDataByStringValDelegate,
TArray<FPOIData>, poiDataSearchArr);
在蓝图层面是会报错的,报错信息如下
customevent_0 signature error: the function/event ‘customevent_0’ does not match the necessary signature - has the delegate or function/event changed?
解决办法如下:
DECLARE_DYNAMIC_DELEGATE_OneParam(FSerachDataByStringValDelegate,
const TArray<FPOIData>&, poiDataSearchArr);