HeaderPane
Main
Hide
Share Link
Print

DPI

Returns the DPI a control currently uses.

C

int WINAPI SftDate_GetDPI(HWND hwndCtl);

C++

int CSftDate::GetDPI() const;
int CSftCalendar::GetDPI() const;

Parameters

hwndCtl

The window handle of the date field control (SftDate) or the month calendar control (SftCalendar).

Returns

The return value is the DPI of the monitor the control is on, for example 96 at 100% scaling or 144 at 150%. 96 is returned if hwndCtl is not a date field or month calendar control.

Comments

The GetDPI function returns the DPI the control uses to size and draw its parts. In a per-monitor DPI aware application (PerMonitorV2), the control follows the DPI of its monitor and sends the NM_SFTDATE_DPI_CHANGED notification when it changes. In an application that is not DPI aware, it returns 96.

The dropdown of a date field control uses the DPI of the monitor it opens on. See Per-Monitor DPI and Scaling.

Examples

C View entire sample code

        wsprintf(szData, TEXT("active=%d"), SftDate_IsDarkModeActive(lpnmhdr->hwndFrom));
        break;
    case NM_SFTDATE_HIGHCONTRAST_CHANGED:
        lpszCode = TEXT("NM_SFTDATE_HIGHCONTRAST_CHANGED");
        wsprintf(szData, TEXT("active=%d"), SftDate_IsHighContrastActive(lpnmhdr->hwndFrom));
        break;
    case NM_SFTDATE_DPI_CHANGED:
        lpszCode = TEXT("NM_SFTDATE_DPI_CHANGED");
        wsprintf(szData, TEXT("dpi=%d"), SftDate_GetDPI(lpnmhdr->hwndFrom));
        break;
    case NM_SETFOCUS:
        lpszCode = TEXT("NM_SETFOCUS");
        break;
    case NM_KILLFOCUS:
        lpszCode = TEXT("NM_KILLFOCUS");
        break;

C++ View entire sample code

        data.Format(_T("active=%d"), SftDate_IsDarkModeActive(pNMHDR->hwndFrom));
        break;
    case NM_SFTDATE_HIGHCONTRAST_CHANGED:
        code = _T("NM_SFTDATE_HIGHCONTRAST_CHANGED");
        data.Format(_T("active=%d"), SftDate_IsHighContrastActive(pNMHDR->hwndFrom));
        break;
    case NM_SFTDATE_DPI_CHANGED:
        code = _T("NM_SFTDATE_DPI_CHANGED");
        data.Format(_T("dpi=%d"), SftDate_GetDPI(pNMHDR->hwndFrom));
        break;
    case NM_SETFOCUS:
        code = _T("NM_SETFOCUS");
        break;
    case NM_KILLFOCUS:
        code = _T("NM_KILLFOCUS");
        break;

See Also C/C++ API | Categories | Notifications


Last Updated 11/26/2026 - (email)
© 2026 Softel vdm, Inc.