Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - Custom Controls
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Custom Controls

 Post Reply Post Reply
Author
Message
dalai View Drop Down
Groupie
Groupie


Joined: 07 January 2011
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote dalai Quote  Post ReplyReply Direct Link To This Post Topic: Custom Controls
    Posted: 15 March 2011 at 6:09am
I opened this for anyone who would like to share their custom controls starting with HH:MM ...

class CControlEditHHMMCtrl : public CXTPMaskEditT<CXTPControlEditCtrl>
{
public:
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    DECLARE_MESSAGE_MAP()
};

class CControlEditHHMM: public CXTPControlEdit
{
    DECLARE_XTP_CONTROL(CControlEditHHMM)
public:
    CXTPControlEditCtrl* CreateEditControl()
    {
        return new CControlEditHHMMCtrl();
    }
};

BEGIN_MESSAGE_MAP(CControlEditHHMMCtrl, CXTPMaskEditT<CXTPControlEditCtrl>)
    ON_MASKEDIT_REFLECT()
    ON_WM_CREATE()
END_MESSAGE_MAP()

IMPLEMENT_XTP_CONTROL(CControlEditHHMM, CXTPControlEdit)

int CControlEditHHMMCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    SetEditMask(_T("00:00"), _T("__:__"), _T("00:00"));
    return CXTPMaskEditT<CXTPControlEditCtrl>::OnCreate(lpCreateStruct);
}


< id="gwProxy" ="">< ="jsCall;" id="jsProxy" ="">
Back to Top
dalai View Drop Down
Groupie
Groupie


Joined: 07 January 2011
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote dalai Quote  Post ReplyReply Direct Link To This Post Posted: 15 March 2011 at 6:36am
how do I limit HH to 0-23 and MM to 0-59 ?< id="gwProxy" ="">< ="jsCall;" id="jsProxy" ="">
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 15 March 2011 at 8:56am
Hi;

Take a look at boost::regex!
I solved it this way:

bool CXRTimeCtrl::CheckTime( const CString& strTemp ) const
{
    if (strTemp.IsEmpty() && bAllowEmptyTime_)
        return true;

    std::string strIn=strTemp;
    static const boost::regex exprFull("^(([0-1][0-9])|([1-2][0-3])):([0-5][0-9]):([0-5][0-9])$");
    static const boost::regex exprReduced("^(([0-1][0-9])|([1-2][0-3])):([0-5][0-9])$");
    boost::smatch what;
    bool bResult=false;
    if (bShowSeconds_)
        bResult=boost::regex_match(strIn, what, exprFull, boost::match_default | boost::match_partial)==true;
    else
        bResult=boost::regex_match(strIn, what, exprReduced, boost::match_default | boost::match_partial)==true;
    bError_= (bResult==false || what[0].matched==false);
    return bResult;
}

Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
dalai View Drop Down
Groupie
Groupie


Joined: 07 January 2011
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote dalai Quote  Post ReplyReply Direct Link To This Post Posted: 16 March 2011 at 3:00am
ok thanks, something like that would be useful in CXTPMaskEdit? instead I handled

BOOL CControlEditHHMMSSCtrl::CheckChar(TCHAR& nChar, int nPos)

to check characters
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.110 seconds.