Thread: Trouble Adding to ComboBox (*not* an LB_ issue..)

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    2

    Trouble Adding to ComboBox (*not* an LB_ issue..)

    I have been absolutely banging my head against various hard surfaces trying to understand what the problem is here.

    I am creating a clipboard monitoring utility that, at this point, will simply see if the clipboard item is text, if so, add it to a ComboBox. Should be about the easiest thing to do, right?? All I get is garbly-gook when I SendMessage to ComboBox using the code below. If I replace the LPARAM with TEXT("test"), "test" is added to the ComboBox successfully.

    Any help would be GREATLY appreciated. I'm using Code::Blocks IDE and compiling with MinGW / GNU C++



    Code:
        if (!IsClipboardFormatAvailable(CF_TEXT))
            return;
        if (!OpenClipboard(clipWnd))
            return;
    
        HGLOBAL hglb = GetClipboardData(CF_TEXT);
        if (hglb != NULL)
        {
            LPCTSTR str  = (LPCTSTR) GlobalLock(hglb);
    
            if (str != NULL)
            {
                SendMessage(hComboBox, CB_INSERTSTRING, 0, (LPARAM) str);
                SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
                GlobalUnlock(hglb);
            }
        }
    
        CloseClipboard();

  2. #2
    Registered User
    Join Date
    Jul 2007
    Posts
    2

    Resolved

    Well, I found the problem, I'm requesting the clipboard data in the CF_TEXT instead of CF_UNICODETEXT....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with adding strings into ComboBox using Window Handle
    By jasperleeabc in forum Windows Programming
    Replies: 7
    Last Post: 05-05-2009, 04:48 PM
  2. Trouble adding source filter for WMV
    By abachler in forum Windows Programming
    Replies: 2
    Last Post: 07-03-2008, 08:38 AM
  3. SVN Import Causes Crash
    By Tonto in forum Tech Board
    Replies: 6
    Last Post: 11-01-2006, 03:44 PM
  4. adding icons to ComboBox
    By ElastoManiac in forum Windows Programming
    Replies: 5
    Last Post: 11-27-2005, 03:17 AM