Home > Software engineering >  CListCtrl controls click a line, if keep the front the behavior of the selected selected?
CListCtrl controls click a line, if keep the front the behavior of the selected selected?

Time:11-20

The default, click operation will be cancelled before the selected rows, if my memory before line state, within the OnClick event is reset SetItemState will lead to serious redraw flicker problem!
I slow decomposition, the mouse to click another line, the choice of other guild lost status,

My demand is done by mouse click multiple-choice, namely,3,5 click 1 to 1,3,5 lines selected, if the second click on the selected rows, the rollover state is not selected,

CodePudding user response:

General multi-select operation press the Ctrl key, and then choose

CodePudding user response:

My demand is done by mouse click multi-select
CListCtrl
Have multiple attributes, not yourself!

CodePudding user response:

CListCtrl support multi-line option

CodePudding user response:

My demand is not through the CTRL/SHIFT key, realize the multiple-choice, but simply by mouse click multiple-choice, no keyboard, touch screen operation,
refer to the second floor schlafenhamster response:
my demand is done by mouse click multi-select
CListCtrl
Have multiple attributes, not yourself!

CodePudding user response:

reference solitary guest tianya reply: 3/f
CListCtrl support multi-line select

Touch screen, no keyboard, does not support the CTRL/shift multiple-choice, do how?

CodePudding user response:

reference 5 floor teleinfor reply:
Quote: refer to the third floor of solitary guest tianya response:

CListCtrl support multi-line select

Touch screen, no keyboard, does not support the CTRL/shift multiple-choice, do how?


Method are many, the first can simulate CTRL key,
Another why use selected to do, can not add a check box?

CodePudding user response:

 
# pragma once

//CMyListCtrl
The class CMyListCtrl: public CListCtrl
{
DECLARE_DYNAMIC (CMyListCtrl)

Public:
CMyListCtrl ()
Virtual ~ CMyListCtrl ()

Public:
Virtual BOOL PreTranslateMessage (MSG * pMsg)
{
The switch (pMsg - & gt; Message)
{
Case (WM_LBUTTONDOWN) :
Case (WM_LBUTTONUP) :
{
PMsg - & gt; WParam |=MK_CONTROL;//simulation press CTRL button
break;
}
}

Return __super: : PreTranslateMessage (pMsg);
}

Protected:
DECLARE_MESSAGE_MAP ()
};



CodePudding user response:

Sounds like LVS_EX_AUTOCHECKSELECT?

CodePudding user response:

Know, there is a simple graphic principle, whether their maintenance within the ListCtrl a all the selected variables, such as
 STD: : map M_mapSelectState; 


When drawing according to the Boolean value to map, click on time according to the bool to set the new value, was done

CodePudding user response:

Void CMyListCtrl: : OnLButtonDown (UINT nFlags, CPoint point)
{
//TODO: Add your message handler code here and/or call the default
If # 1//see PreTranslateMessage
SetFocus ();//blue
//
LVHITTESTINFO hti.
Hti. Pt=point;
Int independence Idx=HitTest (& amp; Hti);//or SubItemHitTest
AfxDump & lt; If (Idx<0) return;
If (GetItemState (independence Idx LVIS_SELECTED))
{
SetItemState (independence Idx, 0, LVIS_SELECTED);
}
The else
{
SetItemState (independence Idx, LVIS_SELECTED LVIS_SELECTED);
}
# the else
CListCtrl: : OnLButtonDown (nFlags, point);
# endif
}

CodePudding user response:

Refer to the eighth floor method, allows the list to the first column, add a checkbox, users only need to select the checkbox
  • Related