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. Have some problem with String Type

Have some problem with String Type

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 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
    popo84
    wrote on last edited by
    #1

    I created a CString StringData; on the Document Side and also initialize it on the constructor as StringData = ""; Then i used the WM_CHAR, and typed this codes. void CCaretsView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { CCaretsDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); pDoc->StringData += nChar**;//Error from here "It pop out an error saying that its error C2593: 'operator +=' is ambiguous** Invalidate(); CView::OnChar(nChar, nRepCnt, nFlags); } What Happen?

    C 1 Reply Last reply
    0
    • P popo84

      I created a CString StringData; on the Document Side and also initialize it on the constructor as StringData = ""; Then i used the WM_CHAR, and typed this codes. void CCaretsView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { CCaretsDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); pDoc->StringData += nChar**;//Error from here "It pop out an error saying that its error C2593: 'operator +=' is ambiguous** Invalidate(); CView::OnChar(nChar, nRepCnt, nFlags); } What Happen?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      nChar is a UINT. conversing from int to char is implicit ( it happens all by itself ), but UINT is a completely different type. Try pDoc->StringData += (char)nChar;, that should do it ( or something similar to that, in any case ). If you pass FALSE to your Invalidate, it won't call WM_ERASEBKGND, which will eliminate flicker. You realise that this code will not allow for the user to edit the string, but just to make it longer ? Christian Graus - Microsoft MVP - C++

      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