Zdravím,
chtěl bych nějakým způsobem zachytit, když je kurzor myši na uživatelsky kresleném tlačítku.
Zkoušel jsem ODS_HOTLIGHT, ale to nedělá nic. Dále jsem zkoušel testovat bod v oblasti (PtInRect), ale pozice kurzoru pomocí WM_MOUSEMOVE se zjišťuje pouze s kurzorem v klientské oblasti.
Koukal jsem na strukturu NMBCHOTITEM a BCN_HOTITEMCHANGE, ale nic jsem o tom nenašel.
Asi vím, jak bych to dělal přes subclassing, ale to bych musel subclassnout každé tlačítko, které bych chtěl uživatelsky kreslit. Jde mi hlavně o to, aby ta funkce byla co nejjednodušší.
LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)lParam;
if(lpDIS->hwndItem == buttonHwnd)
{
if(lpDIS->itemState & ODS_SELECTED)
{
HBRUSH brush = CreateSolidBrush(Select_ButtonBrush); // Button inside color
HPEN pen = CreatePen(PS_INSIDEFRAME, 0, Select_ButtonBorder); // Button border color
HGDIOBJ old_pen = SelectObject(lpDIS->hDC, pen); //Select colors ˇ
HGDIOBJ old_brush = SelectObject(lpDIS->hDC, brush);
FillRect(lpDIS->hDC, &lpDIS->rcItem, CreateSolidBrush(Select_Base_Brush)); // Base color (to ensure transparency when round button is used)
RoundRect(lpDIS->hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, 5, 5); // Color the button with colors already set above...^
SetTextColor(lpDIS->hDC, Select_TextColor); // Button Text Color
SetBkColor(lpDIS->hDC, Select_ButtonBrush); // Text background color (May be same to ensure text transparency)
DrawText(lpDIS->hDC, "Apply", -1, &lpDIS->rcItem, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
SelectObject(lpDIS->hDC, old_pen);
SelectObject(lpDIS->hDC, old_brush);
DeleteObject(pen); // Cleanup
}
else if(lpDIS->itemState & ODS_HOTLIGHT) // Nereaguje...
{
HBRUSH brush = CreateSolidBrush(ButtonBrush); // Button inside color
HPEN pen = CreatePen(PS_INSIDEFRAME, 0, ButtonBorder); // Button border color
HGDIOBJ old_pen = SelectObject(lpDIS->hDC, pen); //Select colors ˇ
HGDIOBJ old_brush = SelectObject(lpDIS->hDC, brush);
FillRect(lpDIS->hDC, &lpDIS->rcItem, CreateSolidBrush(Base_Brush)); // Base color (to ensure transparency when round button is used)
RoundRect(lpDIS->hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, 5, 5); // Color the button with colors already set above...^
SetTextColor(lpDIS->hDC, TextColor); // Button Text Color
SetBkColor(lpDIS->hDC, ButtonBrush); // Text background color (May be same to ensure text transparency)
DrawText(lpDIS->hDC, "Apply", -1, &lpDIS->rcItem, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
SelectObject(lpDIS->hDC, old_pen);
SelectObject(lpDIS->hDC, old_brush);
DeleteObject(pen); // Cleanup
}
}
Předem díky.