home *** CD-ROM | disk | FTP | other *** search
/ PC Administrator / spravce.iso / RunModule / src / ComboCommand.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-08-31  |  3.4 KB  |  86 lines

  1. // ComboCommand.cpp: implementation of the CComboCommand class.
  2. //
  3. /*
  4. Copyright 2001 Anish Mistry. All rights reserved.
  5.  
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8.  
  9.    1. Redistributions of source code must retain the above copyright notice, 
  10.    this list of conditions and the following disclaimer.
  11.    2. Redistributions in binary form must reproduce the above copyright notice,
  12.    this list of conditions and the following disclaimer in the documentation 
  13.    and/or other materials provided with the distribution.
  14.  
  15. THIS SOFTWARE IS PROVIDED BY ANISH MISTRY ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  16. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
  17. AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS 
  18. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  19. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  20. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  21. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  22. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24.  
  25. The views and conclusions contained in the software and documentation are those
  26. of the authors and should not be interpreted as representing official policies,
  27. either expressed or implied, of Anish Mistry or AM Productions.
  28.  
  29. * Variation of the FreeBSD License. http://www.freebsd.org/copyright/freebsd-license.html
  30. */
  31. //////////////////////////////////////////////////////////////////////
  32.  
  33. #include "stdafx.h"
  34. #include "ComboCommand.h"
  35.  
  36. //////////////////////////////////////////////////////////////////////
  37. // Construction/Destruction
  38. //////////////////////////////////////////////////////////////////////
  39.  
  40. CComboCommand::CComboCommand()
  41. {
  42.  
  43. }
  44.  
  45. CComboCommand::~CComboCommand()
  46. {
  47.  
  48. }
  49.  
  50. LRESULT CComboCommand::WndProc(HWND hWnd,UINT nMessage,WPARAM wParam,LPARAM lParam)
  51. {// begin WndProc
  52.     switch(nMessage)
  53.     {// begin nMessage switch
  54.     case WM_DROPFILES:
  55.         OnDropFiles(wParam,lParam);
  56.         break;
  57.     }// end nMessage swtich
  58.     return CComboAutoComplete::WndProc(hWnd, nMessage, wParam, lParam);
  59. }// end WndProc
  60.  
  61. void CComboCommand::OnDropFiles(WPARAM wParam,LPARAM lParam)
  62. {// begin OnDropFiles
  63.     HWND hWnd = GetParent(m_hWnd);
  64.     HDROP hDropInfo = (HDROP) wParam;
  65.     // Get the number of bytes required by the file's full pathname
  66.     int nFiles = DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,NULL);
  67.     // get the string in the edit field
  68.     char pBuffer[MAX_PATH] = {NULL};
  69.     GetDlgItemText(hWnd,IDC_COMBO_RUN,pBuffer,MAX_PATH-1);
  70.  
  71.     for(;nFiles > 0;nFiles--)
  72.     {// begin add the file to the edit field
  73.         UINT wPathnameSize = DragQueryFile(hDropInfo, nFiles-1, NULL, 0);
  74.         // Allocate memory to contain full pathname & zero byte
  75.         char * npszFile = (char *) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, wPathnameSize += 1);
  76.         // Copy the pathname into the buffer
  77.         DragQueryFile(hDropInfo, nFiles-1, npszFile, wPathnameSize);
  78.         lstrcat(pBuffer,npszFile);
  79.         // clean up
  80.         HeapFree(GetProcessHeap(),NULL,npszFile);
  81.     }// end add the file to the edit field
  82.  
  83.     // set the text back to the edit field
  84.     SetDlgItemText(hWnd,IDC_COMBO_RUN,pBuffer);
  85. }// end OnDropFiles
  86.