home *** CD-ROM | disk | FTP | other *** search
/ ftp.funduc.com / 2014.08.ftp.funduc.com.tar / ftp.funduc.com / fshedcode-072212.zip / PasteSpecialDlg.cpp < prev    next >
C/C++ Source or Header  |  2010-09-13  |  3KB  |  93 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //    License (GPLv2+):
  3. //    This program is free software; you can redistribute it and/or modify
  4. //    it under the terms of the GNU General Public License as published by
  5. //    the Free Software Foundation; either version 2 of the License, or
  6. //    (at your option) any later version.
  7. //
  8. //    This program is distributed in the hope that it will be useful, but
  9. //    WITHOUT ANY WARRANTY; without even the implied warranty of
  10. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11. //    General Public License for more details.
  12. //
  13. //    You should have received a copy of the GNU General Public License
  14. //    along with this program; if not, write to the Free Software
  15. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. /////////////////////////////////////////////////////////////////////////////
  17.  
  18. #include "stdafx.h"
  19. #include "fshed.h"
  20. #include "PasteSpecialDlg.h"
  21.  
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CPasteSpecialDlg dialog
  30.  
  31.  
  32. CPasteSpecialDlg::CPasteSpecialDlg(CWnd* pParent /*=NULL*/)
  33.     : CDialog(CPasteSpecialDlg::IDD, pParent)
  34. {
  35.     //{{AFX_DATA_INIT(CPasteSpecialDlg)
  36.     m_strClipText = _T("");
  37.     m_nNumTimes = 1;
  38.     m_nInsertMode = 1;
  39.     m_nSkipBytes = 0;
  40.     m_bPasteAsText = TRUE;
  41.     //}}AFX_DATA_INIT
  42. }
  43.  
  44.  
  45. void CPasteSpecialDlg::DoDataExchange(CDataExchange* pDX)
  46. {
  47.     CDialog::DoDataExchange(pDX);
  48.     //{{AFX_DATA_MAP(CPasteSpecialDlg)
  49.     DDX_Text(pDX, IDC_CLIP_TEXT_ED, m_strClipText);
  50.     DDX_Text(pDX, IDC_NUM_TIMES_ED, m_nNumTimes);
  51.     DDV_MinMaxInt(pDX, m_nNumTimes, 1, 1000000);
  52.     DDX_Radio(pDX, IDC_OVERWRITE_RB, m_nInsertMode);
  53.     DDX_Text(pDX, IDC_SKIP_BYTES_ED, m_nSkipBytes);
  54.     DDV_MinMaxInt(pDX, m_nSkipBytes, 0, 1000000);
  55.     DDX_Check(pDX, IDC_AS_TEXT_CHK, m_bPasteAsText);
  56.     //}}AFX_DATA_MAP
  57. }
  58.  
  59.  
  60. BEGIN_MESSAGE_MAP(CPasteSpecialDlg, CDialog)
  61.     //{{AFX_MSG_MAP(CPasteSpecialDlg)
  62.     //}}AFX_MSG_MAP
  63. END_MESSAGE_MAP()
  64.  
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CPasteSpecialDlg message handlers
  67.  
  68. BOOL CPasteSpecialDlg::OnInitDialog() 
  69. {
  70.     if (OpenClipboard())
  71.     {
  72.         HGLOBAL hClipMemory = GetClipboardData (CF_UNICODETEXT);
  73.         if (hClipMemory != NULL)
  74.         {
  75.             int gsize = (int)GlobalSize(hClipMemory);
  76.             if (gsize > 0)
  77.             {
  78.                 TCHAR* pClipMemory = (TCHAR*) GlobalLock (hClipMemory);
  79.                 memcpy (m_strClipText.GetBuffer(gsize), pClipMemory, gsize * sizeof(TCHAR));
  80.                 m_strClipText.ReleaseBuffer(gsize);
  81.             }
  82.             GlobalUnlock (hClipMemory);
  83.         }
  84.         CloseClipboard ();
  85.     }
  86.     CDialog::OnInitDialog();
  87.     
  88.     // TODO: Add extra initialization here
  89.     
  90.     return TRUE;  // return TRUE unless you set the focus to a control
  91.                   // EXCEPTION: OCX Property Pages should return FALSE
  92. }
  93.