Problems with MFC Ribbon edit with spin button
-
Not sure I understand what your problem is... When you do a GetEditText on your control you only get 1 when it should be a 1000? or you don't expect to be able to reach 1000? Can you clarify?
Seems the comma in
1,000
is his problem (ie GetEditText reads "1,000" then parseInt() or whatever stops at the comma). If there's no suitable style/attribute on the control he's using, then I guess it requires a bit of string-munching. Cheers, PeterSoftware rusts. Simon Stephenson, ca 1994.
-
Seems the comma in
1,000
is his problem (ie GetEditText reads "1,000" then parseInt() or whatever stops at the comma). If there's no suitable style/attribute on the control he's using, then I guess it requires a bit of string-munching. Cheers, PeterSoftware rusts. Simon Stephenson, ca 1994.
-
The problem is comma, when I use GetEditText() returns '1' and not '1,000', I want 1000 because I'm editing a object and when reach 1000 returns to value 1, that's wrong. I don't have parseInt() method I'm using mfc c++. thank you
This seems like such an obvious bug... why would GetEditText() parse out the text (CString never ends on a ',' so I don't see how this bug could occur)? where are you checking your return? Maybe post your actual code and point out where you see the 1.
-
This seems like such an obvious bug... why would GetEditText() parse out the text (CString never ends on a ',' so I don't see how this bug could occur)? where are you checking your return? Maybe post your actual code and point out where you see the 1.
Hi Here is my code:
CMFCRibbonEdit *pEdit = DYNAMIC_DOWNCAST(CMFCRibbonEdit, MyApp->GetRibbonElement(ID_RIBBON_FORMAT_WIDTH));
if(pEdit == NULL)
return;
CDrawObj *pObj = (CDrawObj*)m_selection.GetHead();
if(pObj == NULL){
ASSERT(0);
return;
}
if(_ttoi(pEdit->GetEditText()) < 1) <==== Here GetEditText() return 1 and not 1,000 I tested with MFCOffice2007Sample and they have the same problem
return;
this->InvalObj(pObj);
int nDelta = _ttoi(pEdit->GetEditText()) - pObj->m_position.Width();
if(nDelta < GetDocument()->m_size.cx){
CRect newPosition = pObj->m_position;
newPosition.right += nDelta;
pObj->MoveTo(newPosition);
} -
Hi Here is my code:
CMFCRibbonEdit *pEdit = DYNAMIC_DOWNCAST(CMFCRibbonEdit, MyApp->GetRibbonElement(ID_RIBBON_FORMAT_WIDTH));
if(pEdit == NULL)
return;
CDrawObj *pObj = (CDrawObj*)m_selection.GetHead();
if(pObj == NULL){
ASSERT(0);
return;
}
if(_ttoi(pEdit->GetEditText()) < 1) <==== Here GetEditText() return 1 and not 1,000 I tested with MFCOffice2007Sample and they have the same problem
return;
this->InvalObj(pObj);
int nDelta = _ttoi(pEdit->GetEditText()) - pObj->m_position.Width();
if(nDelta < GetDocument()->m_size.cx){
CRect newPosition = pObj->m_position;
newPosition.right += nDelta;
pObj->MoveTo(newPosition);
}See... you're problem is probably with the conversion of the CString to an integer... place pEdit->GetEditText() on its own line and look at the text returned. If its 1000, with or without a coma, its correct and the problem is with the function doing the conversion to integer. You can always take your returned CString and remove the ',' character before even attempting the conversion.
CString ret = pEdit->GetEditText(); //<-- check the returned string
ret.Remove(','); //<-- Now you can convert this -
See... you're problem is probably with the conversion of the CString to an integer... place pEdit->GetEditText() on its own line and look at the text returned. If its 1000, with or without a coma, its correct and the problem is with the function doing the conversion to integer. You can always take your returned CString and remove the ',' character before even attempting the conversion.
CString ret = pEdit->GetEditText(); //<-- check the returned string
ret.Remove(','); //<-- Now you can convert this -
Thank you Now is working but when I click in Up Arrow the increment shows 1,000, 1,001, 1,002 and when I change focus shows the correct value. Thanks for all
that's a different issue, post as new question pls... :)
-
See... you're problem is probably with the conversion of the CString to an integer... place pEdit->GetEditText() on its own line and look at the text returned. If its 1000, with or without a coma, its correct and the problem is with the function doing the conversion to integer. You can always take your returned CString and remove the ',' character before even attempting the conversion.
CString ret = pEdit->GetEditText(); //<-- check the returned string
ret.Remove(','); //<-- Now you can convert thisThanks. All fixed while I was sleeping... You've spelled out exactly what I was referring to a few message above. Cheers, Peter
Software rusts. Simon Stephenson, ca 1994.
-
that's a different issue, post as new question pls... :)
-
The problem is resolved: I used: CString str = pEdit->GetEditText(); str.Remove(`,`); pEdit->SetEditText(str); :) Thank you
Cool... cheers! :)