Skip to content

Commit

Permalink
SetDlgData->SetDlgProperties.
Browse files Browse the repository at this point in the history
std::iswprint added. Unprintable chars, in the WM_CHAR handler, now don't get printed when in the text area (e.g. VK_ESCAPE, VK_TAB).
  • Loading branch information
jovibor committed Mar 12, 2024
1 parent 36d1d82 commit dfd295b
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 77 deletions.
10 changes: 5 additions & 5 deletions HexCtrl/HexCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ namespace HEXCTRL {
virtual bool SetConfig(std::wstring_view wsvPath) = 0; //Set configuration file, or "" for defaults.
virtual void SetData(const HEXDATA& hds) = 0; //Main method for setting data to display (and edit).
virtual void SetDateInfo(DWORD dwFormat, wchar_t wchSepar) = 0; //Set date format and date separator.
virtual void SetDlgData(EHexWnd eWnd, std::uint64_t u64Data) = 0; //Data for the internal dialogs.
virtual void SetDlgProperties(EHexWnd eWnd, std::uint64_t u64Flags) = 0; //Properties for the internal dialogs.
virtual void SetFont(const LOGFONTW& lf) = 0; //Set the control's new font. This font has to be monospaced.
virtual void SetGroupSize(DWORD dwSize) = 0; //Set data grouping size.
virtual void SetMutable(bool fEnable) = 0; //Enable or disable mutable/editable mode.
Expand Down Expand Up @@ -487,11 +487,11 @@ namespace HEXCTRL {
constexpr auto HEXCTRL_MSG_SETSELECTION { 0x0111U }; //Selection has been made.


/********************************************************************
* Flags for the internal dialogs, used with the SetDlgData method. *
********************************************************************/
/**************************************************************************
* Flags for the internal dialogs, used with the SetDlgProperties method. *
**************************************************************************/

constexpr auto HEXCTRL_FLAG_NOESC { 0x01ULL };
constexpr auto HEXCTRL_FLAG_DLG_NOESC { 0x01ULL };

//Setting a manifest for the ComCtl32.dll version 6.
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
Expand Down
20 changes: 11 additions & 9 deletions HexCtrl/src/CHexCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,7 @@ void CHexCtrl::SetDateInfo(DWORD dwFormat, wchar_t wchSepar)
m_wchDateSepar = wchSepar;
}

void CHexCtrl::SetDlgData(EHexWnd eWnd, std::uint64_t u64Data)
void CHexCtrl::SetDlgProperties(EHexWnd eWnd, std::uint64_t u64Flags)
{
assert(IsCreated());
if (!IsCreated())
Expand All @@ -2758,19 +2758,19 @@ void CHexCtrl::SetDlgData(EHexWnd eWnd, std::uint64_t u64Data)
using enum EHexWnd;
switch (eWnd) {
case DLG_BKMMGR:
m_pDlgBkmMgr->SetDlgData(u64Data);
m_pDlgBkmMgr->SetDlgProperties(u64Flags);
case DLG_DATAINTERP:
m_pDlgDataInterp->SetDlgData(u64Data);
m_pDlgDataInterp->SetDlgProperties(u64Flags);
case DLG_MODIFY:
m_pDlgModify->SetDlgData(u64Data);
m_pDlgModify->SetDlgProperties(u64Flags);
case DLG_SEARCH:
m_pDlgSearch->SetDlgData(u64Data);
m_pDlgSearch->SetDlgProperties(u64Flags);
case DLG_CODEPAGE:
m_pDlgCodepage->SetDlgData(u64Data);
m_pDlgCodepage->SetDlgProperties(u64Flags);
case DLG_GOTO:
m_pDlgGoTo->SetDlgData(u64Data);
m_pDlgGoTo->SetDlgProperties(u64Flags);
case DLG_TEMPLMGR:
m_pDlgTemplMgr->SetDlgData(u64Data);
m_pDlgTemplMgr->SetDlgProperties(u64Flags);
default:
break;
}
Expand Down Expand Up @@ -5604,10 +5604,12 @@ void CHexCtrl::Undo()

void CHexCtrl::OnChar(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/)
{
if (!IsDataSet() || !IsMutable() || !IsCurTextArea() || (GetKeyState(VK_CONTROL) < 0))
if (!IsDataSet() || !IsMutable() || !IsCurTextArea() || (GetKeyState(VK_CONTROL) < 0)
|| !std::iswprint(static_cast<wint_t>(nChar)))
return;

unsigned char chByte = nChar & 0xFF;

wchar_t warrCurrLocaleID[KL_NAMELENGTH];
GetKeyboardLayoutNameW(warrCurrLocaleID); //Current langID as wstring.
if (const auto optLocID = stn::StrToUInt32(warrCurrLocaleID, 16); optLocID) { //Convert langID from wstr to number.
Expand Down
2 changes: 1 addition & 1 deletion HexCtrl/src/CHexCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace HEXCTRL::INTERNAL {
bool SetConfig(std::wstring_view wsvPath)override;
void SetData(const HEXDATA& hds)override;
void SetDateInfo(DWORD dwFormat, wchar_t wchSepar)override;
void SetDlgData(EHexWnd eWnd, std::uint64_t u64Data)override;
void SetDlgProperties(EHexWnd eWnd, std::uint64_t u64Data)override;
void SetFont(const LOGFONTW& lf)override;
void SetGroupSize(DWORD dwSize)override;
void SetMutable(bool fEnable)override;
Expand Down
8 changes: 4 additions & 4 deletions HexCtrl/src/Dialogs/CHexDlgBkmMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ void CHexDlgBkmMgr::RemoveByID(ULONGLONG ullID)
}
}

void CHexDlgBkmMgr::SetDlgData(std::uint64_t ullData)
void CHexDlgBkmMgr::SetDlgProperties(std::uint64_t u64Flags)
{
m_u64DlgData = ullData;
m_u64Flags = u64Flags;
}

void CHexDlgBkmMgr::SetVirtual(IHexBookmarks* pVirtBkm)
Expand Down Expand Up @@ -350,7 +350,7 @@ void CHexDlgBkmMgr::DoDataExchange(CDataExchange* pDX)

bool CHexDlgBkmMgr::IsNoEsc()const
{
return m_u64DlgData & HEXCTRL_FLAG_NOESC;
return m_u64Flags & HEXCTRL_FLAG_DLG_NOESC;
}

bool CHexDlgBkmMgr::IsShowAsHex()const
Expand Down Expand Up @@ -419,7 +419,7 @@ void CHexDlgBkmMgr::OnDestroy()

RemoveAll();
m_menuList.DestroyMenu();
m_u64DlgData = { };
m_u64Flags = { };
}

void CHexDlgBkmMgr::OnOK()
Expand Down
4 changes: 2 additions & 2 deletions HexCtrl/src/Dialogs/CHexDlgBkmMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace HEXCTRL::INTERNAL {
void RemoveAll()override;
void RemoveByOffset(ULONGLONG ullOffset);
void RemoveByID(ULONGLONG ullID)override;
void SetDlgData(std::uint64_t ullData);
void SetDlgProperties(std::uint64_t u64Flags);
void SetVirtual(IHexBookmarks* pVirtBkm);
BOOL ShowWindow(int nCmdShow);
void SortData(int iColumn, bool fAscending);
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace HEXCTRL::INTERNAL {
IHexBookmarks* m_pVirtual { };
LISTEX::IListExPtr m_pList { LISTEX::CreateListEx() };
LONGLONG m_llIndexCurr { }; //Current bookmark's position index, to move next/prev.
std::uint64_t m_u64DlgData { }; //Data from SetDlgData.
std::uint64_t m_u64Flags { }; //Data from SetDlgProperties.
CMenu m_menuList;
CButton m_btnHex; //Check-box "Hex numbers".
};
Expand Down
8 changes: 4 additions & 4 deletions HexCtrl/src/Dialogs/CHexDlgCodepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ void CHexDlgCodepage::Initialize(IHexCtrl* pHexCtrl)
m_pHexCtrl = pHexCtrl;
}

void CHexDlgCodepage::SetDlgData(std::uint64_t ullData)
void CHexDlgCodepage::SetDlgProperties(std::uint64_t u64Flags)
{
m_u64DlgData = ullData;
m_u64Flags = u64Flags;
}

BOOL CHexDlgCodepage::ShowWindow(int nCmdShow)
Expand All @@ -68,7 +68,7 @@ void CHexDlgCodepage::DoDataExchange(CDataExchange* pDX)

bool CHexDlgCodepage::IsNoEsc()const
{
return m_u64DlgData & HEXCTRL_FLAG_NOESC;
return m_u64Flags & HEXCTRL_FLAG_DLG_NOESC;
}

void CHexDlgCodepage::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
Expand Down Expand Up @@ -103,7 +103,7 @@ void CHexDlgCodepage::OnDestroy()
CDialogEx::OnDestroy();

m_vecCodePage.clear();
m_u64DlgData = { };
m_u64Flags = { };
m_pHexCtrl = nullptr;
}

Expand Down
4 changes: 2 additions & 2 deletions HexCtrl/src/Dialogs/CHexDlgCodepage.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace HEXCTRL::INTERNAL {
public:
void AddCP(std::wstring_view wsv);
void Initialize(IHexCtrl* pHexCtrl);
void SetDlgData(std::uint64_t ullData);
void SetDlgProperties(std::uint64_t u64Flags);
BOOL ShowWindow(int nCmdShow);
private:
void DoDataExchange(CDataExchange* pDX)override;
Expand Down Expand Up @@ -42,6 +42,6 @@ namespace HEXCTRL::INTERNAL {
IHexCtrl* m_pHexCtrl { };
LISTEX::IListExPtr m_pListMain { LISTEX::CreateListEx() };
std::vector<CODEPAGE> m_vecCodePage { };
std::uint64_t m_u64DlgData { }; //Data from SetDlgData.
std::uint64_t m_u64Flags { }; //Data from SetDlgProperties.
};
}
8 changes: 4 additions & 4 deletions HexCtrl/src/Dialogs/CHexDlgDataInterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ bool CHexDlgDataInterp::HasHighlight()const
return m_dwHglDataSize > 0;
}

