導航:首頁 > 源碼編譯 > list源碼教程

list源碼教程

發布時間:2022-09-06 05:43:58

A. php源碼,phplist的安裝方法,我下了源碼包,不知道怎麼用!

程序目錄都會附帶readme,它會教你怎麼安裝.

B. 怎樣給VC中的List控制項添加ToolTip

VC6的List控制項默認是不能為subitem提供tooltip的,只有通過重寫CListCtrl類來實現。在網上找了一個寫好的CToolTipListCtrl類可以顯示該功能,只需調用即可。具體步驟如下:

1.將ToolTipListCtrl.h和ToolTipListCtrl.cpp加入工程。

2.為List控制項添加相應的變數CListCtrl m_lstObject。

3.用CToolTipListCtrl替換上面的CListCtrl,當然還要加入相應的頭文件「#include "ToolTipListCtrl.h"」。

4.設置列表的擴展樣式,使之包含LVS_EX_INFOTIP樣式。

m_lstObject.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_INFOTIP);

5.步驟4也可以改為

m_lstObject.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

m_lstObject.EnableToolTips(TRUE);

6.編譯運行程序。效果見下圖:

是不是很簡單呢,你也趕快試試吧。

下面是ToolTipListCtrl.h和ToolTipListCtrl.cpp源碼:

#if !defined(AFX_TOOLTIPLISTCTRL_H__EA17BA6D_ADD2_49E3_AB67_45B65316D19F__INCLUDED_)
#define AFX_TOOLTIPLISTCTRL_H__EA17BA6D_ADD2_49E3_AB67_45B65316D19F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ToolTipListCtrl.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CToolTipListCtrl window

#include <afxtempl.h>

/////////////////////////////////////////////////////////////////////////////
// CToolTipListCtrl, v.1.0
//
// A CListCtrl derived class that
// can display per SubItem tooltips by itself
//
// Author: Jo鉶 Filipe de Castro Ferreira (jfilipe@isr.uc.pt)
// Based on Nate Maynard's (nate.maynard@neomation.com) CToolTipTreeCtrl
//
// Last Modified: 7/11/2001
//
// License: Quoting Nate Maynard,
// "use it however you want. If it helps you out, drop me a line and let me know. :-)"
//
// Disclaimer: This code comes with no warranty of any kind whatsoever. Use at your own risk.
//
/////////////////////////////////////////////////////////////////////////////

//The initial state of m_wHitMask
#define INITIAL_HITMASK LVHT_ONITEMLABEL

class CToolTipListCtrl : public CListCtrl
{
// Construction
public:
CToolTipListCtrl();

// Attributes
public:

protected:
// Map's SubItems to related tooltip text
CMapStringToString m_ToolTipMap;
// A bit mask of LVHT_* flags the control will show tooltips for
WORD m_wHitMask;

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CToolTipListCtrl)
//}}AFX_VIRTUAL

// Implementation
public:


//** CWnd Overrides **
//Provide our own logic for HitTests, specifically, make ToolHitTests respond per SubItem
virtual int OnToolHitTest(CPoint point, TOOLINFO * pTI) const;


//** CTreeCtrl Overrides **
//Overriding the Delete functions makes sure m_ToolTipMap doesn't have excess mappings
virtual BOOL DeleteAllItems( );
virtual BOOL DeleteItem( int nItem );
virtual BOOL SetItemText( int nItem, int nSubItem, LPTSTR lpszText );


//** Additional Functions **

//Set the TVHT_* flags that will trigger the display of a tooltip
WORD SetToolTipHitMask(WORD wHitMask);
//Clear all tooltips
virtual void DeleteAllToolTips();
//Set the tooltip text for a specific SubItem
virtual BOOL SetItemToolTipText( int nItem, int nSubItem, LPCTSTR lpszToolTipText );
//Retrieves the tooltip text for a specific SubItem
virtual CString GetItemToolTipText( int nItem, int nSubItem );


virtual ~CToolTipListCtrl();

// Generated message map functions
protected:
//{{AFX_MSG(CToolTipListCtrl)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG

