Skip to content

Commit

Permalink
Added new icons to the context menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
jovibor committed Dec 26, 2021
1 parent 1df873f commit ee13d05
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 24 deletions.
10 changes: 10 additions & 0 deletions HexCtrl/res/HexCtrl.rc
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,16 @@ IDB_HEXCTRL_LOGO BITMAP "IDB_HEXCTRL_LOGO.bmp"

IDB_HEXCTRL_MODIFY_FILLZEROS BITMAP "IDB_HEXCTRL_MODIFY_FILLZEROS.bmp"

IDB_HEXCTRL_SEARCH BITMAP "IDB_HEXCTRL_SEARCH.bmp"

IDB_HEXCTRL_BKMS BITMAP "IDB_HEXCTRL_BKMS.bmp"

IDB_HEXCTRL_MODIFY BITMAP "IDB_HEXCTRL_MODIFY.bmp"

IDB_HEXCTRL_DLG_DATAINTERP BITMAP "IDB_HEXCTRL_DLG_DATAINTERP.bmp"

IDB_HEXCTRL_GROUP BITMAP "IDB_HEXCTRL_GROUP.bmp"


/////////////////////////////////////////////////////////////////////////////
//
Expand Down
7 changes: 6 additions & 1 deletion HexCtrl/res/HexCtrlRes.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#define IDB_HEXCTRL_CLPBRD_PASTEHEX 9003
#define IDB_HEXCTRL_MODIFY_FILLZEROS 9004
#define IDB_HEXCTRL_SCROLL_ARROW 9005
#define IDB_HEXCTRL_SEARCH 9006
#define IDB_HEXCTRL_BKMS 9007
#define IDB_HEXCTRL_MODIFY 9008
#define IDB_HEXCTRL_DLG_DATAINTERP 9009
#define IDB_HEXCTRL_GROUP 9010
#define IDD_HEXCTRL_SEARCH 9101
#define IDD_HEXCTRL_ABOUT 9102
#define IDD_HEXCTRL_OPERS 9103
Expand Down Expand Up @@ -138,7 +143,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 9262
#define _APS_NEXT_RESOURCE_VALUE 9264
#define _APS_NEXT_COMMAND_VALUE 32820
#define _APS_NEXT_CONTROL_VALUE 9264
#define _APS_NEXT_SYMED_VALUE 9333
Expand Down
Binary file added HexCtrl/res/IDB_HEXCTRL_BKMS.bmp
Binary file not shown.
Binary file added HexCtrl/res/IDB_HEXCTRL_DLG_DATAINTERP.bmp
Binary file not shown.
Binary file added HexCtrl/res/IDB_HEXCTRL_GROUP.bmp
Binary file not shown.
Binary file added HexCtrl/res/IDB_HEXCTRL_MODIFY.bmp
Binary file not shown.
Binary file modified HexCtrl/res/IDB_HEXCTRL_MODIFY_FILLZEROS.bmp
Binary file not shown.
Binary file added HexCtrl/res/IDB_HEXCTRL_SEARCH.bmp
Binary file not shown.
47 changes: 37 additions & 10 deletions HexCtrl/src/CHexCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ namespace HEXCTRL
//Struct for resources auto deletion on destruction.
struct CHexCtrl::SHBITMAP
{
SHBITMAP() = default;
SHBITMAP(HBITMAP hBmp) { m_hBmp = hBmp; }
~SHBITMAP() { ::DeleteObject(m_hBmp); }
SHBITMAP& operator=(HBITMAP hBmp) { m_hBmp = hBmp; return *this; }
operator HBITMAP()const { return m_hBmp; }
HBITMAP m_hBmp { };
};

Expand Down Expand Up @@ -253,21 +251,50 @@ bool CHexCtrl::Create(const HEXCREATE& hcs)
const auto hInst = AfxGetInstanceHandle();
const auto fScale = m_iLOGPIXELSY / 96.0F; //Scale factor for HighDPI displays.
const auto iSizeIcon = static_cast<int>(16 * fScale);
const auto pMenuTop = m_menuMain.GetSubMenu(0); //Context sub-menu handle.

//"Search" menu icon.
mii.hbmpItem = static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_SEARCH), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
pMenuTop->SetMenuItemInfoW(0, &mii, TRUE); //"Search" parent menu icon.
m_menuMain.SetMenuItemInfoW(IDM_HEXCTRL_DLG_SEARCH, &mii);
m_vecHBITMAP.emplace_back(std::make_unique<SHBITMAP>(mii.hbmpItem));

