VC用的一些小片段(不定期更新)

來源:互聯網
上載者:User

1.開啟指定的檔案夾
CString str=_T("D://");
ShellExecute(NULL,"open","explorer",str,"",SW_SHOW);

2.基於對話方塊的MFC程式不用Accelerator處理鍵盤事件
    方法是重寫基類CDialog的PreTranslateMessage方法
    ①在標頭檔中聲明public: BOOL PreTranslateMessage(MSG *pMsg);
    ②在cpp檔案中如下樣本
    BOOL CFaqTestDlg::PreTranslateMessage(MSG *pMsg)
{
 if(pMsg->message==WM_KEYDOWN)
 {
  switch(pMsg->wParam)
  {
  case VK_INSERT:
   MessageBox("Insert");
   break;
  case VK_DELETE:
   MessageBox("Delete");
   break;
  default:
   MessageBox(_T("Other"));
  }
 }
 return CDialog::PreTranslateMessage(pMsg);
}

3.VS2005中如何給自訂類添加虛擬方法

在Visual Studio 6中,在類別檢視下有一個很好的特點,你可以右擊一個類,在彈出的菜單中選擇"添加虛方法"以重寫基類的某些方法,而這一特點在VS2005花了我很長時間才找到,它在VS2005中如下操作:在類別檢視中右鍵你的子類->屬性->選擇頂部的"重載"選項卡.

------------------------------------------------------------------------------
出售小型機,工作站,伺服器 電話:010-51280889轉1007,MSN:wanglinan1121@hotmail.com

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.