//Respondes to the TTN_NEEDTEXT* messages, provides the text of a tooltip
virtual afx_msg BOOL OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult );

DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TOOLTIPLISTCTRL_H__EA17BA6D_ADD2_49E3_AB67_45B65316D19F__INCLUDED_)

// ToolTipListCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "ToolTipListCtrl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CToolTipListCtrl

CToolTipListCtrl::CToolTipListCtrl()
{
m_wHitMask = INITIAL_HITMASK;
}

CToolTipListCtrl::~CToolTipListCtrl()
{
// Cleanup when destroyed

DeleteAllToolTips();
}

BEGIN_MESSAGE_MAP(CToolTipListCtrl, CListCtrl)
//{{AFX_MSG_MAP(CToolTipListCtrl)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP

//Trap all TTN_NEEDTEXT* Messages
//TTN_NEEDTEXT* messages are sent when a ToolTipCtrl wants a control
//to provide it with text to display as the tooltip.
//Specifically, when the TOOLINFO structure passed back to the ToolTipCtrl
//after ::OnToolHitTest has it's lpszText memeber set to LPSTR_TEXTCALLBACK.

ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CToolTipListCtrl message handlers

int CToolTipListCtrl::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
{
// See if the point falls onto a list item
//UINT nFlags = 0;

LVHITTESTINFO lvhitTestInfo;

lvhitTestInfo.pt = point;

int nItem = ListView_SubItemHitTest(
this->m_hWnd,
&lvhitTestInfo);
int nSubItem = lvhitTestInfo.iSubItem;

UINT nFlags = lvhitTestInfo.flags;

// nFlags is 0 if the SubItemHitTest fails
// Therefore, 0 & <anything> will equal false
if (nFlags & m_wHitMask)
{
// If it did fall on a list item,
// and it was also hit one of the
// item specific sub-areas we wish to show tool tips for

// Get the client area occupied by this control
RECT rcClient;
GetClientRect( &rcClient );

// Fill in the TOOLINFO structure
pTI->hwnd = m_hWnd;
pTI->uId = (UINT) (nItem * 100 + nSubItem);
pTI->lpszText = LPSTR_TEXTCALLBACK;
pTI->rect = rcClient;

return pTI->uId; // By returning a unique value per listItem,
// we ensure that when the mouse moves over another list item,
// the tooltip will change
}
else
{
// Otherwise, we aren't interested, so let the message propagate
return -1;
}
}

BOOL CToolTipListCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
// Handle both ANSI and UNICODE versions of the message
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;

// Ignore messages from the built in tooltip, we are processing them internally
if( (pNMHDR->idFrom == (UINT)m_hWnd) &&
( ((pNMHDR->code == TTN_NEEDTEXTA) && (pTTTA->uFlags & TTF_IDISHWND)) ||
((pNMHDR->code == TTN_NEEDTEXTW) && (pTTTW->uFlags & TTF_IDISHWND)) ) )
{
return FALSE;
}

*pResult = 0;

CString strTipText;

// Get the mouse position
const MSG* pMessage;
pMessage = GetCurrentMessage();
ASSERT ( pMessage );
CPoint pt;
pt = pMessage->pt; // Get the point from the message
ScreenToClient( &pt ); // Convert the point's coords to be relative to this control

// See if the point falls onto a list item

LVHITTESTINFO lvhitTestInfo;

lvhitTestInfo.pt = pt;

int nItem = SubItemHitTest(&lvhitTestInfo);
int nSubItem = lvhitTestInfo.iSubItem;

UINT nFlags = lvhitTestInfo.flags;

