Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorFlynn authored May 16, 2017
1 parent dacad10 commit 2692909
Show file tree
Hide file tree
Showing 12 changed files with 1,479 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Borderless Window Helper.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Borderless Window Helper", "Borderless Window Helper\Borderless Window Helper.vcxproj", "{717C50BB-37D4-4F30-89C7-025F5725C83B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{717C50BB-37D4-4F30-89C7-025F5725C83B}.Debug|x64.ActiveCfg = Debug|x64
{717C50BB-37D4-4F30-89C7-025F5725C83B}.Debug|x64.Build.0 = Debug|x64
{717C50BB-37D4-4F30-89C7-025F5725C83B}.Debug|x86.ActiveCfg = Debug|Win32
{717C50BB-37D4-4F30-89C7-025F5725C83B}.Debug|x86.Build.0 = Debug|Win32
{717C50BB-37D4-4F30-89C7-025F5725C83B}.Release|x64.ActiveCfg = Release|x64
{717C50BB-37D4-4F30-89C7-025F5725C83B}.Release|x64.Build.0 = Release|x64
{717C50BB-37D4-4F30-89C7-025F5725C83B}.Release|x86.ActiveCfg = Release|Win32
{717C50BB-37D4-4F30-89C7-025F5725C83B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
151 changes: 151 additions & 0 deletions Borderless Window Helper/Borderless Window Helper.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{717C50BB-37D4-4F30-89C7-025F5725C83B}</ProjectGuid>
<RootNamespace>BorderlessWindowHelper</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<AdditionalDependencies>nana_v140_Debug_x86.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>nana_v140_Debug_x64.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>nana_v140_Release_x86.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableParallelCodeGeneration>
</EnableParallelCodeGeneration>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>nana_v140_Release_x64.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="inifile.h" />
<ClInclude Include="main.h" />
<ClInclude Include="nana_subclassing.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="util.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="inifile.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="util.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Borderless Window Helper.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="E:\VM\Shared\Icons\window.ico" />
<Image Include="window.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
186 changes: 186 additions & 0 deletions Borderless Window Helper/inifile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
#include "inifile.h"

wstring IniFile::safe_fname;

IniFile::IniFile(const wstring &fname) : fname(fname), sort_sections(false), sort_entries(false), nospaces(false)
{
static bool first(true);

if(first)
{
first = false;
wstring appdata(ini_file::GetSysFolderLocation(CSIDL_APPDATA));
if(appdata.size()) safe_fname = appdata + fname.substr(fname.rfind('\\'));
}

LoadData();
}

void IniFile::LoadData()
{
bool b = FileExist(safe_fname.data());
if(!b && !FileExist(fname.data())) return;

ifstream file(b ? safe_fname : fname, ios::ate);
if(!file.is_open()) return;
size_t size = (size_t)file.tellg();
if(!size) return;
stringstream data;
string data_temp(size, '\0');
file.seekg(0);
file.read(&data_temp.front(), size);
data << data_temp;
data_temp.clear();

string line, section_name, entry_name, entry_data;
size_t section_index;

while(!data.eof())
{
getline(data, line);
if(line.size() < 3 || line[0] != '[') continue;
section_name = line.substr(1, line.find(']', 1)-1);

bool found = false;
for(section_index = 0; section_index<sections.size(); section_index++)
if(sections[section_index].name() == section_name) { found = true; break; }
if(!found)
{
sections.emplace_back(section_name);
section_index = sections.size() - 1;
}

while(!data.eof() && data.peek() != '[')
{
getline(data, line);
size_t pos = line.find('=');
if(pos == string::npos) continue;
entry_name = line.substr(0, pos);
entry_name = entry_name.substr(0, entry_name.find(' '));
size_t p = line.find_first_not_of(' ', pos+1);
entry_data = p == string::npos ? "" : line.substr(p);
sections[section_index].add_entry(entry_name, entry_data);
}
}
}

void IniFile::SaveData()
{
if(sections.empty() || sections[0].entries.empty()) return;
bool b = FileExist(safe_fname.data());
ofstream file(b ? safe_fname : fname, ios::trunc);
if(!file.is_open())
{
file.open(safe_fname, ios::trunc);
if(!file.is_open()) return;
}
if(sort_sections) sort(sections.begin(), sections.end(), [](section a, section b) {
return lexicographical_compare(a.name().begin(), a.name().end(), b.name().begin(), b.name().end());
});

for(auto &section : sections)
{
file << '[' << section.name() << "]\n";
if(sort_entries) sort(section.entries.begin(), section.entries.end(), [](section::entry a, section::entry b) {
return lexicographical_compare(a.name().begin(), a.name().end(), b.name().begin(), b.name().end());
});

for(auto &entry : section.entries)
file << entry.name() << (nospaces ? "=" : " = ") << entry.data() << '\n';

if(section.name() != sections.back().name()) file << '\n';
}
}

void IniFile::section::add_entry(const string &name, const string &data)
{
bool hasentry = false;
size_t n;

for(n=0; n<entries.size(); n++)
if(entries[n].name() == name) { hasentry = true; break; }

if(hasentry) entries[n].setdata(data);
else entries.emplace_back(name, data);
}

void IniFile::WriteInt(const string &section_name, const string& entry_name, int value)
{
bool hassection = false;
size_t n = 0;

for(; n<sections.size(); n++)
if(sections[n].name() == section_name) { hassection = true; break; }

if(hassection) sections[n].add_entry(entry_name, to_string(value));
else
{
sections.emplace_back(section_name);
sections.back().add_entry(entry_name, to_string(value));
}
}

void IniFile::WriteUInt(const string &section_name, const string& entry_name, unsigned value)
{
bool hassection = false;
size_t n = 0;

for(; n<sections.size(); n++)
if(sections[n].name() == section_name) { hassection = true; break; }

if(hassection) sections[n].add_entry(entry_name, to_string(value));
else
{
sections.emplace_back(section_name);
sections.back().add_entry(entry_name, to_string(value));
}
}

void IniFile::WriteString(const string &section_name, const string& entry_name, const string &value)
{
bool hassection = false;
size_t n = 0;

for(; n<sections.size(); n++)
if(sections[n].name() == section_name) { hassection = true; break; }

if(hassection) sections[n].add_entry(entry_name, value);
else
{
sections.emplace_back(section_name);
sections.back().add_entry(entry_name, value);
}
}

int IniFile::ReadInt(const string &section_name, const string &entry_name, int default_value)
{
for(auto &section : sections)
if(section.name() == section_name)
for(auto &entry : section.entries)
if(entry.name() == entry_name)
return stoi(entry.data());

return default_value;
}

unsigned IniFile::ReadUInt(const string &section_name, const string &entry_name, unsigned default_value)
{
for(auto &section : sections)
if(section.name() == section_name)
for(auto &entry : section.entries)
if(entry.name() == entry_name)
return stoul(entry.data());

return default_value;
}

string IniFile::ReadString(const string &section_name, const string &entry_name, const string &default_value)
{
for(auto &section : sections)
if(section.name() == section_name)
for(auto &entry : section.entries)
if(entry.name() == entry_name)
return entry.data();

return default_value;
}
Loading

0 comments on commit 2692909

Please sign in to comment.