Skip to content

Commit 46af190

Browse files
committed
[Fixes] List column names centering in CViewRightBL.
Latest HexCtrl.
1 parent 3069914 commit 46af190

File tree

8 files changed

+94
-61
lines changed

8 files changed

+94
-61
lines changed

Pepper/ListEx/ListEx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ namespace LISTEX
8989
********************************************/
9090
struct LISTEXHDRICON
9191
{
92-
POINT pt { }; //Point of the top-left corner.
92+
POINT pt { }; //Coords of the icon's top-left corner in the header item's rect.
9393
int iIndex { }; //Icon index in the header's image list.
9494
bool fClickable { true }; //Is icon sending LISTEX_MSG_HDRICONCLICK message when clicked.
9595
};

Pepper/ListEx/src/CListEx.cpp

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,27 +123,35 @@ bool CListEx::Create(const LISTEXCREATESTRUCT& lcs)
123123
if (!m_stWndTtCell.CreateEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, TTS_BALLOON | TTS_NOANIMATE | TTS_NOFADE | TTS_NOPREFIX | TTS_ALWAYSTIP,
124124
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr))
125125
return false;
126-
127126
SetWindowTheme(m_stWndTtCell, nullptr, L""); //To prevent Windows from changing theme of Balloon window.
128-
129127
m_stTInfoCell.cbSize = TTTOOLINFOW_V1_SIZE;
130128
m_stTInfoCell.uFlags = TTF_TRACK;
131-
m_stTInfoCell.uId = 0x1;
129+
m_stTInfoCell.uId = 0x01;
132130
m_stWndTtCell.SendMessageW(TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&m_stTInfoCell));
133131
m_stWndTtCell.SendMessageW(TTM_SETMAXTIPWIDTH, 0, static_cast<LPARAM>(400)); //to allow use of newline \n.
134132
m_stWndTtCell.SendMessageW(TTM_SETTIPTEXTCOLOR, static_cast<WPARAM>(m_stColors.clrTooltipText), 0);
135133
m_stWndTtCell.SendMessageW(TTM_SETTIPBKCOLOR, static_cast<WPARAM>(m_stColors.clrTooltipBk), 0);
136134

137-
if (!m_stWndTtLink.CreateEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, TTS_NOANIMATE | TTS_NOFADE | TTS_NOPREFIX | TTS_ALWAYSTIP,
135+
if (!m_stWndTtLink.CreateEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, TTS_NOPREFIX | TTS_ALWAYSTIP,
138136
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr))
139137
return false;
140-
141138
m_stTInfoLink.cbSize = TTTOOLINFOW_V1_SIZE;
142139
m_stTInfoLink.uFlags = TTF_TRACK;
143-
m_stTInfoLink.uId = 0x2;
140+
m_stTInfoLink.uId = 0x02;
144141
m_stWndTtLink.SendMessageW(TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&m_stTInfoLink));
145142
m_stWndTtLink.SendMessageW(TTM_SETMAXTIPWIDTH, 0, static_cast<LPARAM>(400)); //to allow use of newline \n.
146143

144+
if (m_fHighLatency) //Tooltip for HighLatency mode.
145+
{
146+
if (!m_stWndTtRow.CreateEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, TTS_NOANIMATE | TTS_NOFADE | TTS_NOPREFIX | TTS_ALWAYSTIP,
147+
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, m_hWnd, nullptr))
148+
return false;
149+
m_stToolInfoRow.cbSize = TTTOOLINFOW_V1_SIZE;
150+
m_stToolInfoRow.uFlags = TTF_TRACK;
151+
m_stToolInfoRow.uId = 0x03;
152+
m_stWndTtRow.SendMessageW(TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&m_stToolInfoRow));
153+
}
154+
147155
m_dwGridWidth = lcs.dwListGridWidth;
148156

149157
LOGFONTW lf;
@@ -957,6 +965,22 @@ void CListEx::TtCellHide()
957965
KillTimer(ID_TIMER_TT_CELL_CHECK);
958966
}
959967

