欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
CToolTipCtrl使用詳細解說(shuō) - zhoubl668的專(zhuān)欄:遠帆,夢(mèng)之帆! - C...

ToolTip是Win32中一個(gè)通用控件,MFC中為其生成了一個(gè)類(lèi)CToolTipCtrl,總的說(shuō)來(lái)其使用方法是較簡(jiǎn)單的,下面講一下它的一般用法和高級用法。

一般用法步驟:
1. 添加CToolTipCtrl成員變量 m_tt。
2. 在父窗口中調用EnableToolTips(TRUE);
3. 在窗口的OnCreate(或者其他適當的位置)中向ToolTip中添加需要顯示Tip的子窗口,并同時(shí)指定相應的顯示字串CToolTipCtrl::AddTool(pWnd,”string to display”)。
4. 重載父窗口的 BOOL PreTranslateMessage(MSG* pMsg) ,在函數中調用 m_tt.RelayEvent(pMsg)。

下面假設在窗口CWndYour中使用CToolTipCtrl

在類(lèi)定義中添加變量說(shuō)明:

  1. class CWndYour:xxx
  2. {
  3.  CToolTipCtrl m_tt;
  4. }

在OnCreate中添加需要顯示Tip的子窗口

  1. CWndYour::OnCreate(....)
  2. {
  3.  EnableToolTips(TRUE);
  4.  m_tt.Create(this);
  5.  m_tt.Activate(TRUE);
  6.  
  7.  CWnd* pW=GetDlgItem(IDC_CHECK1);//得到窗口指針
  8.  m_tt.AddTool(pW,"Check1"); //添加
  9. }

在BOOL PreTranslateMessage(MSG* pMsg)中添加代碼

  1. BOOL CWndYour::PreTranslateMessage(MSG* pMsg)
  2. {
  3.  {
  4.   m_tt.RelayEvent(pMsg);
  5.  }
  6.  return CParentClass::PreTranslateMessage(pMsg);
  7. }

這樣當鼠標移動(dòng)到相應的子窗口上時(shí)會(huì )顯示出相應的ToolTip。

動(dòng)態(tài)改變ToolTip的顯示內容的方法及步驟:

1.上面所講的1、2、4步驟。
2.在增加ToolTip時(shí)不指定顯示的字串,而是使用LPSTR_TEXTCALLBACK。
3.在窗口中增加消息映射 ON_NOTIFY_EX( TTN_NEEDTEXT, 0, SetTipText )。
4.在窗口中增加一個(gè)函數用于動(dòng)態(tài)提供顯示內容,其原型為 BOOL SetTipText( UINT id, NMHDR * pTTTStruct, LRESULT * pResult ),下面的代碼可以根據傳入的參數判定應該顯示的內容。

  1. BOOL CWndYour::SetTipText( UINT id, NMHDR * pTTTStruct, LRESULT * pResult )
  2. {
  3.  TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pTTTStruct;   
  4.  UINT nID =pTTTStruct->idFrom; //得到相應窗口ID,有可能是HWND
  5.  if (pTTT->uFlags & TTF_IDISHWND)    //表明nID是否為HWND
  6.  {
  7.   nID = ::GetDlgCtrlID((HWND)nID);//從HWND得到ID值,當然你也可以通過(guò)HWND值來(lái)判斷
  8.   switch(nID)
  9.   case(IDC_YOUR_CONTROL1)       
  10.    strcpy(pTTT->lpszText,your_string1);//設置
  11.    return TRUE;
  12.   break;
  13.   case(IDC_YOUR_CONTROL2)   //設置相應的顯示字串
  14.    return TRUE;
  15.   break;
  16.  }
  17.  return(FALSE);
  18. }

作者: 聞怡洋 wyy_cq@188.net
原文: http://hi.baidu.com/fateyeah/blog/item/fc7c07b37ab250a7d9335aa7.html

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

如何操縱CToolTipCtrl來(lái)給自己的控件添加tool tip呢?MSDN給出了答案。

創(chuàng )建并操縱一個(gè)CToolTipCtrl
創(chuàng )建一個(gè)CToolTipCtrl的對象.

調用Create函數來(lái)創(chuàng )建windows通用提示控件并使之與CToolTipCtrl對象產(chǎn)生關(guān)聯(lián)。

調用AddTool函數來(lái)把tool tip control注冊到一個(gè)tool上,這樣存儲在tool tip中的信息就能在光標懸浮在這個(gè)tool上的時(shí)候顯示出來(lái)。

調用SetToolInfo來(lái)設置tool tip為這個(gè)tool所保留的信息。

調用SetToolRect來(lái)設置該tol的一個(gè)新的范圍矩形。

調用HitTest函數來(lái)判斷一個(gè)點(diǎn)是否在某個(gè)給定tool的范圍矩形之內,如果是的話(huà),就返回這個(gè)tool的信息。

調用GetToolCount來(lái)得到一個(gè)tool tip所關(guān)聯(lián)到的tool的個(gè)數。

// Create and associate a tooltip control to the tab control of
// CMyPropertySheet.  CMyPropertySheet is a CPropertySheet-derived
// class.
BOOL CMyPropertySheet::OnInitDialog()
...{
   BOOL bResult = CPropertySheet::OnInitDialog();
  
   // Create a tooltip control.  m_ToolTipCtrl is a member variable
   // of type CToolTipCtrl* in CMyPropertySheet class.  It is
   // initialized to NULL in the constructor, and destroyed in the
   // destructor of CMyPropertySheet class.
   m_ToolTipCtrl = new CToolTipCtrl;// 第一步,創(chuàng )建對象
   if (!m_ToolTipCtrl->Create(this)) //第二步,調用Create函數
   ...{
      TRACE("Unable To create ToolTip ");          
      return bResult;
   }

   // Associate the tooltip control to the tab control
   // of CMyPropertySheet.
   CTabCtrl* tab = GetTabControl();
   tab->SetToolTips(m_ToolTipCtrl);
   // Get the bounding rectangle of each tab in the tab control of the
   // property sheet. Use this rectangle when registering a tool with
   // the tool tip control.  IDS_FIRST_TOOLTIP is the first ID string
   // resource that contains the text for the tool.
   int count = tab->GetItemCount();
   int id = IDS_FIRST_TOOLTIP;
   for (int i = 0; i < count; i++)
   ...{
      id += i;
      CRect r;
      tab->GetItemRect(i, &r);
      VERIFY(m_ToolTipCtrl->AddTool(tab, id, &r, id));
   }

   // Activate the tooltip control.
   m_ToolTipCtrl->Activate(TRUE);

   return bResult;
}

// Override PreTranslateMessage() so RelayEvent() can be
// called to pass a mouse message to CMyPropertySheet's
// tooltip control for processing.
BOOL CMyPropertySheet::PreTranslateMessage(MSG* pMsg)
...{
   if (NULL != m_ToolTipCtrl)           
      m_ToolTipCtrl->RelayEvent(pMsg);
  
   return CPropertySheet::PreTranslateMessage(pMsg);
}

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
在VisualC++中建立MFC擴展DLL
在控件中點(diǎn)確認鍵窗口消失處理重寫(xiě)PreTranslateMessage
vc技巧????-轉載
MFC限制Edit控件只輸入數字、小數點(diǎn)及失去焦點(diǎn)
用回車(chē)鍵實(shí)現MFC對話(huà)框中TAB鍵控件輸入焦點(diǎn)在控件中跳轉的效果
【轉】VC/MFC 鍵盤(pán)消息的截取與響應
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久