VC如何?托拽

來源:互聯網
上載者:User

從程式外面,托動一個檔案到應用程式介面,如何得到這個檔案的路徑並且激發一個處理訊息?  
   
  另外,已經知道一個大字串,現在要統計裡面某一個字母的個數,如何統計?如果用While迴圈的話,要1分種,不現實,有沒有什麼速度快一點的方法?  
   
  謝謝 問題點數:50、回複次數:9Top

1 樓DentistryDoctor(不在無聊中無奈,就在沉默中變態)回複於 2006-09-07 14:42:52 得分 15

1.An   application   that   calls   DragAcceptFiles   with   the   fAccept   parameter   set   to   TRUE   has   identified   itself   as   able   to   process   the   WM_DROPFILES   message   from   File   Manager.    
  在視窗建立時調用DragAcceptFiles(TRUE);然後程式處理WM_DROPFILE訊息  
  2.迴圈要一秒鐘,什麼字串這麼大?CString.Find?Top

2 樓SoLike(思危)回複於 2006-09-07 14:43:00 得分 0

在視窗中響應   WM_DROPFILES   訊息Top

3 樓baojian88888(機器人)回複於 2006-09-07 14:45:15 得分 5

拖檔案:  
  先給視窗設定WS_EX_ACCEPTFILES風格,然後處理   WM_DROPFILES   訊息Top

4 樓SoLike(思危)回複於 2006-09-07 14:45:20 得分 20

Dragging   Files  
   
  Dragging   Files   can   be   supported   relatively   easily   as   follows  
   
                  *   Add   a   OnDropFiles(HDROP   hDropInfo)   handler   to   your   Dialog.   You'll   probably   have   to   add   this   manually,   as   ClassWizard   doesn't   seen   to   support   the   WM_DROPFILES   message   for   dialogs.  
   
          Make   the   following   changes  
   
  1)   In   your   .h   file   add   the   OnDropFiles   to   the   AFX_MSG   section  
   
                                  //   Generated   message   map   functions  
                                  //{{AFX_MSG(A2hDialog)  
                                  ...  
                                  afx_msg   void   OnDropFiles(HDROP   hDropInfo);  
                                  ...  
                                  //}}AFX_MSG  
                                  DECLARE_MESSAGE_MAP()  
   
   
          2)   In   your   .cpp   file   add   the   ON_WM_DROPFILES()   handler   to   the   AFX_MSG_MAP   section  
   
                                  BEGIN_MESSAGE_MAP(MyDialog,   CDialog)  
                                          //{{AFX_MSG_MAP(MyDialog)  
                                          ...  
                                          ON_WM_DROPFILES()  
                                          ...  
                                          //}}AFX_MSG_MAP  
                                  END_MESSAGE_MAP()  
   
   
                  Strangely,   after   doing   (1)   and   (2)   the   results   become   visible   in   the   ClassWizard.  
   
          3)  
                  Use   ClassWizard   to   add   an   OnCreate()   handler   to   your   dialog.   in   this   add   the   call    
   
                                  this->DragAcceptFiles(TRUE);  
   
                  This   enables   Drag   and   drop   of   files   on   your   Dialog's   window.   You   can   check   this   by   dragging   files   over   your   Window.   If   the   cursor   is   a   "no   entry"   sign   (circle   with   a   line   through   it)   it's   not   working.   If   the   cursor   changes   to   a   file/folder   icon   with   a   "+"   on   it,   you're   in   business.    
   
          4)   Manually   add   the   OnDropFiles   method   to   look   something   as   follows   :-  
   
  void   MyDialog::OnDropFiles(HDROP   hDropInfo)  
  {  
   
          HDROP   m_hDropInfo   =   hDropInfo;  
          CString   Filename;  
   
          if   (m_hDropInfo)   {  
   
                  int   iFiles   =   DragQueryFile(m_hDropInfo,   (UINT)-1,   NULL,   0);  
   
                  for   (int   i=0;   i<ifiles;   i++)   {  
   
                          char*   pFilename   =   Filename.GetBuffer(_MAX_PATH);  
                          DragQueryFile(m_hDropInfo,   i,   pFilename,   _MAX_PATH);  
   
                          //   do   whatever...  
   
                  }       //   for   each   files...  
          }               //   if   DropInfo  
   
          DragFinish(m_hDropInfo);  
   
          m_hDropInfo   =   0;  
   
  }       //   End   of   OnDropFiles  
   
  Top

5 樓dch4890164(巴拉克)回複於 2006-09-07 14:45:32 得分 0

樓上兩位正確,評鑑完畢,飄過!Top

6 樓kilojin(梅子黃時雨,我在編程時)回複於 2006-09-07 14:47:42 得分 0

一個Log檔案,大約10M,現在要統計裡面某一個類別Log的數量,LogKey是有的,不過,太多,Find   迴圈統計,要很長時間  
  我記得Ultraedit裡面,有這個功能,一下子就統計出來了,不知道如何?的  
  Top

7 樓Mackz(在相互)回複於 2006-09-07 16:40:10 得分 5

主要的時間應該在讀取檔案上了,映射一下。比較必需要迴圈的,提高效率的方法是在尋找上,比如模式比對。Top

8 樓codewarrior(會思考的草)回複於 2006-09-07 16:59:23 得分 5

關於拖動可以看我的blog.  
  速度快主要是要最佳化演算法,使用對應檔可能會好一點.Top

9 樓immc1979(毛毛蟲)回複於 2006-12-06 14:09:31 得分 0

標記一個 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.