Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
show number of colors in group icons
Browse files Browse the repository at this point in the history
  • Loading branch information
zodiacon committed May 12, 2022
1 parent d335f8e commit 0d209a7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
22 changes: 15 additions & 7 deletions TotalPE/IconGroupView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ void CIconGroupView::SetGroupIconData(std::vector<uint8_t> const& data) {
icon.CreateIconFromResourceEx(const_cast<PBYTE>(idata.data()),
(DWORD)idata.size(), 0x30000, width, width, LR_DEFAULTCOLOR);
if (icon) {
m_Icons.emplace_back(icon, width);
IconData id;
id.Icon = icon;
id.Size = width;
id.Id = entry.Id;
id.Colors = entry.bColorCount ? entry.bColorCount : (entry.wBitCount * entry.wPlanes);
m_Icons.emplace_back(std::move(id));
y += width + 12;
}
}
Expand All @@ -67,8 +72,8 @@ LRESULT CIconGroupView::OnCreate(UINT, WPARAM, LPARAM, BOOL& handled) {
LRESULT CIconGroupView::OnDestroy(UINT, WPARAM, LPARAM, BOOL&) {
if(m_Icon)
m_Icon.DestroyIcon();
for (auto& [icon, _] : m_Icons)
icon.DestroyIcon();
for (auto& icon : m_Icons)
icon.Icon.DestroyIcon();

return 0;
}
Expand All @@ -90,10 +95,13 @@ void CIconGroupView::DoPaint(CDCHandle dc) {
}
else {
int y = 10;
for (auto& [icon, size] : m_Icons) {
CRect rc(10, y, 90, y + size);
dc.DrawText(std::format(L"{} X {}", size, size).c_str(), -1, &rc, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
icon.DrawIconEx(dc, 100, y, size, size, 0, nullptr, DI_NORMAL);
for (auto& icon : m_Icons) {
auto size = icon.Size;
CRect rc(10, y, 160, y + size);
auto text = std::format(L"{} X {} ({} bit)", size, size, icon.Colors);
dc.DrawText(text.c_str(),
-1, &rc, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
icon.Icon.DrawIconEx(dc, 180, y, size, size, 0, nullptr, DI_NORMAL);
y += size + 12;
}
}
Expand Down
8 changes: 7 additions & 1 deletion TotalPE/IconGroupView.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ class CIconGroupView :
END_MSG_MAP()

private:
struct IconData {
CIconHandle Icon;
int Size;
UINT Id;
UINT Colors;
};
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);

CIconHandle m_Icon;
int m_IconSize;
std::vector<std::pair<CIconHandle, int>> m_Icons;
std::vector<IconData> m_Icons;
};

0 comments on commit 0d209a7

Please sign in to comment.