void CHexDlgDataInterp::SetDlgData(std::uint64_t ullData)
void CHexDlgDataInterp::SetDlgProperties(std::uint64_t u64Flags)
{
m_u64DlgData = ullData;
m_u64Flags = u64Flags;
}

BOOL CHexDlgDataInterp::ShowWindow(int nCmdShow)
Expand Down Expand Up @@ -314,7 +314,7 @@ bool CHexDlgDataInterp::IsBigEndian()const

bool CHexDlgDataInterp::IsNoEsc()const
{
return m_u64DlgData & HEXCTRL_FLAG_NOESC;
return m_u64Flags & HEXCTRL_FLAG_DLG_NOESC;
}

bool CHexDlgDataInterp::IsShowAsHex()const
Expand Down Expand Up @@ -374,7 +374,7 @@ void CHexDlgDataInterp::OnDestroy()
CDialogEx::OnDestroy();

m_vecGrid.clear();
m_u64DlgData = { };
m_u64Flags = { };
m_pHexCtrl = nullptr;
}

Expand Down
4 changes: 2 additions & 2 deletions HexCtrl/src/Dialogs/CHexDlgDataInterp.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace HEXCTRL::INTERNAL {
[[nodiscard]] auto GetHglDataSize()const->DWORD;
void Initialize(IHexCtrl* pHexCtrl);
[[nodiscard]] bool HasHighlight()const;
void SetDlgData(std::uint64_t ullData);
void SetDlgProperties(std::uint64_t u64Flags);
BOOL ShowWindow(int nCmdShow);
void UpdateData();
private:
Expand Down Expand Up @@ -107,7 +107,7 @@ namespace HEXCTRL::INTERNAL {
ULONGLONG m_ullOffset { };
DWORD m_dwHglDataSize { }; //Size of the data to highlight in the HexCtrl.
DWORD m_dwDateFormat { }; //Date format.
std::uint64_t m_u64DlgData { }; //Data from SetDlgData.
std::uint64_t m_u64Flags { }; //Data from SetDlgProperties.
wchar_t m_wchDateSepar { }; //Date separator.
};
}
8 changes: 4 additions & 4 deletions HexCtrl/src/Dialogs/CHexDlgGoTo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ void CHexDlgGoTo::Repeat(bool fFwd)
GoTo(fFwd);
}

