类CList支持可按顺序或按值访问的非唯一对象的有序列表。CList 列表与双链接列表行为相似。
例子:
一、添加:1、SINGERLISTDETAIL singerdetail;
for(;;)
{ MainDlg->cls_kodLogic->InsertBatchSingerItem( singerdetail ); }
2、void KodLogic::InsertBatchSingerItem(SINGERLISTDETAIL item)
{
cls_KodData->InsertBatchSingerItem( item );
}
3、void KodData::InsertBatchSingerItem(SINGERLISTDETAIL item)
{
m_RowBatchSingerList.AddTail( item );//AddTail 添加一个新元素或元素列表到此列表的标
//题后面。操作前此列表可能为空。
}
(声明:CList<SINGERLISTDETAIL, SINGERLISTDETAIL&>m_RowBatchSingerList; (#include<afxtempl.h>))
二、此数据的提取:1、for( ; ; )
{ singerdetail = MainDlg->cls_kodLogic->GetBatchArtistItem(i); }
2、SINGERLISTDETAIL KodLogic::GetBatchArtistItem(int index)
{
POSITION pos;
CList<SINGERLISTDETAIL, SINGERLISTDETAIL&> *RowArtistList;
SINGERLISTDETAIL artistdetail;
RowArtistList = GetRowBatchSingerList();
pos = RowArtistList->FindIndex( index );// 使用nIndex值作为列表索引。它从
//头开始顺序扫描,停止于第几个元素。
artistdetail = RowArtistList->GetAt(pos);
return artistdetail;
}
加 CList<SINGERLISTDETAIL, SINGERLISTDETAIL&>*KodLogic::GetRowBatchSingerList()
{
return cls_KodData->GetRowBatchSingerList();
}
3、CList<SINGERLISTDETAIL, SINGERLISTDETAIL&>* KodData::GetRowBatchSingerList()
{
return &m_RowBatchSingerList;
}
//2、 通过序号获取歌星记录
bool KodLogic::GetSingerItem(CString singerid, SINGERLISTDETAIL& outputsingerdetail)
{
CList<SINGERLISTDETAIL, SINGERLISTDETAIL&> *RowSingerList;
RowSingerList = GetRowSingerList();
int itemcnt = RowSingerList->GetCount();
POSITION pos = RowSingerList->GetHeadPosition();
SINGERLISTDETAIL singerdetail;
for( int i=0; i<itemcnt; i++ )
{
singerdetail = RowSingerList->GetAt(pos);
if( 0 == strcmp( singerdetail.Singerid, singerid ) )
{
outputsingerdetail = singerdetail;
return true;
}
RowSingerList->GetNext(pos);
}
return false;
}
三、清空此列表数据:1、MainDlg->cls_kodLogic->DeleteBatchArtistAllItem();
2、void KodLogic::DeleteBatchArtistAllItem(void)
{
cls_KodData->DeleteBatchAirtistAllItem();
}
3、void KodData::DeleteBatchAirtistAllItem(void)
{
m_RowBatchSingerList.RemoveAll();//RemoveAll从此列表中删除所有元素并释放
//相关的内存。如果列表已经是空的,则不会出错。
}
最后的结构体typedef struct SINGERLISTDETAIL{
CString Singerid;
CString SingerInitials;
CString SingerNumber;
CString SingerName;
CString SingerSex;
CString SingerPlace;
bool HavePic;
CString ListFileIndex;
CString PicPath;
#ifdef ACE1100
CString SingerPlaceAndSex;
#endif
}SINGERLISTDETAIL;
完!
int = atoi( CString ) CSting.Format( “%d”, int )
修改窗口属性
说明:
以下函数对于POPUP窗口有效,对于子窗口好像不行。
//最小化按钮有效
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) | WS_MINIMIZEBOX );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//最小化按钮无效
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) &~WS_MINIMIZEBOX );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//最大化按钮有效
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) | WS_MAXIMIZEBOX );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//最大化按钮无效
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) &~WS_MAXIMIZEBOX );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//关闭按钮有效
::EnableMenuItem(::GetSystemMenu(m_hWnd,false),SC_CLOSE,MF_BYCOMMAND | MF_GRAYED);
//关闭按钮无效
::EnableMenuItem(::GetSystemMenu(m_hWnd,false),SC_CLOSE,MF_BYCOMMAND | MF_ENABLED);
//工具栏窗口。在任务栏上没有程序显示,需要添加在OnInitDialog()里
::SetWindowLong(m_hWnd,GWL_EXSTYLE,GetWindowLong(m_hWnd,GWL_EXSTYLE)
&~WS_EX_APPWINDOW|WS_EX_TOOLWINDOW );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
//添加标题栏
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)
| WS_CAPTION );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//取消标题栏
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)
& ~WS_CAPTION );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//取消标题栏,保留3d边框,可调整窗口大小
::SetWindowLong(m_hWnd,GWL_STYLE, GetWindowLong(m_hWnd,GWL_STYLE)
& ~WS_CAPTION | WS_THICKFRAME );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); //一定要加这句设置才会立即生效
//取消标题栏和3d边框,保留一个线条的细边框,不能调整窗口大小
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)
& ~WS_CAPTION & ~WS_THICKFRAME | WS_BORDER );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//如果有WS_EX_DLGMODALFRAME还要取消WS_EX_DLGMODALFRAME
// ::SetWindowLong(m_hWnd,GWL_EXSTYLE,GetWindowLong(m_hWnd,GWL_EXSTYLE)
// & ~WS_EX_DLGMODALFRAME);
// ::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
//取消所有边框
::SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE)
& ~WS_CAPTION & ~WS_THICKFRAME );
::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
// //如果有WS_EX_DLGMODALFRAME还要取消WS_EX_DLGMODALFRAME
// ::SetWindowLong(m_hWnd,GWL_EXSTYLE,GetWindowLong(m_hWnd,GWL_EXSTYLE)
// & ~WS_EX_DLGMODALFRAME);
// ::SetWindowPos(m_hWnd,NULL,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);