55* This software is available under "The HexCtrl License", see the LICENSE file. *
66****************************************************************************************/
77#pragma once
8- #include < afxwin .h>
8+ #include < Windows .h>
99#include < compare>
1010#include < cstdint>
1111#include < memory>
1919#error "C++20 compliant compiler is required to build HexCtrl."
2020#endif
2121
22- #ifdef HEXCTRL_SHARED_DLL
23- #ifdef HEXCTRL_EXPORT
22+ #ifdef HEXCTRL_DYNAMIC_LIB
23+ #ifdef HEXCTRL_DYNAMIC_LIB_EXPORT
2424#define HEXCTRLAPI __declspec (dllexport)
25- #else // ^^^ HEXCTRL_EXPORT / vvv !HEXCTRL_EXPORT
25+ #else // ^^^ HEXCTRL_DYNAMIC_LIB_EXPORT / vvv !HEXCTRL_DYNAMIC_LIB_EXPORT
2626#define HEXCTRLAPI __declspec (dllimport)
27- #ifdef _WIN64
27+
28+ #ifdef _M_IX86
29+ #ifdef _DEBUG
30+ #define HEXCTRL_LIBNAME (x ) x" x86D.lib"
31+ #else // ^^^ _DEBUG / vvv !_DEBUG
32+ #define HEXCTRL_LIBNAME (x ) x" x86.lib"
33+ #endif // ^^^ !_DEBUG
34+ #elif defined(_M_X64) // ^^^ _M_IX86 / vvv _M_X64
2835#ifdef _DEBUG
29- #define HEXCTRL_LIBNAME (x ) x" 64d .lib"
36+ #define HEXCTRL_LIBNAME (x ) x" x64D .lib"
3037#else // ^^^ _DEBUG / vvv !_DEBUG
31- #define HEXCTRL_LIBNAME (x ) x" 64 .lib"
32- #endif // _DEBUG
33- #else // ^^^ _WIN64 / vvv !_WIN64
38+ #define HEXCTRL_LIBNAME (x ) x" x64 .lib"
39+ #endif // ^^^ ! _DEBUG
40+ #elif defined(_M_ARM64) // ^^^ _M_X64 / vvv _M_ARM64
3441#ifdef _DEBUG
35- #define HEXCTRL_LIBNAME (x ) x" d .lib"
42+ #define HEXCTRL_LIBNAME (x ) x" ARM64D .lib"
3643#else // ^^^ _DEBUG / vvv !_DEBUG
37- #define HEXCTRL_LIBNAME (x ) x" .lib"
38- #endif // _DEBUG
39- #endif // _WIN64
44+ #define HEXCTRL_LIBNAME (x ) x" ARM64.lib"
45+ #endif // ^^^ _DEBUG
46+ #endif // ^^^ _M_ARM64
47+
4048#pragma comment(lib, HEXCTRL_LIBNAME("HexCtrl"))
41- #endif // HEXCTRL_EXPORT
42- #else // ^^^ HEXCTRL_SHARED_DLL / vvv !HEXCTRL_SHARED_DLL
49+ #endif // ^^^ !HEXCTRL_DYNAMIC_LIB_EXPORT
50+ #else // ^^^ HEXCTRL_DYNAMIC_LIB / vvv !HEXCTRL_DYNAMIC_LIB
4351#define HEXCTRLAPI
44- #endif // HEXCTRL_SHARED_DLL
52+ #endif // ^^^ !HEXCTRL_DYNAMIC_LIB
4553
4654namespace HEXCTRL {
4755 constexpr auto HEXCTRL_VERSION_MAJOR = 3 ;
48- constexpr auto HEXCTRL_VERSION_MINOR = 6 ;
49- constexpr auto HEXCTRL_VERSION_PATCH = 1 ;
56+ constexpr auto HEXCTRL_VERSION_MINOR = 7 ;
57+ constexpr auto HEXCTRL_VERSION_PATCH = 2 ;
5058
5159 using SpanByte = std::span<std::byte>;
5260 using SpanCByte = std::span<const std::byte>;
@@ -64,7 +72,7 @@ namespace HEXCTRL {
6472 CMD_CLPBRD_COPY_BASE64, CMD_CLPBRD_COPY_CARR, CMD_CLPBRD_COPY_GREPHEX, CMD_CLPBRD_COPY_PRNTSCRN,
6573 CMD_CLPBRD_COPY_OFFSET, CMD_CLPBRD_PASTE_HEX, CMD_CLPBRD_PASTE_TEXTUTF16, CMD_CLPBRD_PASTE_TEXTCP,
6674 CMD_MODIFY_OPERS_DLG, CMD_MODIFY_FILLZEROS, CMD_MODIFY_FILLDATA_DLG, CMD_MODIFY_UNDO, CMD_MODIFY_REDO,
67- CMD_SEL_MARKSTART, CMD_SEL_MARKEND , CMD_SEL_ALL, CMD_SEL_ADDLEFT, CMD_SEL_ADDRIGHT, CMD_SEL_ADDUP,
75+ CMD_SEL_MARKSTARTEND , CMD_SEL_ALL, CMD_SEL_ADDLEFT, CMD_SEL_ADDRIGHT, CMD_SEL_ADDUP,
6876 CMD_SEL_ADDDOWN, CMD_DATAINTERP_DLG, CMD_CODEPAGE_DLG, CMD_APPEAR_FONT_DLG, CMD_APPEAR_FONTINC,
6977 CMD_APPEAR_FONTDEC, CMD_APPEAR_CAPACINC, CMD_APPEAR_CAPACDEC, CMD_PRINT_DLG, CMD_ABOUT_DLG,
7078 CMD_CARET_LEFT, CMD_CARET_RIGHT, CMD_CARET_UP, CMD_CARET_DOWN,
@@ -273,16 +281,22 @@ namespace HEXCTRL {
273281 COLORREF clrBkSel { GetSysColor (COLOR_HIGHLIGHT) }; // Background color of the selected Hex/Text.
274282 COLORREF clrBkBkm { RGB (240 , 240 , 0 ) }; // Bookmarks background color.
275283 COLORREF clrBkDataInterp { RGB (147 , 58 , 22 ) }; // Data Interpreter Bk color.
276- COLORREF clrBkInfoBar { GetSysColor (COLOR_BTNFACE ) }; // Background color of the bottom Info bar.
284+ COLORREF clrBkInfoBar { GetSysColor (COLOR_3DFACE ) }; // Background color of the bottom Info bar.
277285 COLORREF clrBkCaret { RGB (0 , 0 , 255 ) }; // Caret background color.
278286 COLORREF clrBkCaretSel { RGB (0 , 0 , 200 ) }; // Caret background color in selection.
287+ COLORREF clrLinesMain { RGB (200 , 200 , 200 ) }; // Main window and pages lines color.
288+ COLORREF clrLinesTempl { RGB (75 , 75 , 75 ) }; // Templates data confining lines color.
289+ COLORREF clrScrollBar { RGB (241 , 241 , 241 ) }; // Scrollbar color.
290+ COLORREF clrScrollThumb { RGB (200 , 200 , 200 ) }; // Scrollbar thumb color.
291+ COLORREF clrScrollArrow { RGB (110 , 110 , 110 ) }; // Scrollbar arrow color.
279292 };
280293 using PCHEXCOLORS = const HEXCOLORS*;
281294
282295 /* *******************************************************************************************
283296 * HEXCREATE: Main struct for the HexCtrl creation. *
284297 ********************************************************************************************/
285298 struct HEXCREATE {
299+ HINSTANCE hInstRes { }; // Hinstance of the HexCtrl resources, nullptr for current module.
286300 HWND hWndParent { }; // Parent window handle.
287301 PCHEXCOLORS pColors { }; // HexCtrl colors, nullptr for default.
288302 const LOGFONTW* pLogFont { }; // Monospaced font for HexCtrl, nullptr for default.
@@ -394,7 +408,8 @@ namespace HEXCTRL {
394408 virtual void ClearData () = 0; // Clears all data from HexCtrl's view (not touching data itself).
395409 virtual bool Create (const HEXCREATE& hcs) = 0; // Main initialization method.
396410 virtual bool CreateDialogCtrl (UINT uCtrlID, HWND hWndParent) = 0; // Сreates custom dialog control.
397- virtual void Destroy () = 0; // Deleter.
411+ virtual void Delete () = 0; // IHexCtrl object deleter.
412+ virtual void DestroyWindow () = 0; // Destroy HexCtrl window.
398413 virtual void ExecuteCmd (EHexCmd eCmd) = 0; // Execute a command within HexCtrl.
399414 [[nodiscard]] virtual auto GetActualWidth ()const ->int = 0; // Working area actual width.
400415 [[nodiscard]] virtual auto GetBookmarks ()const ->IHexBookmarks* = 0; // Get Bookmarks interface.
@@ -407,8 +422,8 @@ namespace HEXCTRL {
407422 [[nodiscard]] virtual auto GetData (HEXSPAN hss)const ->SpanByte = 0; // Get pointer to data offset, no matter what mode HexCtrl works in.
408423 [[nodiscard]] virtual auto GetDataSize ()const ->ULONGLONG = 0; // Get currently set data size.
409424 [[nodiscard]] virtual auto GetDateInfo ()const ->std::tuple<DWORD, wchar_t> = 0; // Get date format and separator info.
410- [[nodiscard]] virtual auto GetDlgItemHandle (EHexWnd eWnd, EHexDlgItem eItem)const ->HWND = 0; // Dialogs' items.
411- [[nodiscard]] virtual auto GetFont ()const ->LOGFONTW = 0; // Get current font.
425+ [[nodiscard]] virtual auto GetDlgItemHandle (EHexDlgItem eItem)const ->HWND = 0; // Dialogs' items.
426+ [[nodiscard]] virtual auto GetFont (bool fMain = true )const ->LOGFONTW = 0; // Get current main/infobar font.
412427 [[nodiscard]] virtual auto GetGroupSize ()const ->DWORD = 0; // Retrieves current data grouping size.
413428 [[nodiscard]] virtual auto GetMenuHandle ()const ->HMENU = 0; // Context menu handle.
414429 [[nodiscard]] virtual auto GetOffset (ULONGLONG ullOffset, bool fGetVirt )const ->ULONGLONG = 0; // Offset<->VirtOffset conversion.
@@ -421,50 +436,45 @@ namespace HEXCTRL {
421436 [[nodiscard]] virtual auto GetUnprintableChar ()const ->wchar_t = 0; // Get unprintable replacement character.
422437 [[nodiscard]] virtual auto GetWndHandle (EHexWnd eWnd, bool fCreate = true )const ->HWND = 0; // Get HWND of internal window/dialogs.
423438 virtual void GoToOffset (ULONGLONG ullOffset, int iPosAt = 0 ) = 0; // Go to the given offset.
439+ [[nodiscard]] virtual bool HasInfoBar ()const = 0; // Is InfoBar currently visible?
424440 [[nodiscard]] virtual bool HasSelection ()const = 0; // Does currently have any selection or not.
425441 [[nodiscard]] virtual auto HitTest (POINT pt, bool fScreen = true )const ->std::optional<HEXHITTEST> = 0; // HitTest given point.
426442 [[nodiscard]] virtual bool IsCmdAvail (EHexCmd eCmd)const = 0; // Is given Cmd currently available (can be executed)?
427443 [[nodiscard]] virtual bool IsCreated ()const = 0; // Shows whether HexCtrl is created or not.
428444 [[nodiscard]] virtual bool IsDataSet ()const = 0; // Shows whether a data was set to HexCtrl or not.
429- [[nodiscard]] virtual bool IsInfoBar ()const = 0; // Is InfoBar visible?
430445 [[nodiscard]] virtual bool IsMutable ()const = 0; // Is data mutable or not.
431446 [[nodiscard]] virtual bool IsOffsetAsHex ()const = 0; // Are offsets shown as Hex or as Decimal.
432447 [[nodiscard]] virtual auto IsOffsetVisible (ULONGLONG ullOffset)const ->HEXVISION = 0; // Ensures that the given offset is visible.
433448 [[nodiscard]] virtual bool IsVirtual ()const = 0; // Is working in VirtualData or default mode.
434449 virtual void ModifyData (const HEXMODIFY& hms) = 0; // Main routine to modify data in IsMutable()==true mode.
450+ [[nodiscard]] virtual bool PreTranslateMsg (MSG* pMsg) = 0;
435451 virtual void Redraw () = 0; // Redraw HexCtrl's window.
436452 virtual void SetCapacity (DWORD dwCapacity) = 0; // Set current capacity.
437453 virtual void SetCaretPos (ULONGLONG ullOffset, bool fHighLow = true , bool fRedraw = true ) = 0; // Set the caret position.
438454 virtual void SetCharsExtraSpace (DWORD dwSpace) = 0; // Extra space to add between chars, in pixels.
439455 virtual void SetCodepage (int iCodepage) = 0; // Codepage for text area.
440456 virtual void SetColors (const HEXCOLORS& hcs) = 0; // Set HexCtrl's colors.
441457 virtual bool SetConfig (std::wstring_view wsvPath) = 0; // Set configuration file, or "" for defaults.
442- virtual void SetData (const HEXDATA& hds) = 0; // Main method for setting data to display (and edit) .
458+ virtual void SetData (const HEXDATA& hds, bool fAdjust = false ) = 0; // Main method to set data for HexCtrl .
443459 virtual void SetDateInfo (DWORD dwFormat, wchar_t wchSepar) = 0; // Set date format and date separator.
444460 virtual void SetDlgProperties (EHexWnd eWnd, std::uint64_t u64Flags) = 0; // Properties for the internal dialogs.
445- virtual void SetFont (const LOGFONTW& lf) = 0; // Set HexCtrl's font, this font has to be monospaced .
461+ virtual void SetFont (const LOGFONTW& lf, bool fMain = true ) = 0; // Set main/infobar font.
446462 virtual void SetGroupSize (DWORD dwSize) = 0; // Set data grouping size.
447- virtual void SetMutable (bool fEnable ) = 0; // Enable or disable mutable/editable mode.
463+ virtual void SetMutable (bool fMutable ) = 0; // Enable or disable mutable/editable mode.
448464 virtual void SetOffsetMode (bool fHex ) = 0; // Set offset being shown as Hex or as Decimal.
449465 virtual void SetPageSize (DWORD dwSize, std::wstring_view wsvName = L" Page" ) = 0; // Set page size and name to draw the lines in-between.
450466 virtual void SetRedraw (bool fRedraw ) = 0; // Handle WM_PAINT message or not.
451467 virtual void SetScrollRatio (float flRatio, bool fLines ) = 0; // Set mouse-wheel scroll ratio in screens or in lines.
452468 virtual void SetSelection (const VecSpan& vecSel, bool fRedraw = true , bool fHighlight = false ) = 0; // Set current selection.
453469 virtual void SetUnprintableChar (wchar_t wch) = 0; // Set unprintable replacement character.
454470 virtual void SetVirtualBkm (IHexBookmarks* pVirtBkm) = 0; // Set pointer for Bookmarks Virtual Mode.
471+ virtual void SetWindowPos (HWND hWndAfter, int iX, int iY, int iWidth, int iHeight, UINT uFlags = SWP_NOACTIVATE | SWP_NOZORDER) = 0;
455472 virtual void ShowInfoBar (bool fShow ) = 0; // Show/hide bottom Info bar.
456473 };
457474
458- struct IHexCtrlDeleter {
459- void operator ()(IHexCtrl* p)const { p->Destroy (); }
460- };
461-
475+ struct IHexCtrlDeleter { void operator ()(IHexCtrl* p)const { p->Delete (); } };
462476 using IHexCtrlPtr = std::unique_ptr<IHexCtrl, IHexCtrlDeleter>;
463- [[nodiscard]] HEXCTRLAPI IHexCtrlPtr CreateHexCtrl (HINSTANCE hInstClass = nullptr );
464-
465- #if defined(HEXCTRL_SHARED_DLL) || defined(HEXCTRL_MANUAL_MFC_INIT)
466- extern " C" HEXCTRLAPI BOOL __cdecl HexCtrlPreTranslateMessage (MSG * pMsg);
467- #endif
477+ [[nodiscard]] HEXCTRLAPI IHexCtrlPtr CreateHexCtrl ();
468478
469479 /* *************************************************************************
470480 * WM_NOTIFY message codes (NMHDR.code values). *
@@ -490,13 +500,12 @@ namespace HEXCTRL {
490500 constexpr auto HEXCTRL_MSG_SETGROUPSIZE { 0x0110U }; // Data grouping size has changed.
491501 constexpr auto HEXCTRL_MSG_SETSELECTION { 0x0111U }; // Selection has been made.
492502
493-
494503 /* *************************************************************************
495504 * Flags for the internal dialogs, used with the SetDlgProperties method. *
496505 **************************************************************************/
497506
498507 constexpr auto HEXCTRL_FLAG_DLG_NOESC { 0x01ULL };
499508
500- // Setting a manifest for the ComCtl32 .dll version 6 .
509+ // Manifest for the Comctl32.dll v6. Must be here, in header, to pick up v6 for the .dll as well .
501510#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
502511}
0 commit comments