void CHexDlgGoTo::SetDlgData(std::uint64_t ullData)
void CHexDlgGoTo::SetDlgProperties(std::uint64_t u64Flags)
{
m_u64DlgData = ullData;
m_u64Flags = u64Flags;
}

BOOL CHexDlgGoTo::ShowWindow(int nCmdShow)
Expand Down Expand Up @@ -159,7 +159,7 @@ void CHexDlgGoTo::GoTo(bool fForward)

bool CHexDlgGoTo::IsNoEsc()const
{
return m_u64DlgData & HEXCTRL_FLAG_NOESC;
return m_u64Flags & HEXCTRL_FLAG_DLG_NOESC;
}

void CHexDlgGoTo::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
Expand Down Expand Up @@ -191,7 +191,7 @@ void CHexDlgGoTo::OnClose()
void CHexDlgGoTo::OnDestroy()
{
CDialogEx::OnDestroy();
m_u64DlgData = { };
m_u64Flags = { };
m_pHexCtrl = nullptr;
m_fRepeat = false;
}
Expand Down
4 changes: 2 additions & 2 deletions HexCtrl/src/Dialogs/CHexDlgGoTo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace HEXCTRL::INTERNAL {
void Initialize(IHexCtrl* pHexCtrl);
[[nodiscard]] bool IsRepeatAvail()const;
void Repeat(bool fFwd = true); //fFwd: true - forward, false - backward.
void SetDlgData(std::uint64_t ullData);
void SetDlgProperties(std::uint64_t u64Flags);
BOOL ShowWindow(int nCmdShow);
private:
enum class EGoMode : std::uint8_t;
Expand All @@ -33,7 +33,7 @@ namespace HEXCTRL::INTERNAL {
DECLARE_MESSAGE_MAP();
private:
IHexCtrl* m_pHexCtrl { };
std::uint64_t m_u64DlgData { }; //Data from SetDlgData.
std::uint64_t m_u64Flags { }; //Data from SetDlgProperties.
CComboBox m_comboMode;
bool m_fRepeat { false }; //Is repeat available.
};
Expand Down
Loading

0 comments on commit dfd295b

Please sign in to comment.