968+
void CListEx::TtRowShow(bool fShow, UINT uRow)
969+
{
970+
if (fShow)
971+
{
972+
CPoint ptScreen;
973+
GetCursorPos(&ptScreen);
974+
975+
static wchar_t warrOffset[32] { L"Row: " };
976+
swprintf_s(&warrOffset[5], 24, L"%u", uRow);
977+
m_stToolInfoRow.lpszText = warrOffset;
978+
m_stWndTtRow.SendMessageW(TTM_TRACKPOSITION, 0, static_cast<LPARAM>(MAKELONG(ptScreen.x - 5, ptScreen.y - 20)));
979+
m_stWndTtRow.SendMessageW(TTM_UPDATETIPTEXT, 0, reinterpret_cast<LPARAM>(&m_stToolInfoRow));
980+
}
981+
m_stWndTtRow.SendMessageW(TTM_TRACKACTIVATE, static_cast<WPARAM>(fShow), reinterpret_cast<LPARAM>(&m_stToolInfoRow));
982+
}
983+
960984
void CListEx::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
961985
{
962986
//Set row height according to current font's height.
@@ -1298,7 +1322,7 @@ void CListEx::OnPaint()
12981322
DefWindowProcW(WM_PAINT, reinterpret_cast<WPARAM>(rDC.m_hDC), static_cast<LPARAM>(0));
12991323
}
13001324

1301-
void CListEx::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar * pScrollBar)
1325+
void CListEx::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
13021326
{
13031327
if (m_fVirtual && m_fHighLatency)
13041328
{
@@ -1317,6 +1341,7 @@ void CListEx::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar * pScrollBar)
13171341
Scroll(size);
13181342
flag = false;
13191343
}
1344+
TtRowShow(false, 0);
13201345
CMFCListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
13211346
}
13221347
else
@@ -1327,6 +1352,7 @@ void CListEx::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar * pScrollBar)
13271352
si.fMask = SIF_ALL;
13281353
GetScrollInfo(SB_VERT, &si);
13291354
uItem = si.nTrackPos; //si.nTrackPos is in fact a row number.
1355+
TtRowShow(true, uItem);
13301356
}
13311357
}
13321358
else
@@ -1374,8 +1400,8 @@ BOOL CListEx::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult)
13741400
void CListEx::OnLvnColumnClick(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
13751401
{
13761402
/*******************************************************************************
1377-
* Just an empty handler.
1378-
* Without it all works fine, but assert triggers in Debug mode, when clicking
1403+
* Just an empty handler.
1404+
* Without it all works fine, but assert triggers in Debug mode, when clicking
13791405
* on header, if list is in Virtual mode (LVS_OWNERDATA).
13801406
* ASSERT((GetStyle() & LVS_OWNERDATA)==0)
13811407
*******************************************************************************/
@@ -1401,6 +1427,7 @@ void CListEx::OnDestroy()
14011427

14021428
m_stWndTtCell.DestroyWindow();
14031429
m_stWndTtLink.DestroyWindow();
1430+
m_stWndTtRow.DestroyWindow();
14041431
m_fontList.DeleteObject();
14051432
m_fontListUnderline.DeleteObject();
14061433
m_penGrid.DeleteObject();

Pepper/ListEx/src/CListEx.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ namespace LISTEX::INTERNAL
3434
[[nodiscard]] int GetSortColumn()const override;
3535
[[nodiscard]] bool GetSortAscending()const override;
3636
void HideColumn(int iIndex, bool fHide)override;
37-
int InsertColumn(int nCol, const LVCOLUMN* pColumn);
38-
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1);
37+
int InsertColumn(int nCol, const LVCOLUMN* pColumn)override;
38+
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1)override;
3939
[[nodiscard]] bool IsCreated()const override;
4040
[[nodiscard]] bool IsColumnSortable(int iColumn)override;
4141
void ResetSort()override; //Reset all the sort by any column to its default state.
@@ -66,6 +66,7 @@ namespace LISTEX::INTERNAL
6666
auto ParseItemText(int iItem, int iSubitem)->std::vector<SITEMDATA>;
6767
void TtLinkHide();
6868
void TtCellHide();
69+
void TtRowShow(bool fShow, UINT uRow); //Tooltips for HighLatency mode.
6970
void DrawItem(LPDRAWITEMSTRUCT pDIS)override;
7071
afx_msg void OnPaint();
7172
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
@@ -95,6 +96,8 @@ namespace LISTEX::INTERNAL
9596
TTTOOLINFOW m_stTInfoCell { }; //Cells' tool-tip info struct.
9697
CWnd m_stWndTtLink; //Link tool-tip window.
9798
TTTOOLINFOW m_stTInfoLink { }; //Link's tool-tip info struct.
99+
CWnd m_stWndTtRow { }; //Tooltip window for row in m_fHighLatency mode.
100+
TTTOOLINFOW m_stToolInfoRow { };//Tooltips struct.
98101
std::wstring m_wstrTtText { }; //Link's tool-tip current text.
99102
HCURSOR m_cursorHand { }; //Hand cursor handle.
100103
HCURSOR m_cursorDefault { }; //Standard (default) cursor handle.
@@ -105,6 +108,7 @@ namespace LISTEX::INTERNAL
105108
long m_lSizeFont { }; //Font size.
106109
PFNLVCOMPARE m_pfnCompare { nullptr }; //Pointer to user provided compare func.
107110
EListExSortMode m_enDefSortMode { EListExSortMode::SORT_LEX }; //Default sorting mode.
111+
CRect m_rcLinkCurr { }; //Current link's rect;
108112
std::unordered_map<int, std::unordered_map<int, LISTEXTOOLTIP>> m_umapCellTt { }; //Cell's tooltips.
109113
std::unordered_map<int, std::unordered_map<int, ULONGLONG>> m_umapCellData { }; //Cell's custom data.
110114
std::unordered_map<int, std::unordered_map<int, LISTEXCOLOR>> m_umapCellColor { }; //Cell's colors.
@@ -122,7 +126,6 @@ namespace LISTEX::INTERNAL
122126
bool m_fTtCellShown { false }; //Is cell's tool-tip shown atm.
123127
bool m_fTtLinkShown { false }; //Is link's tool-tip shown atm.
124128
bool m_fLDownAtLink { false }; //Left mouse down on link.
125-
CRect m_rcLinkCurr { }; //Current link's rect;
126129
};
127130

