OSDN Git Service

Make listviews DPI-aware
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 26 Jun 2016 02:31:26 +0000 (11:31 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 26 Jun 2016 02:31:26 +0000 (11:31 +0900)
Src/DirColsDlg.cpp
Src/FileFiltersDlg.cpp
Src/LineFiltersDlg.cpp
Src/PluginsListDlg.cpp

index 174401d..ef16266 100644 (file)
@@ -56,10 +56,13 @@ END_MESSAGE_MAP()
  */
 void CDirColsDlg::InitList()
 {
+       const int lpx = CClientDC(this).GetDeviceCaps(LOGPIXELSX);
+       auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
+
        // Show selection across entire row.
        // Also enable infotips.
        m_listColumns.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
-       m_listColumns.InsertColumn(0, _T(""), LVCFMT_LEFT, 150);
+       m_listColumns.InsertColumn(0, _T(""), LVCFMT_LEFT, pointToPixel(112));
 }
 
 /**
index 8685a5b..a0599f2 100644 (file)
@@ -128,12 +128,15 @@ void FileFiltersDlg::InitList()
        // Also enable infotips.
        m_listFilters.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
 
+       const int lpx = CClientDC(this).GetDeviceCaps(LOGPIXELSX);
+       auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
+
        String title = _("Name");
-       m_listFilters.InsertColumn(0, title.c_str(), LVCFMT_LEFT, 150);
+       m_listFilters.InsertColumn(0, title.c_str(), LVCFMT_LEFT, pointToPixel(112));
        title = _("Description");
-       m_listFilters.InsertColumn(1, title.c_str(), LVCFMT_LEFT, 350);
+       m_listFilters.InsertColumn(1, title.c_str(), LVCFMT_LEFT, pointToPixel(262));
        title = _("Location");
-       m_listFilters.InsertColumn(2, title.c_str(), LVCFMT_LEFT, 350);
+       m_listFilters.InsertColumn(2, title.c_str(), LVCFMT_LEFT, pointToPixel(262));
 
        title = _("<None>");
        m_listFilters.InsertItem(1, title.c_str());
index 3156fc8..a4c913c 100644 (file)
@@ -87,8 +87,11 @@ void LineFiltersDlg::InitList()
        // Also enable infotips.
        m_filtersList.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
 
+       const int lpx = CClientDC(this).GetDeviceCaps(LOGPIXELSX);
+       auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
+
        String title = _("Regular expression");
-       m_filtersList.InsertColumn(1, title.c_str(), LVCFMT_LEFT, 500);
+       m_filtersList.InsertColumn(1, title.c_str(), LVCFMT_LEFT, pointToPixel(375));
 
        size_t count = m_pList->GetCount();
        for (size_t i = 0; i < count; i++)
index 933d7df..1789b16 100644 (file)
@@ -67,12 +67,15 @@ void PluginsListDlg::InitList()
        // Also enable infotips.
        m_list.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
 
+       const int lpx = CClientDC(this).GetDeviceCaps(LOGPIXELSX);
+       auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
+
        String title = _("Name");
-       m_list.InsertColumn(0, title.c_str(), LVCFMT_LEFT, 200);
+       m_list.InsertColumn(0, title.c_str(), LVCFMT_LEFT, pointToPixel(150));
        title = _("Type");
-       m_list.InsertColumn(1, title.c_str(), LVCFMT_LEFT, 100);
+       m_list.InsertColumn(1, title.c_str(), LVCFMT_LEFT, pointToPixel(75));
        title = _("Description");
-       m_list.InsertColumn(2, title.c_str(), LVCFMT_LEFT, 300);
+       m_list.InsertColumn(2, title.c_str(), LVCFMT_LEFT, pointToPixel(225));
 }
 
 /**