//"Group Data" menu icon.
mii.hbmpItem = static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_GROUP), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
pMenuTop->SetMenuItemInfoW(2, &mii, TRUE); //"Group Data" parent menu icon.
m_vecHBITMAP.emplace_back(std::make_unique<SHBITMAP>(mii.hbmpItem));

//"Bookmarks->Add" menu icon.
mii.hbmpItem = static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_BKMS), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
pMenuTop->SetMenuItemInfoW(4, &mii, TRUE); //"Bookmarks" parent menu icon.
m_menuMain.SetMenuItemInfoW(IDM_HEXCTRL_BKM_ADD, &mii);
m_vecHBITMAP.emplace_back(std::make_unique<SHBITMAP>(mii.hbmpItem));

//"Clipboard->Copy as Hex" menu icon.
mii.hbmpItem = m_umapHBITMAP[IDM_HEXCTRL_CLPBRD_COPYHEX] =
static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_CLPBRD_COPYHEX), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
mii.hbmpItem = static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_CLPBRD_COPYHEX), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
pMenuTop->SetMenuItemInfoW(5, &mii, TRUE); //"Clipboard" parent menu icon.
m_menuMain.SetMenuItemInfoW(IDM_HEXCTRL_CLPBRD_COPYHEX, &mii);
m_vecHBITMAP.emplace_back(std::make_unique<SHBITMAP>(mii.hbmpItem));

//"Clipboard->Paste as Hex" menu icon.
mii.hbmpItem = m_umapHBITMAP[IDM_HEXCTRL_CLPBRD_PASTEHEX] =
static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_CLPBRD_PASTEHEX), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
mii.hbmpItem = static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_CLPBRD_PASTEHEX), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
m_menuMain.SetMenuItemInfoW(IDM_HEXCTRL_CLPBRD_PASTEHEX, &mii);
m_vecHBITMAP.emplace_back(std::make_unique<SHBITMAP>(mii.hbmpItem));

//"Modify" parent menu icon.
mii.hbmpItem = static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_MODIFY), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
pMenuTop->SetMenuItemInfoW(6, &mii, TRUE);
m_vecHBITMAP.emplace_back(std::make_unique<SHBITMAP>(mii.hbmpItem));

//"Modify->Fill with Zeros" menu icon.
mii.hbmpItem = m_umapHBITMAP[IDM_HEXCTRL_MODIFY_FILLZEROS] =
static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_MODIFY_FILLZEROS), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
mii.hbmpItem = static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_MODIFY_FILLZEROS), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
m_menuMain.SetMenuItemInfoW(IDM_HEXCTRL_MODIFY_FILLZEROS, &mii);
m_vecHBITMAP.emplace_back(std::make_unique<SHBITMAP>(mii.hbmpItem));

//"Data View->Data Interpreter" menu icon.
mii.hbmpItem = static_cast<HBITMAP>(LoadImageW(hInst, MAKEINTRESOURCEW(IDB_HEXCTRL_DLG_DATAINTERP), IMAGE_BITMAP, iSizeIcon, iSizeIcon, LR_CREATEDIBSECTION));
m_menuMain.SetMenuItemInfoW(IDM_HEXCTRL_DLG_DATAINTERP, &mii);
m_vecHBITMAP.emplace_back(std::make_unique<SHBITMAP>(mii.hbmpItem));
/*End of menu related.*/

