Print Page | Close Window

Password CXTPControlEdit in Toolbar

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=2701
Printed Date: 08 November 2025 at 9:21pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Password CXTPControlEdit in Toolbar
Posted By: mwest
Subject: Password CXTPControlEdit in Toolbar
Date 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!



Replies:
Posted By: Oleg
Date 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


Posted By: mwest
Date 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.


Posted By: spike
Date Posted: 17 August 2005 at 12:10pm
Looks like the better way to do it to me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net