x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

SWindow::MoveWindowTo( FVector2D NewPosition ) doesn't work anymore

SWindow.h (Runtime/SlateCore/Public/Widgets/SWindow.h):

The public function

void MoveWindowTo( FVector2D NewPosition );

create a error LNK2019

Erreur LNK2019 symbole externe non résolu "__declspec(dllimport) public: void __cdecl SWindow::MoveWindowTo(struct FVector2D)" (__imp_?MoveWindowTo@SWindow@@QEAAXUFVector2D@@@Z) référence dans la fonction "public: static void __cdecl UCustomBlueprintLibrary::SetWindowPosition(int,int)" (?SetWindowPosition@UCustomBlueprintLibrary@@SAXHH@Z) BlazingSun C:\Users\jeanl\Documents\Unreal Projects\BlazingSun\Intermediate\ProjectFiles\CustomBlueprintLibrary.cpp.obj 1

Code:

 #include "Runtime/SlateCore/Public/Widgets/SWindow.h"
 #include "CustomBlueprintLibrary.h"
 
 void UCustomBlueprintLibrary::SetWindowPosition(float x=-1.f, float y=-1.f)
 {
     if (GEngine && GEngine->GameViewport)
     {
         FVector2D ScreenPosition;
         ScreenPosition.X = x;
         ScreenPosition.Y = y;
         GEngine->GameViewport->GetWindow()->MoveWindowTo(ScreenPosition);
     }
 }






Product Version: UE 4.10 Preview
Tags:
more ▼

asked Nov 03 '15 at 03:40 PM in Bug Reports

avatar image

Shinje
89 5 10 16

avatar image Doug E ♦♦ STAFF Nov 03 '15 at 06:11 PM

Hey Shinje-

The MoveWindowTo function is not one I'm familiar with. How were you using it previously and what is different now? It appears the code you posted is in a custom Blueprint Library, correct? Where is your function being called from? Please provide any additional information that will help me understand how the function is not working and to test on my end.

Cheers

Doug Wilson

avatar image Shinje Nov 03 '15 at 09:35 PM

Exact, the code is in a custom library. The function must be used in a level blueprint but isn't actually used. It was used in the previous versions with no problems.

avatar image Doug E ♦♦ STAFF Nov 04 '15 at 05:22 PM

Could you post the full class for your blueprint function library? I tried to copy the function posted above and got a number of compile errors. I noticed you're using "GEngine" which would require #include "Engine.h" - even after adding this include statement I'm getting other compile errors.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey Shinje-

I was able to get the function posted in your original post to work by adding SlateCore to the Build.cs file. After this I tested the function again in a new 4.10 preview 4 project and it worked for me there as well. I noticed in the full class that you posted the line that calls MoveWindowTo is commented out. I'm not sure if this was for testing purposes but this would explain why it was not having an effect. After un-commenting this line, and adding "SlateCore" to the Build.cs file, the window should update accordingly when the function is called.

Cheers

Doug Wilson

more ▼

answered Nov 04 '15 at 08:02 PM

avatar image Shinje Nov 04 '15 at 09:57 PM

Hi Doug, the line was commented out because of the problem, to continue my work with no compile error. And

 // Uncomment if you are using Slate UI
 PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

is already uncommented. The problem persists. I don't understand.

EDIT. I was in 4.10 preview 3. I'll test with le Preview 4 and I'll tell you.

avatar image Shinje Nov 05 '15 at 05:15 AM

Bug corrected in 4.10 Preview 4. Thank you.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

There's the full source code

