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. CEdit SetPasswordChar SetFont [modified]

CEdit SetPasswordChar SetFont [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpdata-structuresquestion
17 Posts 6 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.
  • T Taulie

    Hello, i've a problem with a subclassed CEdit on WindowsCE 5.0. If i use SetPasswordChar and SetFont in the same subclassed CEdit it generates an acces violation [Stack fault]: Thread=9a431400 Proc=98328d20 'xxxxxx.exe' AKY=00004001 PC=0017ba6c(xxxxxx.exe+0x0016ba6c) RA=000318e8(xxxxxx.exe+0x000218e8) BVA=1e2a1ee4 FSR=00000007 my Code: ... if(edit->SubclassDlgItem(IDC_EDIT1, this)){ edit->SetFont(m_Font, FALSE); edit->SetPasswordChar(0x25CF); // --> stack fault } ... If i don't use SetFont OR SetPasswordChar it works fine... whats wrong ??? can anybody help me? Thanx for replys... edit: // Initialization Controls.edit2 = new CMyEdit(); Controls.edit2->__SubClassControl(this, IDC_EDIT2); Controls.edit2->__SetMaxTextLength(9); //Controls.edit2->SetPasswordChar('*'); // --> stack fault Controls.edit2->SetPasswordChar(0x25CF); // --> stack fault // Control-Code BOOL CMyEdit::__SubClassControl(CMyDialog *pParent, int nID) { // subclassing per SubclassDlgItem is okay, SubclassWindow does not work m_pParent = pParent; m_nID = nID; BOOL ret = SubclassDlgItem(m_nID, m_pParent); // changing FontSize to parentfont and the heigth of the Control LOGFONT lf; if(m_pParent->GetFont()->GetLogFont(&lf) != 0){ // m_Font is a derived class from CFont and an Item of my CMyEdit for better Fonthandling // if i use CFont the same Problem exist with SetPasswordChar (isn't the reason) m_Font->_SetLogFont(lf); if(m_bFontResizing == TRUE){ CRect rect; GetClientRect(&rect); rect.DeflateRect(2,2,2,2); m_Font->_SetHeight(rect.Height()); } SetFont((CFont*)m_Font, FALSE); } return ret; } void CMyEdit::__SetMaxTextLength(int maxLen) { m_maxLen = maxLen; // del mask m_Mask = _T(""); }

    modified on Friday, January 23, 2009 7:14 AM

    K Offline
    K Offline
    krmed
    wrote on last edited by
    #3

    If your edit control is set to multiline, that could be the problem. MSDN states that SetPasswordChar is not supported on multi-line edit controls.

    Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

    T 1 Reply Last reply
    0
    • T Taulie

      Hello, i've a problem with a subclassed CEdit on WindowsCE 5.0. If i use SetPasswordChar and SetFont in the same subclassed CEdit it generates an acces violation [Stack fault]: Thread=9a431400 Proc=98328d20 'xxxxxx.exe' AKY=00004001 PC=0017ba6c(xxxxxx.exe+0x0016ba6c) RA=000318e8(xxxxxx.exe+0x000218e8) BVA=1e2a1ee4 FSR=00000007 my Code: ... if(edit->SubclassDlgItem(IDC_EDIT1, this)){ edit->SetFont(m_Font, FALSE); edit->SetPasswordChar(0x25CF); // --> stack fault } ... If i don't use SetFont OR SetPasswordChar it works fine... whats wrong ??? can anybody help me? Thanx for replys... edit: // Initialization Controls.edit2 = new CMyEdit(); Controls.edit2->__SubClassControl(this, IDC_EDIT2); Controls.edit2->__SetMaxTextLength(9); //Controls.edit2->SetPasswordChar('*'); // --> stack fault Controls.edit2->SetPasswordChar(0x25CF); // --> stack fault // Control-Code BOOL CMyEdit::__SubClassControl(CMyDialog *pParent, int nID) { // subclassing per SubclassDlgItem is okay, SubclassWindow does not work m_pParent = pParent; m_nID = nID; BOOL ret = SubclassDlgItem(m_nID, m_pParent); // changing FontSize to parentfont and the heigth of the Control LOGFONT lf; if(m_pParent->GetFont()->GetLogFont(&lf) != 0){ // m_Font is a derived class from CFont and an Item of my CMyEdit for better Fonthandling // if i use CFont the same Problem exist with SetPasswordChar (isn't the reason) m_Font->_SetLogFont(lf); if(m_bFontResizing == TRUE){ CRect rect; GetClientRect(&rect); rect.DeflateRect(2,2,2,2); m_Font->_SetHeight(rect.Height()); } SetFont((CFont*)m_Font, FALSE); } return ret; } void CMyEdit::__SetMaxTextLength(int maxLen) { m_maxLen = maxLen; // del mask m_Mask = _T(""); }

      modified on Friday, January 23, 2009 7:14 AM

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #4

      grandmasta1 wrote:

      edit->SetPasswordChar(0x25CF); // --> stack fault

      I'm not sure how Windows CE treats char. But try using some simple char like '*' first.

      T _ 2 Replies Last reply
      0
      • C Code o mat

        No real idea here but what happens if you change the order, use SetPasswordChar first and then use SetFont? Any change?

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

        T Offline
        T Offline
        Taulie
        wrote on last edited by
        #5

        i try it, but it has no effect... the message EM_SETPASSWORDCHAR raises the error, mfc is not the reason...

        C 1 Reply Last reply
        0
        • K krmed

          If your edit control is set to multiline, that could be the problem. MSDN states that SetPasswordChar is not supported on multi-line edit controls.

          Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

          T Offline
          T Offline
          Taulie
          wrote on last edited by
          #6

          MSDN says the Function has on effect in multineedit... i test it... edit: tested, but no effect

          K 1 Reply Last reply
          0
          • P prasad_som

            grandmasta1 wrote:

            edit->SetPasswordChar(0x25CF); // --> stack fault

            I'm not sure how Windows CE treats char. But try using some simple char like '*' first.

            T Offline
            T Offline
            Taulie
            wrote on last edited by
            #7

            has no effect - SetPasswordChar requieres a TCHAR as parameter

            1 Reply Last reply
            0
            • T Taulie

              Hello, i've a problem with a subclassed CEdit on WindowsCE 5.0. If i use SetPasswordChar and SetFont in the same subclassed CEdit it generates an acces violation [Stack fault]: Thread=9a431400 Proc=98328d20 'xxxxxx.exe' AKY=00004001 PC=0017ba6c(xxxxxx.exe+0x0016ba6c) RA=000318e8(xxxxxx.exe+0x000218e8) BVA=1e2a1ee4 FSR=00000007 my Code: ... if(edit->SubclassDlgItem(IDC_EDIT1, this)){ edit->SetFont(m_Font, FALSE); edit->SetPasswordChar(0x25CF); // --> stack fault } ... If i don't use SetFont OR SetPasswordChar it works fine... whats wrong ??? can anybody help me? Thanx for replys... edit: // Initialization Controls.edit2 = new CMyEdit(); Controls.edit2->__SubClassControl(this, IDC_EDIT2); Controls.edit2->__SetMaxTextLength(9); //Controls.edit2->SetPasswordChar('*'); // --> stack fault Controls.edit2->SetPasswordChar(0x25CF); // --> stack fault // Control-Code BOOL CMyEdit::__SubClassControl(CMyDialog *pParent, int nID) { // subclassing per SubclassDlgItem is okay, SubclassWindow does not work m_pParent = pParent; m_nID = nID; BOOL ret = SubclassDlgItem(m_nID, m_pParent); // changing FontSize to parentfont and the heigth of the Control LOGFONT lf; if(m_pParent->GetFont()->GetLogFont(&lf) != 0){ // m_Font is a derived class from CFont and an Item of my CMyEdit for better Fonthandling // if i use CFont the same Problem exist with SetPasswordChar (isn't the reason) m_Font->_SetLogFont(lf); if(m_bFontResizing == TRUE){ CRect rect; GetClientRect(&rect); rect.DeflateRect(2,2,2,2); m_Font->_SetHeight(rect.Height()); } SetFont((CFont*)m_Font, FALSE); } return ret; } void CMyEdit::__SetMaxTextLength(int maxLen) { m_maxLen = maxLen; // del mask m_Mask = _T(""); }

              modified on Friday, January 23, 2009 7:14 AM

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

              grandmasta1 wrote:

              If i don't use SetFont...it works fine...

              Since the edit control is just going to show a * anyway, why does it need a different font?

              "Love people and use things, not love things and use people." - Unknown

              "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

              T 1 Reply Last reply
              0
              • D David Crow

                grandmasta1 wrote:

                If i don't use SetFont...it works fine...

                Since the edit control is just going to show a * anyway, why does it need a different font?

                "Love people and use things, not love things and use people." - Unknown

                "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                T Offline
                T Offline
                Taulie
                wrote on last edited by
                #9

                i change the fontsize to fit in the control...

                T 1 Reply Last reply
                0
                • T Taulie

                  i change the fontsize to fit in the control...

                  T Offline
                  T Offline
                  Taulie
                  wrote on last edited by
                  #10

                  i change the fontsize to fit in the control... e.g. from size 8 to 15 - and the oher edit controls have size 15 looks not so fine, if the passwordcontrol has only size 8 if i use '*' as default, the access violation occurs if i set a new font. if the flag ES_PASSWORD or a PassworChar is set and i try to set a new font the access violation is always generated... i have no idea...

                  1 Reply Last reply
                  0
                  • T Taulie

                    i try it, but it has no effect... the message EM_SETPASSWORDCHAR raises the error, mfc is not the reason...

                    C Offline
                    C Offline
                    Code o mat
                    wrote on last edited by
                    #11

                    So let me get this clear:

                    edit.SetFont(somefont);
                    edit.SetPasswordChar(whatever); <- it crashes here

                    crashes and

                    edit.SetPasswordChar(whatever); <- it crashes here again, so SetFont never gets called
                    edit.SetFont(somefont);

                    crashes too but

                    edit.SetPasswordChar(whatever); <- works ok, no SetFont around

                    works. That is very strange, i don't really see the great difference between the later two cases since SetFont never gets called at all in either case.

                    > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

                    T 1 Reply Last reply
                    0
                    • C Code o mat

                      So let me get this clear:

                      edit.SetFont(somefont);
                      edit.SetPasswordChar(whatever); <- it crashes here

                      crashes and

                      edit.SetPasswordChar(whatever); <- it crashes here again, so SetFont never gets called
                      edit.SetFont(somefont);

                      crashes too but

                      edit.SetPasswordChar(whatever); <- works ok, no SetFont around

                      works. That is very strange, i don't really see the great difference between the later two cases since SetFont never gets called at all in either case.

                      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

                      T Offline
                      T Offline
                      Taulie
                      wrote on last edited by
                      #12

                      not directly... edit.SetFont(somefont); edit.SetPasswordChar(whatever); <- it crashes here edit.SetPasswordChar(whatever); edit.SetFont(somefont);<- it crashes here edit.SetPasswordChar(whatever); <- works ok, no SetFont around i check now if the subclassing is the reason... wait a moment...

                      C 1 Reply Last reply
                      0
                      • T Taulie

                        not directly... edit.SetFont(somefont); edit.SetPasswordChar(whatever); <- it crashes here edit.SetPasswordChar(whatever); edit.SetFont(somefont);<- it crashes here edit.SetPasswordChar(whatever); <- works ok, no SetFont around i check now if the subclassing is the reason... wait a moment...

                        C Offline
                        C Offline
                        Code o mat
                        wrote on last edited by
                        #13

                        Ah, i see. Where do you perform all this? I mean, the subclassinc of the edit and the rest? I mean, in what method, at what event...?

                        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

                        T 1 Reply Last reply
                        0
                        • C Code o mat

                          Ah, i see. Where do you perform all this? I mean, the subclassinc of the edit and the rest? I mean, in what method, at what event...?

                          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

                          T Offline
                          T Offline
                          Taulie
                          wrote on last edited by
                          #14

                          in OnInitDialog... i've rewritten a little class to encapsulate this problem, it looks like a WindowsCE-Problem... in Win32 works fine... edit: give up... in pocketpc-emulator it works always fine :-| it must be devicedependend or a devicemistake...

                          1 Reply Last reply
                          0
                          • T Taulie

                            MSDN says the Function has on effect in multineedit... i test it... edit: tested, but no effect

                            K Offline
                            K Offline
                            krmed
                            wrote on last edited by
                            #15

                            Here's a quote from MSDN: Remarks When a password character is set, that character is displayed for each character the user types. This member function has no effect on a multiple-line edit control. When the SetPasswordChar member function is called, CEdit will redraw all visible characters using the character specified by ch. If the edit control is created with the ES_PASSWORD style, the default password character is set to an asterisk (*). This style is removed if SetPasswordChar is called with ch set to 0. For more information, see EM_SETPASSWORDCHAR in the Platform SDK.

                            Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

                            1 Reply Last reply
                            0
                            • P prasad_som

                              grandmasta1 wrote:

                              edit->SetPasswordChar(0x25CF); // --> stack fault

                              I'm not sure how Windows CE treats char. But try using some simple char like '*' first.

                              _ Offline
                              _ Offline
                              _Superman_
                              wrote on last edited by
                              #16

                              Windows CE only supports Unicode. So all string MUST be L"" and all characters are 2 bytes.

                              «_Superman_»

                              T 1 Reply Last reply
                              0
                              • _ _Superman_

                                Windows CE only supports Unicode. So all string MUST be L"" and all characters are 2 bytes.

                                «_Superman_»

                                T Offline
                                T Offline
                                Taulie
                                wrote on last edited by
                                #17

                                i know... 0x25CF are 2 bytes, or not? ans strings with L"" or _T("") or TEXT("")... there is a single Character as parameter required in TCHAR-Format... the app works in emulator, it must be devicedependend... on an other device the app has no problem and works... thanx

                                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