Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem occurred ...please help

Problem occurred ...please help

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pubududilena
    wrote on last edited by
    #1

    hi all, I have a Method like this:- void CMyprogramDlg::Addcustomers(BSTR bstrParty) { CListBox m_lbParties; _ASSERTE( bstrParty != NULL); m_lbParties.AddString(bstrParty); } But when I compile this,I am getting such a Error:- "error C2664: 'AddString' : cannot convert parameter 1 from 'unsigned short *' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast " How do I solve this? If anyone know this please help me.. Thanks in Advance..

    G A 2 Replies Last reply
    0
    • P pubududilena

      hi all, I have a Method like this:- void CMyprogramDlg::Addcustomers(BSTR bstrParty) { CListBox m_lbParties; _ASSERTE( bstrParty != NULL); m_lbParties.AddString(bstrParty); } But when I compile this,I am getting such a Error:- "error C2664: 'AddString' : cannot convert parameter 1 from 'unsigned short *' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast " How do I solve this? If anyone know this please help me.. Thanks in Advance..

      G Offline
      G Offline
      geo_m
      wrote on last edited by
      #2

      Add string requires the char* and you are suplying the BSTR here. You need to convert it from UNICODE BSTR to the normal string or force the listbox to accept BSTRs

      1 Reply Last reply
      0
      • P pubududilena

        hi all, I have a Method like this:- void CMyprogramDlg::Addcustomers(BSTR bstrParty) { CListBox m_lbParties; _ASSERTE( bstrParty != NULL); m_lbParties.AddString(bstrParty); } But when I compile this,I am getting such a Error:- "error C2664: 'AddString' : cannot convert parameter 1 from 'unsigned short *' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast " How do I solve this? If anyone know this please help me.. Thanks in Advance..

        A Offline
        A Offline
        Andrzej Markowski
        wrote on last edited by
        #3

        You could use CString to convert from UNICODE to char string like this: m_lbParties.AddString(CString(bstrParty)) or use WideCharToMultiByte function. You must also create list box before you call AddString. Regards, Andrzej Markowski

        My Latest ArticlesCCustomBitmapButton: An owner-draw button and a frame for the caption bar, in one class. CCustomTabCtrl: A clone of the Excel tab sheet control.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups