void CDKText32View::OnEditCopy() 
{
   int idx,   len;
   HGLOBAL    hglbCopy;
   LPVOID     lockPtr;
   const char *msg;
   
   // haleyjd: implement the copy command

   // a message must be selected to copy
   if((idx = GetListCtrl().GetNextItem(-1, LVNI_FOCUSED)) < 0)
      return;

   msg = GetDocument()->GetMessageAt(idx);
   len = strlen(msg);
   
   // open the clipboard
   if(!OpenClipboard())
      return;

   // empty any current contents
   EmptyClipboard();

   // allocate global memory object
   if((hglbCopy = GlobalAlloc(GMEM_SHARE | GMEM_MOVABLE, len + 1)) == NULL)
   {
      CloseClipboard();
      return;
   }

   // lock the memory and copy the string to it
   lockPtr  = GlobalLock(hglbCopy);
   memcpy(lockPtr, msg, len);
   lockPtr[len] = 0;                // null-terminate the buffer
   GlobalUnlock(hglbCopy);

   // throw this crap onto the clipboard
   // (Shouldn't this be the ONLY thing necessary? Why isn't this crap
   //  encapsulated by MFC??? >_< )

   SetClipboardData(CF_TEXT, hglbCopy);
}