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. format the value of Spin & Edit?

format the value of Spin & Edit?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
16 Posts 5 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.
  • C Cedric Moonen

    :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.

    Z Offline
    Z Offline
    zeus_master
    wrote on last edited by
    #4

    yes CSpinButtonCtrl m_spin; CEdit m_edit; .. m_spin.SetBuddy(&m_edit) ...

    1 Reply Last reply
    0
    • C Cedric Moonen

      :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.

      Z Offline
      Z Offline
      zeus_master
      wrote on last edited by
      #5

      :doh:yes CSpinButtonCtrl m_spin; CEdit m_edit; .. m_spin.SetBuddy(&m_edit) ...

      1 Reply Last reply
      0
      • Z zeus_master

        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. :((

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #6

        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

        Z 1 Reply Last reply
        0
        • D David Crow

          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

          Z Offline
          Z Offline
          zeus_master
          wrote on last edited by
          #7

          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:

          D 1 Reply Last reply
          0
          • Z zeus_master

            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:

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #8

            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

            Z 1 Reply Last reply
            0
            • D David Crow

              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

              Z Offline
              Z Offline
              zeus_master
              wrote on last edited by
              #9

              what you mean is this function m_edit.SetWindowsText("FF")? would you tell me the way of you setting? thank you:)

              D 1 Reply Last reply
              0
              • Z zeus_master

                what you mean is this function m_edit.SetWindowsText("FF")? would you tell me the way of you setting? thank you:)

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #10

                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

                Z 1 Reply Last reply
                0
                • D David Crow

                  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

                  Z Offline
                  Z Offline
                  zeus_master
                  wrote on last edited by
                  #11

                  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:

                  N D 2 Replies Last reply
                  0
                  • Z zeus_master

                    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:

                    N Offline
                    N Offline
                    Nibu babu thomas
                    wrote on last edited by
                    #12

                    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 using Format function of CString or by using sprintf. for ex:

                    sprintf(buf, "%x", spinVal);


                    Nibu thomas Software Developer

                    Z 1 Reply Last reply
                    0
                    • N Nibu babu thomas

                      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 using Format function of CString or by using sprintf. for ex:

                      sprintf(buf, "%x", spinVal);


                      Nibu thomas Software Developer

                      Z Offline
                      Z Offline
                      zeus_master
                      wrote on last edited by
                      #13

                      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?

                      N 1 Reply Last reply
                      0
                      • Z zeus_master

                        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:

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #14

                        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

                        1 Reply Last reply
                        0
                        • Z zeus_master

                          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?

                          N Offline
                          N Offline
                          Nibu babu thomas
                          wrote on last edited by
                          #15

                          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 handle WM_CHAR. Check for valid hex characters. If not valid hex characters eat the message else display char.


                          Nibu thomas Software Developer

                          Z 1 Reply Last reply
                          0
                          • N Nibu babu thomas

                            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 handle WM_CHAR. Check for valid hex characters. If not valid hex characters eat the message else display char.


                            Nibu thomas Software Developer

                            Z Offline
                            Z Offline
                            zeus_master
                            wrote on last edited by
                            #16

                            thank you. :laugh:

                            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