Thread: Second parameter of SetClipboardData()

  1. #1
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001

    Second parameter of SetClipboardData()

    Can anyone explain to me what the second parameter is? MSDN didn't explain it too well.. err, it went over my head.

    Say I want to take text from one of my text boxes and click a button "Copy to Clipboard"

  2. #2
    Registered User
    Join Date
    Feb 2002
    why that's a handle....

    just kidding...

    it works something like this... if this does not work email me tomorrow at

    I will send you a sample that works...

    if( OpenClipboard( myhwnd ) ){

    HGLOBAL hgb = GlobalAlloc(
    GMEM_MOVEABLE, // allocation attributes
    100 // number of bytes to allocate

    char* pdata;

    pdata = (char*) GlobalLock(hgb);

    strcpy(pdata, "my text");

    SetClipboardData( CF_TEXT, hgb);


    --true programmer's don't comment--
    --programmer wannabes complain about it--

  3. #3
    Registered User
    Join Date
    Aug 2001
    	if( OpenClipboard() )
    		HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, sFxName.GetLength() + 1);
    		if( hGlobal )
    			char *psz = (char *)GlobalLock( hGlobal );
    			strcpy(psz, sFxName.GetBuffer( sFxName.GetLength() ) );
    			SetClipboardData(CF_TEXT, hGlobal);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. my error is storage class specified for parameter
    By meli in forum C Programming
    Replies: 5
    Last Post: 03-27-2009, 12:06 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. cannot start a parameter declaration
    By Dark Nemesis in forum C++ Programming
    Replies: 6
    Last Post: 09-23-2005, 02:09 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM