Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Password CXTPControlEdit in Toolbar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Password CXTPControlEdit in Toolbar

 Post Reply Post Reply
Author
Message
mwest View Drop Down
Newbie
Newbie
Avatar

Joined: 13 June 2005
Location: United States
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote mwest Quote  Post ReplyReply Direct Link To This Post Topic: Password CXTPControlEdit in Toolbar
    Posted: 08 August 2005 at 11:59am
Is there an easy way to make a CXTPControlEdit in a toolbar a password field (one with '*')?

I tried to create the control in OnCreateControl and call SetPasswordChar, but the CEdit is not created until 'SetRect' is called (which is too late).


m_pPassword = (CXTPControlEdit*)CXTPControlEdit::CreateObject();

m_pPassword->SetWidth(150);
m_pPassword->SetFlags(xtpFlagManualUpdate);
m_pPassword->SetCaption("password");
m_pPassword->GetEditCtrl()->SetPasswordChar('*');&nb sp;  // <-- Does not work!

lpCreateControl->pControl = m_pPassword;

return TRUE;


I am trying to create a simple password control without having to create a custom class.  Thanks!
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 08 August 2005 at 12:41pm

Only one way to override CXTPControlEdit

class CXTPControlPasswordEdit : public CXTPControlEdit
{

DECLATE_XTP_CONROL(CXTPControlPasswordEdit )

   void SetRect(CRect rcControl)
  {

     CXTPControlEdit::SetRect(rcControl);
     m_pEdit->SetPasswordChar('*');

  }
}

IMPLEMENT_XTP_CONTROL(CXTPControlPasswordEdit , CXTPControlEdit)

 

ps. didn't tested :)

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
mwest View Drop Down
Newbie
Newbie
Avatar

Joined: 13 June 2005
Location: United States
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote mwest Quote  Post ReplyReply Direct Link To This Post Posted: 08 August 2005 at 4:47pm
For now I just have:


class CObscureEdit : public CXTPControlEdit
{
public:
    DECLARE_XTP_CONTROL(CObscureEdit)

public:
    virtual CXTPControlEditCtrl* CreateEditControl(){
        pEditCtrl = new CObscureEditCtrl;
        return pEditCtrl;
    }

protected:
    CXTPControlEditCtrl* pEditCtrl;
};


class CObscureEditCtrl : public CXTPControlEditCtrl
{
// Overrides
public:
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CObscureEditCtrl)
protected:
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs){
        cs.style |= ES_PASSWORD;    // Make it password protected
        return CXTPControlEditCtrl::PreCreateWindow(cs);
    }
    //}}AFX_VIRTUAL
};

NOTE:  The code was truncated and inlined.

It seems to work fine, but I am not sure if it is the best way to do it.


Edited by mwest
Back to Top
spike View Drop Down
Groupie
Groupie


Joined: 13 May 2003
Location: United States
Status: Offline
Points: 48
Post Options Post Options   Thanks (0) Thanks(0)   Quote spike Quote  Post ReplyReply Direct Link To This Post Posted: 17 August 2005 at 12:10pm
Looks like the better way to do it to me.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.