// nFlags is 0 if the SubItemHitTest fails
// Therefore, 0 & <anything> will equal false
if( nFlags & m_wHitMask )
{
// If it did fall on a list item,
// and it was also hit one of the
// item specific sub-areas we wish to show tool tips for

// Lookup the list item's text in the ToolTip Map

CString strKey;

strKey.Format(_T("%d"), nItem * 100 + nSubItem);

if( m_ToolTipMap.Lookup(strKey, strTipText ) )
{
// If there was a CString associated with the list item,
// it's text (up to 80 characters worth, limitation of the TOOLTIPTEXT structure)
// into the TOOLTIPTEXT structure's szText member

// Deal with UNICODE
#ifndef _UNICODE
if (pNMHDR->code == TTN_NEEDTEXTA)
lstrcpyn(pTTTA->szText, strTipText, 80);
else
_mbstowcsz(pTTTW->szText, strTipText, 80);
#else
if (pNMHDR->code == TTN_NEEDTEXTA)
_wcstombsz(pTTTA->szText, strTipText, 80);
else
lstrcpyn(pTTTW->szText, strTipText, 80);
#endif

}
}

return FALSE; // We didn't handle the message,
// let the framework continue propagating the message
}

// Sets the tooltip text for a specific item
BOOL CToolTipListCtrl::SetItemToolTipText( int nItem, int nSubItem, LPCTSTR lpszToolTipText )
{
CString strKey;

strKey.Format(_T("%d"), nItem * 100 + nSubItem);

m_ToolTipMap.SetAt( strKey, lpszToolTipText );

return TRUE;
}

// Retrieve the tooltip text for a specific list item
CString CToolTipListCtrl::GetItemToolTipText( int nItem, int nSubItem )
{
CString itemToolTipText;

CString strKey;

strKey.Format(_T("%d"), nItem * 100 + nSubItem);


if( !m_ToolTipMap.Lookup( strKey, itemToolTipText ) )
{
itemToolTipText = "";
}

return itemToolTipText;
}

WORD CToolTipListCtrl::SetToolTipHitMask( WORD wHitMask )
{
WORD oldHitMask = m_wHitMask;

m_wHitMask = wHitMask;

return oldHitMask;
}

void CToolTipListCtrl::DeleteAllToolTips()
{
m_ToolTipMap.RemoveAll();
}

BOOL CToolTipListCtrl::DeleteAllItems( )
{
// Call the base class method
BOOL retVal = CListCtrl::DeleteAllItems();

if( retVal )
{
// If it succeeded, remove all tooltips
DeleteAllToolTips();
}

return retVal;
}

