1, the initialization of the list box. In the initialization function: DWORD dwexstyle= Lvs_ex_fullrowselect | Lvs_ex_gridlines |/*Lvs_ex_subitemimages |*/ //list Style M_list1.setextendedstyle (lvs_ex_fullrowselect| Lvs_ex_gridlines); //Lvs_ex_headerdragdrop | Lvs_ex_trackselect;M_list1.insertcolumn (0, _t ("xx"), lvcfmt_image| Lvcfmt_left);//column headings for listsM_list1.insertcolumn (1, _t ("xx")); M_list1.insertcolumn (2, _t ("xx")); M_list1.insertcolumn (3, _t ("XXX")); M_list1.insertcolumn (4, _t ("XXX")); M_list1.insertcolumn (5, _t ("XXX")); M_list1.insertcolumn (6, _t ("xxxx")); M_list1.setcolumnwidth (0, -);//Column Width for(intj=1;j<7; j + +) M_list1.setcolumnwidth (J, the);//Column width Setting2, the scroll bar is placed at the bottom of the list box. //This is the Get scroll bar current position//intVisindex =M_list1.getscrollpos (sb_vert);//int posx = M_list1.getscrollpos (Sb_horz);//put new data in the CListCtrl again//set the location of the scroll after completion//M_list1.setscrollpos (posx,visindex,1); //ensure the last item is visible.intNcount =M_list1.getitemcount ();if(Ncount >0) m_list1.ensurevisible (ncount-1, FALSE);3, the alarm plays the sound. //displayed in the List1. //gets the current time. CTime time; time=Ctime::getcurrenttime (); CString Str= Time.format ("%y.%m.%d.%i:%m:%s"); M_date=Str;if(M_recv1 < m_nd && M_recv2 < m_nd)//to modify according to the actual situation{ } Else{m_dataistrue="not qualified"; //Alarm//_variant_t VTIM,VRSC,VRSB,VRSRSJ; Nitem=m_list1.insertitem (0xFFFF, (_bstr_t) Str);//Date Time M_list1.setitem (nitem,1,1, (_bstr_t) qianhao,null,0,0,0);//maximum value for marginM_list1.setitem (Nitem,2,1, (_bstr_t) Xianxing,null,0,0,0);//to the margin middle valueM_list1.setitem (Nitem,3,1, (_bstr_t) M_recv3,null,0,0,0);//the maximum value of the margin M_list1.setitem (nitem,4,1, (_bstr_t) m_recv2,null,0,0,0);//to margin median value M_list1.setitem (nitem,5,1, (_bstr_t) m_recv1,null,0,0,0);//the minimum value of the margin M_list1.setitem (nitem,6,1, (_bstr_t) m_dataistrue,null,0,0,0);//data display. M_list1.setitemcolor (Nitem, RGB (255,0,0)); //Alarm Sound//SetTimer (3,20000,null);//PlaySound (LPCTSTR) Idr_beep, AfxGetInstanceHandle (), Snd_resource |Snd_async); //PlaySound (L "Air.wav", null,snd_filename| Snd_async);} updatedata (false);
VC MFC Listctrl Control vertical scroll bar at the bottom