128131
/*******************Setting a manifest for ComCtl32.dll version 6.***********************/

Pepper/Pepper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ BOOL CAboutDlg::OnInitDialog()
2929
std::wstring wstrlibpeVer = L"libpe - PE/PE+ binaries library v";
3030
wstrlibpeVer += libpeInfo()->pwszVersion;
3131
GetDlgItem(IDC_LINK_LIBPE)->SetWindowTextW(wstrlibpeVer.data());
32-
wstrlibpeVer = L"HexCtrl - Hex Control for MFC/Win32 v";
32+
wstrlibpeVer = L"HexCtrl - ";
3333
wstrlibpeVer += GetHexCtrlInfo()->pwszVersion;
3434
GetDlgItem(IDC_LINK_HEXCTRL)->SetWindowTextW(wstrlibpeVer.data());
3535

Pepper/ViewRightBL.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,10 @@ int CViewRightBL::CreateListImportEntry(DWORD dwEntry)
474474
LVCOLUMNW stCol { LVCF_FMT, LVCFMT_CENTER };
475475
m_listImportEntry->SetColumn(0, &stCol);
476476
m_listImportEntry->SetHdrColumnColor(0, g_clrOffset);
477-
m_listImportEntry->InsertColumn(1, L"Function Name", 0, 175);
478-
m_listImportEntry->InsertColumn(2, L"Ordinal / Hint", 0, 100);
479-
m_listImportEntry->InsertColumn(3, L"AddressOfData", 0, 150);
480-
m_listImportEntry->InsertColumn(4, L"Thunk RVA", 0, 150);
477+
m_listImportEntry->InsertColumn(1, L"Function Name", LVCFMT_CENTER, 175);
478+
m_listImportEntry->InsertColumn(2, L"Ordinal / Hint", LVCFMT_CENTER, 100);
479+
m_listImportEntry->InsertColumn(3, L"AddressOfData", LVCFMT_CENTER, 150);
480+
m_listImportEntry->InsertColumn(4, L"Thunk RVA", LVCFMT_CENTER, 150);
481481
}
482482
else
483483
m_listImportEntry->DeleteAllItems();
@@ -585,12 +585,12 @@ int CViewRightBL::CreateListDelayImportEntry(DWORD dwEntry)
585585
LVCOLUMNW stCol { LVCF_FMT, LVCFMT_CENTER };
586586
m_listDelayImportEntry->SetColumn(0, &stCol);
587587
m_listDelayImportEntry->SetHdrColumnColor(0, g_clrOffset);
588-
m_listDelayImportEntry->InsertColumn(1, L"Function Name", 0, 300);
589-
m_listDelayImportEntry->InsertColumn(2, L"Ordinal / Hint", 0, 100);
588+
m_listDelayImportEntry->InsertColumn(1, L"Function Name", LVCFMT_CENTER, 300);
589+
m_listDelayImportEntry->InsertColumn(2, L"Ordinal / Hint", LVCFMT_CENTER, 100);
590590
m_listDelayImportEntry->InsertColumn(3, L"ImportNameTable AddresOfData", 0, 220);
591-
m_listDelayImportEntry->InsertColumn(4, L"IAT AddresOfData", 0, 200);
592-
m_listDelayImportEntry->InsertColumn(5, L"BoundIAT AddresOfData", 0, 230);
593-
m_listDelayImportEntry->InsertColumn(6, L"UnloadInfoTable AddresOfData", 0, 240);
591+
m_listDelayImportEntry->InsertColumn(4, L"IAT AddresOfData", LVCFMT_CENTER, 200);
592+
m_listDelayImportEntry->InsertColumn(5, L"BoundIAT AddresOfData", LVCFMT_CENTER, 230);
593+
m_listDelayImportEntry->InsertColumn(6, L"UnloadInfoTable AddresOfData", LVCFMT_CENTER, 240);
594594
}
595595
else
596596
m_listDelayImportEntry->DeleteAllItems();

