strtok()--SelectItem--HitTest

 strtok()

功能:查找由在第二个串中指定的分界符分隔开的单词    
  例子:  
      Ex1.   strtok("0736-8888888","-");     返回字符串   "0736"  
      Ex2.   strtok("0736-8888888","6-");   返回字符串   "073"  
      Ex3.   strtok("0736-8888888","&");     返回字符串   "NULL"  

首先看下MSDN上的解释:

char *strtok( char *strToken, const char *strDelimit );

Parameters
strToken
String containing token or tokens.
strDelimit
Set of delimiter characters.
Return Value
Returns a pointer to the next token found in strToken. They return NULL when no more tokens are found. Each call modifies strToken by substituting a NULL character for each delimiter that is encountered.

简单的说,就是函数返回第一个分隔符分隔的子串后,将第一参数设置为NULL,函数将返回剩下的子串。

下面我们来看一个例子:

int main()
{
      char test1[] = "feng,ke,wei"; 
      char *test2 = "feng,ke,wei"; 
      char *p; 
      p = strtok(test1, ",");
      while(p) 
          {  
              printf("%s\n", p);  
              p = strtok(NULL, ",");    
          }     
      return 0;
 }
运行结果:

feng

ke

wei

----------------------------------

CTreeCtrl::SelectItem

Call this function to select the given tree view item.

BOOL SelectItem( HTREEITEM hItem );

Parameters
hItem

Handle of a tree item.

Return Value---Nonzero if successful; otherwise 0.

Remarks---If hItem is NULL, then this function selects no item.

Example

// The pointer to my tree control.
extern CTreeCtrl* pmyTreeCtrl;
// The point to test.
extern CPoint myPoint;

// Select the item that is at the point myPoint.
UINT uFlags;
HTREEITEM hItem = pmyTreeCtrl->HitTest(myPoint, &uFlags);

if ((hItem != NULL) && (TVHT_ONITEM & uFlags))
{
   pmyTreeCtrl->SelectItem(hItem);
}

-------------------------------------------

CTreeCtrl::HitTest

Call this function to determine the location of the specified point relative to the client area of a tree view control.

HTREEITEM HitTest(

 CPoint pt,

UINT* pFlags = NULL

) const;

HTREEITEM HitTest(

TVHITTESTINFO* pHitTestInfo

) const;

 

Parameters

pt

Client coordinates of the point to test.

pFlags

Pointer to an integer that receives information about the results of the hit test. It can be one or more of the values listed under the flags member in the Remarks section.

pHitTestInfo

Address of a TVHITTESTINFO structure that contains the position to hit test and that receives information about the results of the hit test.

Return Value---The handle of the tree view item that occupies the specified point or NULL if no item occupies the point.

Remarks---When this function is called, the pt parameter specifies the coordinates of the point to test. The function returns the handle of the item at the specified point or NULL if no item occupies the point. In addition, the pFlags parameter contains a value that indicates the location of the specified point.

Example

// The pointer to my tree control.
extern CTreeCtrl* pmyTreeCtrl;
// The point to test.
extern CPoint myPoint;

// Select the item that is at the point myPoint.
UINT uFlags;
HTREEITEM hItem = pmyTreeCtrl->HitTest(myPoint, &uFlags);

if ((hItem != NULL) && (TVHT_ONITEM & uFlags))
{
   pmyTreeCtrl->Select(hItem, TVGN_CARET);
}

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值