Clipboard format



  • hallo,
    ich hab folgendes problem:
    ich hab ein programm mit dem ich Daten mit "SetClipboardData( CF_TEXT, hData )" in die Zwischenablage lege. Es wird dadurch aber anscheinend nicht aller Text in der Zwischenablage überschrieben. wenn ich z.b. text aus icq kopiere dann text mit meinem programm kopiere und dann im icq fenster einfügen mache wird der "alte" icq-text eingefügt und nicht meiner.Wie kann ich das ändern ?

    Ach noch ne Frage: Was ist CF_LOCALE für ein Format ? das hab ich nicht ganz verstanden.



  • CF_LOCALE
    The data is a handle to the locale identifier associated with text in the
    clipboard. When you close the clipboard, if it contains CF_TEXT data but no
    CF_LOCALE data, the system automatically sets the CF_LOCALE format to the
    current input locale. You can use the CF_LOCALE format to associate a different
    locale with the clipboard text.An application that pastes text from the
    clipboard can retrieve this format to determine which character set was used to
    generate the text.Note that the clipboard does not support plain text in
    multiple character sets. To achieve this, use a fomatted text data type such as
    RTF instead.Windows NT: The system uses the code page associated with CF_LOCALE
    to implicitly convert from CF_TEXT to CF_UNICODETEXT. Therefore, the correct
    code page table is used for the conversion.
    

    [ Dieser Beitrag wurde am 01.06.2003 um 13:42 Uhr von paranoiac.org editiert. ]



  • hmm die msdn hab ich dazu auch schon gelesen, bringt mich aber ehrlich gesagt auch nicht weiter.

    Was ich eigentlich wissen will ist wie genau macht das z.b. Notepad text in die zwischenablage zu kopieren ? Mit "SetClipboardData( CF_TEXT, hData )" allein kanns nicht getan sein sonst würdes bei mir auch so funktionieren, wie ich mir das vorstelle.



  • weiss keiner was ?



  • Hallo,

    ich weiss nicht genau, welche Schritte du alle ausführst, deswegen mal ein bisschen Quelltext:

    void CNavClipCtrl::SetClipText() 
    {
      HGLOBAL hGlobalMemory = NULL;
      LPTSTR pcGlobalMemory = NULL;
      LPTSTR pcLocalText =(LPTSTR) cszClipText.GetBuffer(0);
      int iTextLen;
    
      iTextLen = _tcslen(pcLocalText);
    
      hGlobalMemory = ::GlobalAlloc(GHND |GMEM_SHARE, (iTextLen+1)*sizeof(TCHAR));
      //Speicher für den Text + Nullchar auf dem globalen Heap reservieren,
      if (hGlobalMemory)
      {
        pcGlobalMemory = (LPTSTR) ::GlobalLock(hGlobalMemory);
        //Speicher sperren, erst GlobalLock liefert einen verwertbaren Pointer zurück
        //wenn GHND bzw. GMEM_MOVEABLE angegeben ist 
        if (pcGlobalMemory)
        {
          for (int i = 0; i<iTextLen;i++)
            *pcGlobalMemory++ = *pcLocalText++;
            //Text reinschieben
          ::GlobalUnlock(hGlobalMemory);
          //Speicher wieder entsperren
          ::OpenClipboard (NULL);  
          ::EmptyClipboard();
          ::SetClipboardData(_CF_TTEXT, hGlobalMemory);
          ::CloseClipboard();
        }
      }
    
      cszClipText = __TEXT("");
      return;
    }
    

Anmelden zum Antworten