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