CListCtrl control main events and handling of lvn_itemchanged messages and mouse double-click List item Events

Source: Internet
Author: User

MFC CListCtrl Select a row, the message is which. I can't remember. Find an article, more useful:


Http://www.cnblogs.com/hongfei/archive/2012/12/25/2832806.html


Lvn_begindrag the left mouse button is being triggered for drag-and-drop operations (resulting when the left mouse button starts dragging items in a list view control)

Lvn_beginrdrag The right mouse button is being triggered for drag-and-drop operations (resulting when the right mouse button starts dragging items in a list view control)

Lvn_beginlabeledit start editing the text of an item

Lvn_columnclick click a column (resulting when the mouse clicks the column header of a list view control)

Nm_click when the mouse clicks the list view Control

Lvn_columnclick Click Columns

Lvn_deleteallitems Delete all items

Lvn_deleteitem Deleting an item

NM_DBLCLK occurs when the mouse double-clicks the list view Control

Lvn_endlabeledit ending edits to item text

Lvn_getdispinfo request information that needs to be displayed

Lvn_getinfotip additional text information that is requested to be displayed in the ToolTip window

Lvn_hottrack Mouse over an item

Lvn_insertitem When you insert a project into a list view control

Lvn_itemactivate activating an item

Lvn_itemchanged an item has changed

Lvn_itemchanging a project is changing

Nm_killfocus occurs when the View Table column chart control loses focus

Lvn_keydown a key is pressed

Lvn_marqueebegin Start a border selection

Nm_outofmemory When a memory overflow occurs

Lvn_odcachehint the contents of the display area of the virtual list control have changed

Lvn_odstatechanged an item or a range of items in a control of a virtual list has changed

Lvn_odfinditem requires the owner to find a specific callback item

Nm_rclick when the right mouse button is clicked on a list view control

NM_RDBLCLK when the right mouse button is double-clicked on a list view control

Nm_setfocus when a list view control receives focus

Lvn_setdispinfo the parent window must update the information maintained by the control for the item

Annotations:

Hdn:header Notify
Lvn:listview Control Notify
Nm:notify Message
Tvn:treeview Control Notify

Handling of lvn_itemchanged messages

Message handler functions:

void C***dlg::onitemchangedlist (nmhdr* pnmhdr, lresult* pResult) 
{
nm_listview* Pnmlistview = (nm_listview*) PNMHDR;

if (pnmlistview->uchanged==lvif_state)
{
if (pnmlistview->unewstate & lvis_selected)
   {
    / /processing content
    int nitem=pnmlistview->iitem;
    CString value[6];
    for (int i=0;i<6;i++)
    {
     value[i]=m_list.getitemtext (nitem,i);}}
}
*presult = 0;
}

The two if conditional sentences in the message handler must be there, otherwise there may be multiple entry handling issues.

Mouse double-click on the handling of list item events

Response NM_DBLCLK Message:

void Cdissalarydlg::ondblclklist (nmhdr* pnmhdr, lresult* pResult) 
{
    Nm_listview *pnmlistview= (nm_listview *) Pnmhdr;
    int nitem=pnmlistview->iitem;
    if (nitem>=0 && nitem<m_list.getitemcount ())//Determine if the double-click position is above the list item with data
    {
        ...
    }

    *presult = 0;
}

The IF statement in the

      Message handler function is important to determine whether the double-click position is above the list item with the data. Because the NM_DBLCLK message is a CListCtrl control (overall) message, the message is generated if the event is executed within the scope of the CListCtrl control, not necessarily on the list item that has the data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.