add get primary display DPI scale factor fix #129, #135

This commit is contained in:
vcaesar 2018-07-09 22:52:55 +08:00
parent 22fbae18dd
commit ec82b0fd15
3 changed files with 33 additions and 2 deletions

View File

@ -1293,6 +1293,16 @@ ____ __ ____ __ .__ __. _______ ______ ____ __ ____
*/
// ScaleX get primary display horizontal DPI scale factor
func ScaleX() int {
return int(C.scalex())
}
// ScaleY get primary display vertical DPI scale factor
func ScaleY() int {
return int(C.scaley())
}
// ShowAlert show a alert window
func ShowAlert(title, msg string, args ...string) int {
var (

View File

@ -18,6 +18,27 @@ int show_alert(const char *title, const char *msg,
return alert;
}
intptr scalex(){
#if defined(IS_WINDOWS)
// Get desktop dc
HDC desktopDc = GetDC(NULL);
// Get native resolution
intptr horizontalDPI = GetDeviceCaps(desktopDc, LOGPIXELSX);
// intptr verticalDPI = GetDeviceCaps(desktopDc, LOGPIXELSY);
return horizontalDPI;
#endif
}
intptr scaley(){
#if defined(IS_WINDOWS)
// Get desktop dc
HDC desktopDc = GetDC(NULL);
// Get native resolution
intptr verticalDPI = GetDeviceCaps(desktopDc, LOGPIXELSY);
return verticalDPI;
#endif
}
bool is_valid(){
bool abool = IsValid();
return abool;
@ -68,7 +89,7 @@ void set_active(const MData win){
DWORD dwProcessId = 0;
GetWindowThreadProcessId(hWnd, &dwProcessId);
if(dwProcessId == pInfo->dwPid) {
if (dwProcessId == pInfo->dwPid) {
pInfo->hWnd = hWnd;
return FALSE;
}

View File

@ -560,7 +560,7 @@ bool IsMaximized(void){
void SetActive(const MData win){
// Check if the window is valid
if (!IsValid()) {return;}
if (!IsValid()) { return; }
#if defined(IS_MACOSX)
// Attempt to raise the specified window object