目前共有7篇帖子。 內容轉換:不轉換▼
 
點擊 回復
543 6
【八爪鱼函数库】VC6常用函数库
一派護法 十九級
1樓 發表于:2013-1-26 15:44

//删去字符串两端的空格

void Trim(CString* str)
{
 str->TrimLeft();
 str->TrimRight();
}

//删去两端空格后,判断一个字符串是否为空

bool IsEmpty(CString* str)
{
 Trim(str);
 if (str->IsEmpty())
  return true;
 else
  return false;
}

 

//根据一个字符串(各项用回车隔开)显示列表框

void DisplayComboItems(CComboBox* ctrl,CString str)
{
 int pos[2]={0,0};
 while (true)
 {
  pos[1]=str.Find('\n',pos[0]);
  if (pos[1]==-1)
  {
   ctrl->AddString(str.Right(str.GetLength()-pos[0]));
   break; //如果已到字符串末尾,就停止
  }
  ctrl->AddString(str.Left(pos[1]).Right(pos[1]-pos[0]));
  pos[0]=pos[1]+1;
 }
}

一派護法 十九級
2樓 發表于:2013-1-26 15:45

//下面是有关ListControl的函数

//获取选中行(只获取第一行)
int GetListCtrlSelect(CListCtrl* ctrl)
{
 POSITION pos=ctrl->GetFirstSelectedItemPosition();
 if (pos==NULL)
  return -1;
 else
  return ctrl->GetNextSelectedItem(pos);
}
//选中一行
void SetListCtrlSelect(CListCtrl* ctrl,int pos)
{
 ctrl->SetItemState(pos,LVNI_SELECTED,LVNI_SELECTED);
}
//检测某个字符串是否存在
bool ListCtrlExists(CListCtrl* ctrl,CString str,int subitem)
{
 int count=ctrl->GetItemCount(); //获取总数
 for (int i=0;i<count;i++)
 {
  CString str2=ctrl->GetItemText(i,subitem);
  if (str2==str)
   return true;
 }
 return false;
}

一派護法 十九級
3樓 發表于:2013-1-26 15:46
//字符串拆分成数组(分隔符长度必须为1)
void StringExplode(CString str,CString symbol,CArray<CString,CString>* array)
{
 int pos[2]={0,0};
 while (true)
 {
  pos[1]=str.Find(symbol,pos[0]);
  if (pos[1]==-1)
  {
   array->Add(str.Right(str.GetLength()-pos[0]));
   break; //如果已到字符串末尾,就停止
  }
  array->Add(str.Left(pos[1]).Right(pos[1]-pos[0]));
  pos[0]=pos[1]+1;
 }
}
一派護法 十九級
4樓 發表于:2013-1-26 15:46

//这个函数用来设置鼠标是否带一个沙漏

void SetCursorState(BOOL running)
{
 LPCTSTR lpCursorName=(running)?IDC_APPSTARTING:IDC_ARROW;
 HCURSOR hCur=LoadCursor(NULL,lpCursorName);
 SetCursor(hCur);
}

一派護法 十九級
5樓 發表于:2013-1-26 15:47

//消息框哈苏,content和title都是字符串表中的id

int STRTBBox(HWND wnd,int content,int title,unsigned int style)
{
 CString s1,s2;
 s1.LoadString(content);
 s2.LoadString(title);
 return MessageBox(wnd,s1,s2,style);
}

一派護法 十九級
6樓 發表于:2013-1-26 15:49

//显示一个数字的消息框(通常用于调试)
void NumberBox(int num)
{
 CString str;
 str.Format("%d",num);
 AfxMessageBox(str);
}

 

//获取ListCtrl某一项的图标

int GetListCtrlIcon(CListCtrl* ctrl, int id)
{
 LVITEM lvi;
 lvi.iItem=id;
 lvi.iSubItem=0;
 lvi.mask=LVIF_IMAGE;
 ctrl->GetItem(&lvi);
 return lvi.iImage;
}

 

//设置ListCtrl风格

void SetListCtrlStyle(CListCtrl* ctrl, int id)
{
 HWND hWnd=ctrl->GetSafeHwnd();
 DWORD dwOldStyle=GetWindowLong(hWnd,GWL_STYLE);
 DWORD dwNewStyle=lvs[id];
 if ((dwOldStyle&LVS_TYPEMASK)!=dwNewStyle)
 {
  dwOldStyle&=~LVS_TYPEMASK;
  dwNewStyle|=dwOldStyle;
  SetWindowLong(hWnd,GWL_STYLE,dwNewStyle);
 }

 

//获取ListCtrl风格

int GetListCtrlStyle(CListCtrl* ctrl)
{
 HWND hWnd=ctrl->GetSafeHwnd();
 DWORD dwOldStyle=GetWindowLong(hWnd,GWL_STYLE);
 dwOldStyle&=LVS_TYPEMASK;
 for (int i=0;i<4;i++)
 {
  if (dwOldStyle==lvs[i])
   return i;
 }
 return -1;
}
}

一派護法 十九級
7樓 發表于:2013-1-26 15:53

//根据id获取StringTable中的字符串

CString GetStr(int id)
{
 CString str;
 str.LoadString(id);
 return str;
}

//★载入一个DLL文件中的图标

HICON LoadIconFromDLL(int id, CString filename)
{
 HINSTANCE hInstance=::LoadLibrary(filename);
 HICON hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(id));
 return hIcon;
}

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
(快捷鍵:Ctrl+Enter)
 

本帖信息

點擊數:543 回複數:6
評論數: ?
作者:巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2013-1-26 15:53
 
©2010-2024 Arslanbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。