BOOL CToolTipListCtrl::DeleteItem( int nItem )
{
// Call the base class method
BOOL retVal = CListCtrl::DeleteItem( nItem );

if( retVal )
{

C. java 後台處理 list 為樹HTML源碼

構造treelist的過程可以使用遞歸查詢獲取,表結構如下
create table TB_TREE
(
id NUMBER not null,
name VARCHAR2(50),
parentId NUMBER //父節點
)

Postgre Sql:
select 語句如下,oracle可以用 start with connect by prior實現類似功能
WITH RECURSIVE r AS (
SELECT

D. java裡面的list是干什麼的,具體它是介面如何使用

list就是一個可以任意改變長度的數字
list本身只能作為ArrayList和LinkedList的父類引用使用
List l=new ArrayList();
這樣用

E. 請問ListFilter類里的accept方法怎樣才能實現

public String[] list(FilenameFilter filter) {
String names[] = list();
if ((names == null) || (filter == null)) {
return names;
}
ArrayList v = new ArrayList();
for (int i = 0 ; i < names.length ; i++) {
if (filter.accept(this, names[i])) {
v.add(names[i]);
}
}
return (String[])(v.toArray(new String[v.size()]));
}

看了list方法的源碼就明白了吧,accept方法就是提供一個過濾規則,將無參list()返回的列表信息以此規則進行過濾,accept的兩個參數都是為了定位待檢測的項目,然後通過方法體中的過濾規則返回一個是否排除此項目的boolean值。

F. 大神們,初始化順序表InitList(L)的源碼怎麼寫

/*int InitList(SqList *L)//初始化順序表
{/*L為指向順序表的指針*/
/*L->length = 0;
return 1;//可能出現異常
}*/

G. 誰有站內搜索的源碼,或者是教程。

67194五端源碼及教程網路網盤免費資源在線學習

鏈接: https://pan..com/s/1tahpynYwQ47bqD2mXnj37g

提取碼: q932

67194五端源碼及教程 官方相關廣告圖片 安裝程序及資料庫(無數據版) 火鳥門戶小程序源碼_20190415.zip

火鳥門戶小程序上架流程.doc

火鳥門戶系統 更換域名教程.mp4 後台賬號密碼.txt

安卓APP源碼2019-4-18.7z PC端登錄、支付、郵箱、簡訊教程配置教程.docx

IOSAPP源碼2019-4-18.7z CentOS 7.4 64位 配置寶塔環境,部署火鳥門戶帶演示數據.mp4 APP配置教程.doc

安裝說明.txt hnup_rucheng_pro_20190629_100403.sql.gz 0190629_144441.zip

H. c++ lIst的對象如何保存在文件中

這個問題得研究一下list的源碼,
list本身和list的節點是不同的結構,首先看list的節點結構:
template<class
T>
struct
__list_node{
typedef
void*
void_pointer;
void_pointer
prev;
void_pointer
next;
T
data
}
從這里可以看出,list中用於存儲不同類型的值,如int
或者
float
會影響list的節點的大小。
而list本身的結構如下:
template<class
T>
class
list{
protected:
typedef
__list
node<T>
list_node;
public:
typdefef
__list
node*
link_type;
protected:
link_type
node;//只要一個指針,便可表示整個list
...
}
從這里可以看出,
list中僅僅是保存了一個指向其節點的指針,
所以當對list使用sizeof的時候,
只會計算這個指針的佔用的空間大小,
和整個list所指向的鏈表有多少個節點無關。
也就是說sizeof(list<double>)始終都是同一個值。
如果想知道list中存放了多少個值,可以調用list.size();
至於把list中的內容寫到文件上,可以循環的讀取list中的內容,然後再寫至相應的文件
下面是我寫的一段代碼(VS2005編譯器),樓主可以參考一下:
#include<iostream>
#include<fstream>
#include<iostream>
#include<list>
using
namespace
std;
int
main()
{
fstream
file("test.txt",fstream::out);
list<int>
int_list;
cout<<sizeof(int_list)<<endl;//cout<<24
cout<<int_list.size()<<endl;//cout<<0
for(int
i=0;i<100;i++)
int_list.push_back(i);
cout<<sizeof(int_list)<<endl;//cout<<24
cout<<int_list.size()<<endl;//cout<<100
for(list<int>::const_iterator
it=int_list.begin();it!=int_list.end();it++)
file<<*it<<endl;//cin
to
file
file.clear();
file.close();
}

I. C++ list中存儲不同的類,求源碼,初學者,要能編譯通過的,

懶得寫。。。
做個共有基類,比如:
class object
{
// 能提為共有的就提煉出來
};

使用基類保存就好了,反正子類型基類轉化,直接轉化就好了;
list<object*> test_list;
使用的話,只要你知道第幾個具體是什麼類,你轉換回來就好了。
Student* student = dynamatic_cast<Student*>(test_list_iterator);
Teacher* teacher = dynamatic_cast<Teacher*>(test_list_iterator);

閱讀全文

與list源碼教程相關的資料

熱點內容
噴油螺桿製冷壓縮機 瀏覽:579
python員工信息登記表 瀏覽:377
高中美術pdf 瀏覽:161
java實現排列 瀏覽:513
javavector的用法 瀏覽:982
osi實現加密的三層 瀏覽:233
大眾寶來原廠中控如何安裝app 瀏覽:916
linux內核根文件系統 瀏覽:243
3d的命令面板不見了 瀏覽:526
武漢理工大學伺服器ip地址 瀏覽:149
亞馬遜雲伺服器登錄 瀏覽:525
安卓手機如何進行文件處理 瀏覽:71
mysql執行系統命令 瀏覽:930
php支持curlhttps 瀏覽:143
新預演算法責任 瀏覽:444
伺服器如何處理5萬人同時在線 瀏覽:251
哈夫曼編碼數據壓縮 瀏覽:426
鎖定伺服器是什麼意思 瀏覽:385
場景檢測演算法 瀏覽:617
解壓手機軟體觸屏 瀏覽:350