Main events and mouse response functions of CListCtrl

Source: Internet
Author: User

Main Events:

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

notes:

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

For example:

handling of lvn_itemchanged event messages

In. CPP found in the following two paragraphs, between them to add bold that the sentence, the third parameter is the function name, you can write freely ,

Begin_message_map ()

on_notify (lvn_itemchanged, Idc_list1, OnItemchangedList1);

End_message_map ()

In. The addition of afx_msg void OnItemchangedList1 (nmhdr* pnmhdr, lresult* PResult) in H is considered a function declaration.

In. Add functions in CPP:

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

if (pnmlistview->uchanged==lvif_state)
{
if (Pnmlistview->unewstate & lvis_selected)
{
Working with 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 a message handler 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.