/*Font related.*/
Expand Down Expand Up @@ -4598,7 +4625,7 @@ void CHexCtrl::OnDestroy()
m_fontMain.DeleteObject();
m_fontInfo.DeleteObject();
m_penLines.DeleteObject();
m_umapHBITMAP.clear();
m_vecHBITMAP.clear();
m_vecKeyBind.clear();
m_pDlgBkmMgr->DestroyWindow();
m_pDlgDataInterp->DestroyWindow();
Expand Down
4 changes: 2 additions & 2 deletions HexCtrl/src/CHexCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ namespace HEXCTRL::INTERNAL
std::wstring m_wstrTextTitle { }; //Text area title.
std::deque<std::unique_ptr<std::vector<SUNDO>>> m_deqUndo; //Undo deque.
std::deque<std::unique_ptr<std::vector<SUNDO>>> m_deqRedo; //Redo deque.
std::unordered_map<int, SHBITMAP> m_umapHBITMAP; //Images for the Menu.
std::vector<std::unique_ptr<SHBITMAP>> m_vecHBITMAP { }; //Icons for the Menu.
std::vector<SKEYBIND> m_vecKeyBind { }; //Vector of key bindings.
wchar_t m_wchUnprintable { L'.' }; //Replacement char for unprintable characters.
wchar_t m_wchDateSepar { L'/' }; //Date separator.
Expand All @@ -285,4 +285,4 @@ namespace HEXCTRL::INTERNAL
bool m_fMenuCMD { false }; //Command to be executed through menu, not through key-shortcut.
bool m_fRedraw { true }; //Should WM_PAINT be handled or not.
};
}
}
4 changes: 2 additions & 2 deletions HexCtrl/src/HexUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#define HEXCTRL_PRODUCT_NAME L"Hex Control for MFC/Win32"
#define HEXCTRL_COPYRIGHT_NAME L"(C) 2018-2021 Jovibor"
#define HEXCTRL_VERSION_MAJOR 3
#define HEXCTRL_VERSION_MINOR 0
#define HEXCTRL_VERSION_MAINTENANCE 1
#define HEXCTRL_VERSION_MINOR 1
#define HEXCTRL_VERSION_MAINTENANCE 0

#define TO_WSTR_HELPER(x) L## #x
#define TO_WSTR(x) TO_WSTR_HELPER(x)
Expand Down
11 changes: 8 additions & 3 deletions VS Projects/DLL Project/DLL Project.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,19 @@
<ResourceCompile Include="..\..\HexCtrl\res\HexCtrl.rc" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\HexCtrl\res\IDR_HEXCTRL_JSON_KEYBIND.json" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_BKMS.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_CLPBRD_COPYHEX.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_CLPBRD_PASTEHEX.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_GROUP.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_LOGO.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_MODIFY.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_MODIFY_FILLZEROS.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_SCROLL_ARROW.bmp" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\HexCtrl\res\IDR_HEXCTRL_JSON_KEYBIND.json" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_SEARCH.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_DLG_DATAINTERP.bmp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
23 changes: 19 additions & 4 deletions VS Projects/DLL Project/DLL Project.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\HexCtrl\res\IDR_HEXCTRL_JSON_KEYBIND.json">
<Filter>HexCtrl\res</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_BKMS.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_CLPBRD_COPYHEX.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
Expand All @@ -177,16 +185,23 @@
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_LOGO.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_MODIFY.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_MODIFY_FILLZEROS.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_SCROLL_ARROW.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<None Include="..\..\HexCtrl\res\IDR_HEXCTRL_JSON_KEYBIND.json">
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_SEARCH.bmp">
<Filter>HexCtrl\res</Filter>
</None>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_DLG_DATAINTERP.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_GROUP.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion VS Projects/Sample Project/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 132
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32777
#define _APS_NEXT_CONTROL_VALUE 1011
#define _APS_NEXT_SYMED_VALUE 101
Expand Down
5 changes: 5 additions & 0 deletions VS Projects/Sample Project/Sample Project.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,16 @@
<None Include="res\HexSample.rc2" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_BKMS.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_CLPBRD_COPYHEX.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_CLPBRD_PASTEHEX.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_DLG_DATAINTERP.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_GROUP.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_LOGO.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_MODIFY.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_MODIFY_FILLZEROS.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_SCROLL_ARROW.bmp" />
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_SEARCH.bmp" />
<Image Include="res\HexSample.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
17 changes: 16 additions & 1 deletion VS Projects/Sample Project/Sample Project.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
<Image Include="res\HexSample.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_SCROLL_ARROW.bmp">
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_BKMS.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_CLPBRD_COPYHEX.bmp">
Expand All @@ -209,11 +209,26 @@
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_CLPBRD_PASTEHEX.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_DLG_DATAINTERP.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_GROUP.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_LOGO.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_MODIFY_FILLZEROS.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_SCROLL_ARROW.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_SEARCH.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
<Image Include="..\..\HexCtrl\res\IDB_HEXCTRL_MODIFY.bmp">
<Filter>HexCtrl\res</Filter>
</Image>
</ItemGroup>
</Project>

0 comments on commit ee13d05

Please sign in to comment.