got it working
This is a multi-part message in MIME format.
------=_NextPart_000_000B_01C8F16E.E1BFD040
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
How can I intercept the right-click to make sure it's on a valid row =
before
the selection event occurs?
I have a kludge that selects the row above after the fact but it's =
pretty
ugly. Optimally I'd like to prevent the row selection event from =
ever
occuring.
You might be able to handle this in WM_RBUTTONDOWN or =
LVN_ITEMCHANGING.
--
Here's what I did. It works like a charm. The OnNmRclick function does =
not get called unless I make the call to the base class OnRButtonDown =
function. I only do this if a valid ItemData pointer is found. =
Thanks for helping me think this through.
void CDeleteBtnListCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
if (m_bOnlyAllowRClickSelectIfItemDataExists)
{
LVHITTESTINFO lvhti;
lvhti.pt = point;
int iItemSelected = SubItemHitTest(&lvhti);
if (iItemSelected >= 0)
{
if (GetItemData(iItemSelected) == NULL)
{
return;
}
}
}
CListCtrl::OnRButtonDown(nFlags, point);
}
------=_NextPart_000_000B_01C8F16E.E1BFD040
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; =
charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>><BR>>>How can I intercept the =
right-click
to make sure it's on a valid row before <BR>>>the selection event
occurs?<BR>>><BR>>>I have a kludge that selects the row =
above after
the fact but it's pretty <BR>>>ugly. Optimally I'd =
like to
prevent the row selection event from ever <BR>>>occuring.<BR>> =
<BR>>
You might be able to handle this in WM_RBUTTONDOWN or =
LVN_ITEMCHANGING.<BR>>
<BR>> -- <BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Here's what I did. It works like =
a
charm. The OnNmRclick function does not get called unless I make =
the call
to the base class OnRButtonDown function. I only do this if =
a valid
ItemData pointer is found. Thanks for helping me think this
through.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DL>
<DT><FONT face="Courier New" size=2>void
CDeleteBtnListCtrl::OnRButtonDown(UINT nFlags, CPoint point) =
</FONT></DT>
<DT><FONT face="Courier New" size=2>{</FONT></DT>
<DT><FONT face="Courier New" size=2> if
(m_bOnlyAllowRClickSelectIfItemDataExists)</FONT></DT>
<DT><FONT face="Courier New" size=2> =
{</FONT></DT>
<DT><FONT face="Courier New" size=2> =
LVHITTESTINFO lvhti;</FONT></DT>
<DT><FONT face="Courier New" size=2> =
lvhti.pt = point;</FONT></DT>
<DT><FONT face="Courier New" size=2> =
int
iItemSelected = SubItemHitTest(&lvhti);</FONT></DT>
<DT><FONT face="Courier New" size=2></FONT> </DT>
<DT><FONT face="Courier New" size=2> =
if
(iItemSelected >= 0)</FONT></DT>
<DT><FONT face="Courier New"
size=2> {</FONT></DT>
<DT><FONT face="Courier New" size=2> =
if (GetItemData(iItemSelected) == =
NULL)</FONT></DT>
<DT><FONT face="Courier New" size=2> =
{</FONT></DT>
<DT><FONT face="Courier New" size=2> =
return;</FONT></DT>
<DT><FONT face="Courier New" size=2> =
}</FONT></DT>
<DT><FONT face="Courier New" size=2> =
}</FONT></DT>
<DT><FONT face="Courier New" size=2> =
}</FONT></DT>
<DT><FONT face="Courier New" size=2></FONT> </DT>
<DT><FONT face="Courier New" size=2>
CListCtrl::OnRButtonDown(nFlags, point);</FONT></DT>
<DT><FONT face="Courier New" =
size=2>}</FONT></DT></DL></BODY></HTML>
------=_NextPart_000_000B_01C8F16E.E1BFD040--