Pepper/include/HexCtrl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ namespace HEXCTRL
6363
[[nodiscard]] virtual auto GetDataSize()const->ULONGLONG = 0; //Get currently set data size.
6464
[[nodiscard]] virtual int GetEncoding()const = 0; //Get current code page ID.
6565
[[nodiscard]] virtual long GetFontSize()const = 0; //Current font size.
66-
[[nodiscard]] virtual auto GetGroupMode()const->EHexGroupMode = 0; //Retrieves current data grouping mode.
66+
[[nodiscard]] virtual auto GetGroupMode()const->EHexDataSize = 0; //Retrieves current data grouping mode.
6767
[[nodiscard]] virtual HMENU GetMenuHandle()const = 0; //Context menu handle.
6868
[[nodiscard]] virtual auto GetPagesCount()const->ULONGLONG = 0; //Get count of pages.
6969
[[nodiscard]] virtual auto GetPagePos()const->ULONGLONG = 0; //Get current page a cursor stays at.
7070
[[nodiscard]] virtual DWORD GetPageSize()const = 0; //Current page size.
71-
[[nodiscard]] virtual auto GetSelection()const->std::vector<HEXSPANSTRUCT> = 0; //Gets current selection.
71+
[[nodiscard]] virtual auto GetSelection()const->std::vector<HEXSPANSTRUCT> = 0; //Get current selection.
7272
[[nodiscard]] virtual HWND GetWindowHandle(EHexWnd enWnd)const = 0; //Retrieves control's window/dialog handle.
7373
virtual void GoToOffset(ULONGLONG ullOffset, int iRelPos = 0) = 0; //Go (scroll) to a given offset.
74+
[[nodiscard]] virtual bool HasSelection()const = 0; //Does currently have any selection or not.
7475
[[nodiscard]] virtual auto HitTest(POINT pt, bool fScreen = true)const->std::optional<HEXHITTESTSTRUCT> = 0; //HitTest given point.
7576
[[nodiscard]] virtual bool IsCmdAvail(EHexCmd enCmd)const = 0; //Is given Cmd currently available (can be executed)?
7677
[[nodiscard]] virtual bool IsCreated()const = 0; //Shows whether control is created or not.
@@ -88,7 +89,7 @@ namespace HEXCTRL
8889
virtual void SetEncoding(int iCodePage) = 0; //Code-page for text area.
8990
virtual void SetFont(const LOGFONTW* pLogFont) = 0; //Set the control's new font. This font has to be monospaced.
9091
virtual void SetFontSize(UINT uiSize) = 0; //Set the control's font size.
91-
virtual void SetGroupMode(EHexGroupMode enMode) = 0; //Set current "Group Data By" mode.
92+
virtual void SetGroupMode(EHexDataSize enMode) = 0; //Set current "Group Data By" mode.
9293
virtual void SetMutable(bool fEnable) = 0; //Enable or disable mutable/editable mode.
9394
virtual void SetOffsetMode(bool fHex) = 0; //Set offset being shown as Hex or as Decimal.
9495
virtual void SetPageSize(DWORD dwSize, std::wstring_view wstrName = L"Page") = 0; //Set page size and name to draw the lines in-between.

0 commit comments

Comments
 (0)