format the value of Spin & Edit?
-
How to make the edit display the value by hex string? such as .... m_spin.SetBase(16); m_spin.SetRange(0,0xFF); m_spin.SetPos(0x2F); ... the edit display "0x002F",what I want is just the string "2F" only. ps:I tried to format m_edit in the function OnUpdateEdit(), but failed. :((
-
How to make the edit display the value by hex string? such as .... m_spin.SetBase(16); m_spin.SetRange(0,0xFF); m_spin.SetPos(0x2F); ... the edit display "0x002F",what I want is just the string "2F" only. ps:I tried to format m_edit in the function OnUpdateEdit(), but failed. :((
:confused: What is this m_spin ? A Progress bar ? It has nothing to do with the edit control ! What you put in the edit control, it's up to you to format it correctly.
-
:confused: What is this m_spin ? A Progress bar ? It has nothing to do with the edit control ! What you put in the edit control, it's up to you to format it correctly.
-
:confused: What is this m_spin ? A Progress bar ? It has nothing to do with the edit control ! What you put in the edit control, it's up to you to format it correctly.
yes CSpinButtonCtrl m_spin; CEdit m_edit; .. m_spin.SetBuddy(&m_edit) ...
-
:confused: What is this m_spin ? A Progress bar ? It has nothing to do with the edit control ! What you put in the edit control, it's up to you to format it correctly.
:doh:yes CSpinButtonCtrl m_spin; CEdit m_edit; .. m_spin.SetBuddy(&m_edit) ...
-
How to make the edit display the value by hex string? such as .... m_spin.SetBase(16); m_spin.SetRange(0,0xFF); m_spin.SetPos(0x2F); ... the edit display "0x002F",what I want is just the string "2F" only. ps:I tried to format m_edit in the function OnUpdateEdit(), but failed. :((
zeus_master wrote:
How to make the edit display the value by hex string?
If "2F" is already in s string-type variable, just use
CEdit::SetWindowText()
:m_edit.SetWindowText("2F");
If not, please explain more clearly what you are after.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
-
zeus_master wrote:
How to make the edit display the value by hex string?
If "2F" is already in s string-type variable, just use
CEdit::SetWindowText()
:m_edit.SetWindowText("2F");
If not, please explain more clearly what you are after.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
In fact, I want to build a simple tool to debug some registers. the registers value range is from "0x00" to "0xFF". only display the string from the hex value please see sketch map below: ____ |DE | // edit value display is 00,01,02.......,0A,0B,....0F,...1E...FF <||> // spin left<- ->right:confused:
-
In fact, I want to build a simple tool to debug some registers. the registers value range is from "0x00" to "0xFF". only display the string from the hex value please see sketch map below: ____ |DE | // edit value display is 00,01,02.......,0A,0B,....0F,...1E...FF <||> // spin left<- ->right:confused:
Now I understand. Unfortunately, the only solution I can think of is to make the edit control right-justified and just wide enough to hold FF.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
-
Now I understand. Unfortunately, the only solution I can think of is to make the edit control right-justified and just wide enough to hold FF.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
what you mean is this function m_edit.SetWindowsText("FF")? would you tell me the way of you setting? thank you:)
-
what you mean is this function m_edit.SetWindowsText("FF")? would you tell me the way of you setting? thank you:)
I assumed you simply wanted to know how to set the text of an edit control.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
-
I assumed you simply wanted to know how to set the text of an edit control.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
yes, it is also a problem for me. how to set the text/string of edit control that display the value from "00" to "FF"?:doh:
-
yes, it is also a problem for me. how to set the text/string of edit control that display the value from "00" to "FF"?:doh:
Why don't you set it through code? Remove the style
UDS_SETBUDDYINT
. Handle the notification for spin control. Now get the current integer value of the spin control and get it in hex format usingFormat
function ofCString
or by usingsprintf
. for ex:sprintf(buf, "%x", spinVal);
Nibu thomas Software Developer
-
Why don't you set it through code? Remove the style
UDS_SETBUDDYINT
. Handle the notification for spin control. Now get the current integer value of the spin control and get it in hex format usingFormat
function ofCString
or by usingsprintf
. for ex:sprintf(buf, "%x", spinVal);
Nibu thomas Software Developer
thank you very much for your suggestion, I removed the style UDS_SETBUDDYINT, and added the code below. void CFlexgridDlg::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult) { NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; // TODO: Add your control notification handler code here BYTE str; str = m_UpDown.GetPos(); m_edit.Format("%02x",str); m_edit.MakeUpper(); UpdateData(false); *pResult = 0; } the text of the edit display the hex string I want now. but I met another problem is if how to limit input value from keyboard of the edit is hex string format. CEdit m_edit1Ctrl; CString m_edit; void CFlexgridDlg::OnChangeEdit1() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here char chartemp; char edit1sel; UpdateData(TRUE); edit1sel = m_edit1Ctrl.GetSel(); if(edit1sel) chartemp = m_edit.GetAt(edit1sel-1); else chartemp = 0x00; if(!(isxdigit(chartemp))) { m_12.SetSel(edit1sel-1,edit1sel); m_12.Clear(); } UpdateData(false); } the code can work well while the edit is not a buddy of the spin, if set edit as a buddy of the spin. the error occurs, UpdateData() cann't work here?
-
yes, it is also a problem for me. how to set the text/string of edit control that display the value from "00" to "FF"?:doh:
zeus_master wrote:
how to set the text/string of edit control that display the value from "00" to "FF"?
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
-
thank you very much for your suggestion, I removed the style UDS_SETBUDDYINT, and added the code below. void CFlexgridDlg::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult) { NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; // TODO: Add your control notification handler code here BYTE str; str = m_UpDown.GetPos(); m_edit.Format("%02x",str); m_edit.MakeUpper(); UpdateData(false); *pResult = 0; } the text of the edit display the hex string I want now. but I met another problem is if how to limit input value from keyboard of the edit is hex string format. CEdit m_edit1Ctrl; CString m_edit; void CFlexgridDlg::OnChangeEdit1() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here char chartemp; char edit1sel; UpdateData(TRUE); edit1sel = m_edit1Ctrl.GetSel(); if(edit1sel) chartemp = m_edit.GetAt(edit1sel-1); else chartemp = 0x00; if(!(isxdigit(chartemp))) { m_12.SetSel(edit1sel-1,edit1sel); m_12.Clear(); } UpdateData(false); } the code can work well while the edit is not a buddy of the spin, if set edit as a buddy of the spin. the error occurs, UpdateData() cann't work here?
zeus_master wrote:
but I met another problem is if how to limit input value from keyboard of the edit is hex string format.
Subclass
CEdit
and handleWM_CHAR
. Check for valid hex characters. If not valid hex characters eat the message else display char.
Nibu thomas Software Developer
-
zeus_master wrote:
but I met another problem is if how to limit input value from keyboard of the edit is hex string format.
Subclass
CEdit
and handleWM_CHAR
. Check for valid hex characters. If not valid hex characters eat the message else display char.
Nibu thomas Software Developer
thank you. :laugh: