Skip to content

Commit

Permalink
add jump feature 5
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Mar 31, 2024
1 parent 488a6da commit 0465267
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion XG_HintsWnd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ class XG_HintsWnd : public XG_Window
// ハイライトに背景色を付ける。
HBRUSH OnCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type) noexcept
{
if (hwndChild == s_hwndHighlightVertEdit || hwndChild == s_hwndHighlightHorzEdit)
if (hwndChild == m_hwndTrackMenuOn)
{
constexpr COLORREF rgbColor = RGB(255, 140, 255);
SetBkColor(hdc, rgbColor);
SetDCBrushColor(hdc, rgbColor);
return GetStockBrush(DC_BRUSH);
}
else if (hwndChild == s_hwndHighlightVertEdit || hwndChild == s_hwndHighlightHorzEdit)
{
constexpr COLORREF rgbColor = RGB(140, 255, 255);
SetBkColor(hdc, rgbColor);
Expand Down Expand Up @@ -733,6 +740,7 @@ class XG_HintsWnd : public XG_Window
// ジャンプ先番号。
INT m_nNumber = 0;
BOOL m_bVert = FALSE;
HWND m_hwndTrackMenuOn = NULL;

// WM_CONTEXTMENU
// 「ヒント」ウィンドウのコンテキストメニュー。
Expand All @@ -756,10 +764,25 @@ class XG_HintsWnd : public XG_Window
if (!bStatic || !m_nNumber)
DeleteMenu(hSubMenu, ID_JUMPNUMBER, MF_BYCOMMAND);

// スタティックなら色を変える。
if (bStatic)
{
m_hwndTrackMenuOn = hwndContext;
InvalidateRect(hwndContext, NULL, TRUE);
}

// 右クリックメニューを表示する。
::SetForegroundWindow(hwnd);
constexpr auto flags = TPM_RIGHTBUTTON | TPM_LEFTALIGN | TPM_RETURNCMD;
const auto nCmd = ::TrackPopupMenu(hSubMenu, flags, xPos, yPos, 0, hwnd, nullptr);

// 色を戻す。
if (bStatic)
{
m_hwndTrackMenuOn = NULL;
InvalidateRect(hwndContext, NULL, TRUE);
}

::PostMessageW(hwnd, WM_NULL, 0, 0);
if (nCmd)
::PostMessageW(xg_hMainWnd, WM_COMMAND, nCmd, 0);
Expand All @@ -784,6 +807,7 @@ class XG_HintsWnd : public XG_Window
HANDLE_MSG(hWnd, WM_GETMINMAXINFO, OnGetMinMaxInfo);
HANDLE_MSG(hWnd, WM_CONTEXTMENU, OnContextMenu);
HANDLE_MSG(hWnd, WM_CTLCOLOREDIT, OnCtlColor);
HANDLE_MSG(hWnd, WM_CTLCOLORSTATIC, OnCtlColor);
default:
return ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
Expand Down

0 comments on commit 0465267

Please sign in to comment.