CustomBlueprintLibrary.h

 // Copyright 2014© BnG Interactive
 
 #pragma once
 
 #include "Runtime/SlateCore/Public/Widgets/SWindow.h"
 #include "CustomBlueprintLibrary.generated.h"
 
 class UBSSaveGame;
 
 class UUserWidget;
 
 class IGameMoviePlayer;
 
 class SWindow;
 
 UENUM(BlueprintType)
 enum class IniFileType : uint8
 {
     GAMEINI UMETA(DisplayName = "Game.ini file"),
     ENGINEINI UMETA(DisplayName = "Engine.ini file"),
     LIGHTMASSINI UMETA(DisplayName = "Lightmass.ini file"),
     SCALABILITYINI UMETA(DisplayName = "Scalability.ini file"),
     INPUTINI UMETA(DisplayName = "Input.ini file"),
     GAMEUSERSETTINGSINI UMETA(DisplayName = "GameUserSettings.ini file"),
 };
 
 UENUM(BlueprintType)
 enum class ProtectionType
 {
     NONE UMETA(DisplayName = "Aucune"),
     HEAT UMETA(DisplayName = "Chaud"),
     COLD UMETA(DisplayName = "Froid"),
     BOTH UMETA(DisplayName = "Chaud et Froid"),
 };
 
 USTRUCT(BlueprintType)
 struct FScreenSettings
 {
     GENERATED_USTRUCT_BODY()
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Screen)
     int32 Width;
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Screen)
     int32 Height;
 };
 
 UCLASS()
 class BLAZINGSUN_API UCustomBlueprintLibrary : public UBlueprintFunctionLibrary
 {
     GENERATED_UCLASS_BODY()
 public:
 
     //Fonction de remplacement IniFileType par le string correspondant
     static FString GetIniFile(IniFileType pType);
 
     //Fonctions de lecture
     UFUNCTION(BlueprintPure, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static bool GetIniBooleanVar(IniFileType pType, FString SectionName, FString VariableName);
 
     UFUNCTION(BlueprintPure, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static int32 GetIniIntegerVar(IniFileType pType, FString SectionName, FString VariableName);
 
     UFUNCTION(BlueprintPure, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static float GetIniFloatVar(IniFileType pType, FString SectionName, FString VariableName);
 
     UFUNCTION(BlueprintPure, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static FVector GetIniVectorVar(IniFileType pType, FString SectionName, FString VariableName);
 
     UFUNCTION(BlueprintPure, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static FRotator GetIniRotationVar(IniFileType pType, FString SectionName, FString VariableName);
 
     UFUNCTION(BlueprintPure, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static FLinearColor GetIniColorVar(IniFileType pType, FString SectionName, FString VariableName);
 
     UFUNCTION(BlueprintPure, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static FString GetIniStringVar(IniFileType pType, FString SectionName, FString VariableName);
 
     //Fonction d'insertion
     UFUNCTION(BlueprintCallable, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static void SetIniBooleanVar(IniFileType pType, FString SectionName, FString VariableName, bool Value);
 
     UFUNCTION(BlueprintCallable, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static void SetIniIntegerVar(IniFileType pType, FString SectionName, FString VariableName, int32 Value);
 
     UFUNCTION(BlueprintCallable, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static void SetIniFloatVar(IniFileType pType, FString SectionName, FString VariableName, float Value);
 
     UFUNCTION(BlueprintCallable, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static void SetIniVectorVar(IniFileType pType, FString SectionName, FString VariableName, FVector Value);
 
     UFUNCTION(BlueprintCallable, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static void SetIniRotationVar(IniFileType pType, FString SectionName, FString VariableName, FRotator Value);
 
     UFUNCTION(BlueprintCallable, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static void SetIniColorVar(IniFileType pType, FString SectionName, FString VariableName, FColor Value);
 
     UFUNCTION(BlueprintCallable, Category = "INI Files", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static void SetIniStringVar(IniFileType pType, FString SectionName, FString VariableName, FString Value);
 
     UFUNCTION(BlueprintCallable, Category = "Conversions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static float ConvertToFahrenheitDegrees(float value);
 
     UFUNCTION(BlueprintCallable, Category = "Conversions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static float ConvertToCelciusDegrees(float value);
 
     UFUNCTION(BlueprintCallable, Category = "Math|Float", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static float RoundToXDecimals(float value, int32 DecimalsNumber);
 
     UFUNCTION(BlueprintCallable, Category = "Math|integer", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static FString IntToString(int32 value);
 
     UFUNCTION(BlueprintCallable, Category = "Screen Resolutions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static FScreenSettings GetActualScreenSettings();
 
     UFUNCTION(BlueprintCallable, Category = "Screen Resolutions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static TArray<FScreenSettings> GetAllScreenResolutions();
 
     UFUNCTION(BlueprintCallable, Category = "Screen Resolutions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static FString ResolutionCommand(FScreenSettings Screen, bool Fullscreen);
 
     UFUNCTION(BlueprintCallable, Category = "Screen Resolutions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static void SetWindowPosition(float x, float y);
 
     UFUNCTION(BlueprintCallable, Category = "Convertions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
     static void ConvertToDateTime(float TimeInSeconds);
 
     UFUNCTION(BlueprintCallable, Category = "Convertions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static int32 GetHours(float TimeInSeconds);
 
     UFUNCTION(BlueprintCallable, Category = "Convertions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static int32 GetMinutes(float TimeInSeconds);
 
     UFUNCTION(BlueprintCallable, Category = "Convertions", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
         static int32 GetSeconds(float TimeInSeconds);
 
 };

CustomBlueprintLibrary.cpp

 // Copyright 2014© BnG Interactive
 
 #include "BlazingSun.h"
 #include "PlatformFeatures.h"
 #include "SaveSystem/BSSaveGame.h"
 #include "GameFramework/SaveGame.h"
 #include "Runtime/SlateCore/Public/Widgets/SWindow.h"
 //#include "Engine/Source/Runtime/MoviePlayer/Public/MoviePlayer.h"
 
 #include <cmath>
 
 #include "CustomBlueprintLibrary.h"
 
 UCustomBlueprintLibrary::UCustomBlueprintLibrary(const FObjectInitializer& ObjectInitializer)
 : Super(ObjectInitializer)
 {
 
 }
 
 FString UCustomBlueprintLibrary::GetIniFile(IniFileType pType){
 
     FString IniName = "";
 
     switch (pType){
     case IniFileType::GAMEINI:
         IniName = GGameIni;
         break;
     case IniFileType::ENGINEINI:
         IniName = GEngineIni;
         break;
     case IniFileType::LIGHTMASSINI:
         IniName = GLightmassIni;
         break;
     case IniFileType::SCALABILITYINI:
         IniName = GScalabilityIni;
         break;
     case IniFileType::INPUTINI:
         IniName = GInputIni;
         break;
     case IniFileType::GAMEUSERSETTINGSINI:
         IniName = GGameUserSettingsIni;
         break;
     }
 
     return IniName;
 }
 
 
 bool UCustomBlueprintLibrary::GetIniBooleanVar(IniFileType pType, FString SectionName, FString VariableName)
 {
     if (!GConfig) return false;
 
     bool Value;
     GConfig->GetBool(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
     return Value;
 
 }
 
 
 int32 UCustomBlueprintLibrary::GetIniIntegerVar(IniFileType pType, FString SectionName, FString VariableName)
 {
     if (!GConfig) return 0;
 
     int32 Value;
     GConfig->GetInt(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
     return Value;
 
 }
 
 
 float UCustomBlueprintLibrary::GetIniFloatVar(IniFileType pType, FString SectionName, FString VariableName)
 {
     if (!GConfig) return 0;
 
     float Value;
     GConfig->GetFloat(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
     return Value;
 
 }
 
 
 FVector UCustomBlueprintLibrary::GetIniVectorVar(IniFileType pType, FString SectionName, FString VariableName)
 {
     if (!GConfig) return FVector::ZeroVector;
 
     FVector Value;
     GConfig->GetVector(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
     return Value;
 }
 
 
 FRotator UCustomBlueprintLibrary::GetIniRotationVar(IniFileType pType, FString SectionName, FString VariableName)
 {
     if (!GConfig) return FRotator::ZeroRotator;
 
     FRotator Value;
     GConfig->GetRotator(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
     return Value;
 
 }
 
 
 FLinearColor UCustomBlueprintLibrary::GetIniColorVar(IniFileType pType, FString SectionName, FString VariableName)
 {
     if (!GConfig) return FColor::Black;
 
     FColor Value;
     GConfig->GetColor(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
     return Value;
 
 }
 
 
 FString UCustomBlueprintLibrary::GetIniStringVar(IniFileType pType, FString SectionName, FString VariableName)
 {
     if (!GConfig) return "";
 
     FString Value;
     GConfig->GetString(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
     return Value;
 
 }
 
 
 void UCustomBlueprintLibrary::SetIniBooleanVar(IniFileType pType, FString SectionName, FString VariableName, bool Value)
 {
     if (!GConfig) return;
 
     GConfig->SetBool(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
 
     GConfig->Flush(false, GetIniFile(pType));
 
 }
 
 
 void UCustomBlueprintLibrary::SetIniIntegerVar(IniFileType pType, FString SectionName, FString VariableName, int32 Value)
 {
     if (!GConfig) return;
 
     GConfig->SetInt(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
 
     GConfig->Flush(false, GetIniFile(pType));
 
 }
 
 
 void UCustomBlueprintLibrary::SetIniFloatVar(IniFileType pType, FString SectionName, FString VariableName, float Value)
 {
     if (!GConfig) return;
 
     GConfig->SetFloat(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
 
     GConfig->Flush(false, GetIniFile(pType));
 
 }
 
 
 void UCustomBlueprintLibrary::SetIniVectorVar(IniFileType pType, FString SectionName, FString VariableName, FVector Value)
 {
     if (!GConfig) return;
 
     GConfig->SetVector(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
 
     GConfig->Flush(false, GetIniFile(pType));
 
 }
 
 
 void UCustomBlueprintLibrary::SetIniRotationVar(IniFileType pType, FString SectionName, FString VariableName, FRotator Value)
 {
     if (!GConfig) return;
 
     GConfig->SetRotator(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
 
     GConfig->Flush(false, GetIniFile(pType));
 
 }
 
 
 void UCustomBlueprintLibrary::SetIniColorVar(IniFileType pType, FString SectionName, FString VariableName, FColor Value)
 {
     if (!GConfig) return;
 
     GConfig->SetColor(
         *SectionName,
         *VariableName,
         Value,
         GetIniFile(pType)
         );
 
     GConfig->Flush(false, GetIniFile(pType));
 
 }
 
 
 void UCustomBlueprintLibrary::SetIniStringVar(IniFileType pType, FString SectionName, FString VariableName, FString Value)
 {
     if (!GConfig) return;
 
     GConfig->SetString(
         *SectionName,
         *VariableName,
         *Value,
         GetIniFile(pType)
         );
 
     GConfig->Flush(false, GetIniFile(pType));
 
 }
 
 
 float UCustomBlueprintLibrary::ConvertToFahrenheitDegrees(float value){ return (value* (9 / 5)) + 32; }
 
 float UCustomBlueprintLibrary::ConvertToCelciusDegrees(float value){ return (value - 32)*(5 / 9); }
 
 float UCustomBlueprintLibrary::RoundToXDecimals(float value, int32 DecimalsNumber = 1)
 {
     int32 Factor = pow(10, DecimalsNumber);
     return floorf((value*Factor) + 0.5) / Factor;
 }
 
 FString UCustomBlueprintLibrary::IntToString(int32 value)
 {
     FString ConvertedValue;
     ConvertedValue.FromInt(value);
     return ConvertedValue;
 }
 
 FScreenSettings UCustomBlueprintLibrary::GetActualScreenSettings()
 {
     FScreenSettings ActualScreen;
 
 #if PLATFORM_WINDOWS
     RECT desktop;
     const HWND hDesktop = GetDesktopWindow();
     GetWindowRect(hDesktop, &desktop);
 
     ActualScreen.Width = (int32)desktop.right;
     ActualScreen.Height = (int32)desktop.bottom;
 #endif
 
     return ActualScreen;
 }
 
 TArray<FScreenSettings> UCustomBlueprintLibrary::GetAllScreenResolutions()
 {
     TArray<FScreenSettings> AvailableResolutions;
 
 #if PLATFORM_WINDOWS
     DEVMODE dm = { 0 };
     dm.dmSize = sizeof(dm);
     for (int iModeNum = 0; EnumDisplaySettings(NULL, iModeNum, &dm) != 0; iModeNum++) {
         FScreenSettings tempSS;
         tempSS.Height = (int32)dm.dmPelsHeight;
         tempSS.Width = (int32)dm.dmPelsWidth;
         AvailableResolutions.Add(tempSS);
     }
 #endif
 
     TArray<FScreenSettings> ResolutionsList;
 
     //Création de la liste finale
     //Supression des doublons lors de l'insertion
     for (int i = 0; i < AvailableResolutions.Num(); i++){
         if (ResolutionsList.Num() == 0)
         {
             ResolutionsList.Add(AvailableResolutions[i]);
         }
         else
         {
             bool bIsUnique = true;
 
             for (int n = 0; n < ResolutionsList.Num(); n++)
             {
                 if (ResolutionsList[n].Height == AvailableResolutions[i].Height && ResolutionsList[n].Width == AvailableResolutions[i].Width)
                 {
                     bIsUnique = false;
                     break;
                 }
 
             }
 
             if (bIsUnique)
             {
                 ResolutionsList.Add(AvailableResolutions[i]);
             }
         }
     }
 
     return ResolutionsList;
 }
 
 FString UCustomBlueprintLibrary::ResolutionCommand(FScreenSettings Screen, bool Fullscreen)
 {
     FString command;
     command = TEXT("r.SetRes ");
     command.AppendInt(Screen.Width);
     command.Append(TEXT("x"));
     command.AppendInt(Screen.Height);
 
     if (Fullscreen){ command.Append(TEXT("f")); }
     else{ command.Append(TEXT("w")); }
 
     return command;
 }
 
 void UCustomBlueprintLibrary::SetWindowPosition(float x=-1.f, float y=-1.f)
 {
     if (GEngine && GEngine->GameViewport)
     {
         FVector2D ScreenPosition;
         ScreenPosition.X = x;
         ScreenPosition.Y = y;
         //GEngine->GameViewport->GetWindow()->MoveWindowTo(ScreenPosition);
     }
 }
 
 
 void UCustomBlueprintLibrary::ConvertToDateTime(float TimeInSeconds)
 {
 
 
 }
 
 int32 UCustomBlueprintLibrary::GetHours(float TimeInSeconds)
 {
     return abs(TimeInSeconds / 3600);
 }
 
 int32 UCustomBlueprintLibrary::GetMinutes(float TimeInSeconds)
 {
     return abs((TimeInSeconds - (GetHours(TimeInSeconds) * 3600)) / 60);
 }
 
 int32 UCustomBlueprintLibrary::GetSeconds(float TimeInSeconds)
 {
     return abs(TimeInSeconds - (GetHours(TimeInSeconds) * 3600) - (GetMinutes(TimeInSeconds) * 60));
 }


more ▼

answered Nov 04 '15 at 07:21 PM

avatar image

Shinje
89 5 10 16

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question