Skip to content

Commit

Permalink
Merge pull request #38 from ansani/2-add-support-for-4k-screens
Browse files Browse the repository at this point in the history
Removed "DPI Aware" configuration
  • Loading branch information
ansani authored Oct 24, 2022
2 parents ea4a48a + 0a0a6bf commit df0a5b6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,5 @@ pip-log.txt
/plugins/ZIPBuilder/ZIPBuilder.h

#NuGet
/vc2022/.vs/*
/vc2022/packages/*
/vc143/.vs/*
/vc143/packages/*
18 changes: 17 additions & 1 deletion shareaza/FontManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

int GetDpi(HWND hWnd)
{
HDC hDC = ::GetDC(hWnd);
INT ydpi = ::GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(hWnd, hDC);
return ydpi;
}

CFontManager::CFontManager(void)
{
LOGFONT lf;
Expand All @@ -38,7 +46,15 @@ CFontManager::CFontManager(void)
if ( lf.lfHeight < 0 )
lf.lfHeight = -lf.lfHeight;

m_nDefaultSize = (WORD)MulDiv( lf.lfHeight, 72, GetDeviceCaps( hDC, LOGPIXELSY ) );
int dpi = GetDpi(GetDesktopWindow());
int scaling = static_cast<int>(100.0 * 96 / dpi);

//m_nDefaultSize = (WORD)MulDiv( lf.lfHeight, 96, GetDeviceCaps( hDC, LOGPIXELSY ) );
m_nDefaultSize = (WORD)lf.lfHeight * scaling/100;
//m_nDefaultSize = scaling;

// m_nDefaultSize = 10;

m_sFontName = lf.lfFaceName;

ReleaseDC( NULL, hDC );
Expand Down
6 changes: 3 additions & 3 deletions shareaza/Shareaza.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,9 @@ BOOL CShareazaApp::InitInstance()
AfxOleInit(); // Initializes OLE support for the application.
AfxGetThread()->m_lpfnOleTermOrFreeLib = AfxOleTermOrFreeLibSafe;
CoInitializeSecurity( NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL );
// m_pFontManager = new CFontManager();
AfxEnableControlContainer( /*m_pFontManager*/); // Enable support for containment of OLE controls.
InitFonts(); // Loads default fonts. Depends on Settings.Load().
CFontManager *m_pFontManager = new CFontManager();
AfxEnableControlContainer(m_pFontManager); // Enable support for containment of OLE controls.
InitResources(); // Loads theApp settings.
Settings.Load(); // Loads settings. Depends on InitResources().

Expand All @@ -354,7 +355,6 @@ BOOL CShareazaApp::InitInstance()
}
}

InitFonts(); // Loads default fonts. Depends on Settings.Load().
Skin.CreateDefault(); // Loads colors, fonts and language. Depends on InitFonts().
Register(); // Re-register Shareaza Type Library
LoadStdProfileSettings(); // Load MRU file list and last preview state.
Expand Down
4 changes: 4 additions & 0 deletions shareaza/Shareaza_143.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<PostBuildEvent />
<Manifest>
<AdditionalManifestFiles>compatibility.manifest</AdditionalManifestFiles>
<EnableDpiAwareness>false</EnableDpiAwareness>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand Down Expand Up @@ -202,6 +203,7 @@
<PostBuildEvent />
<Manifest>
<AdditionalManifestFiles>compatibility.manifest</AdditionalManifestFiles>
<EnableDpiAwareness>false</EnableDpiAwareness>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down Expand Up @@ -257,6 +259,7 @@
<PostBuildEvent />
<Manifest>
<AdditionalManifestFiles>compatibility.manifest</AdditionalManifestFiles>
<EnableDpiAwareness>false</EnableDpiAwareness>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand Down Expand Up @@ -311,6 +314,7 @@
<PostBuildEvent />
<Manifest>
<AdditionalManifestFiles>compatibility.manifest</AdditionalManifestFiles>
<EnableDpiAwareness>false</EnableDpiAwareness>
</Manifest>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down

0 comments on commit df0a5b6

Please sign in to comment.