Print Page | Close Window

OnCreateControl, edit control 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=2002
Printed Date: 27 April 2024 at 8:02am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: OnCreateControl, edit control in toolbar
Posted By: Maye Johnson
Subject: OnCreateControl, edit control in toolbar
Date Posted: 21 March 2005 at 9:39pm
I have an edit control in my toolbar that was created in OnCreateControl().  I want the user to be able to input, hit Enter, and have an action occur.  How do I capture the Enter key?



Replies:
Posted By: Oleg
Date Posted: 22 March 2005 at 5:47am

 

ON_XTP_EXECUTE(ID_EDIT_FIND, OnEditFind)

 

void CCustomThemesView::OnEditFind(NMHDR* pNMHDR, LRESULT* pResult)
{
 NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;

 CXTPControlEdit* pControl = (CXTPControlEdit*)tagNMCONTROL->pControl;
 if (pControl->GetType() == xtpControlEdit)
 {
  *pResult = 1; // Handled;
 }
}



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Maye Johnson
Date Posted: 22 March 2005 at 11:42am
I already have a handler, but it doesn't get called when the Enter key is pressed.  Maybe there's something wrong with my setup code?


.h file: CEdit                    m_GotoEdit;

.cpp file:
    //}}AFX_MSG_MAP
    ON_XTP_EXECUTE(IDC_TDLEDITOR_GOTO_EDIT, OnGoto)
    ON_XTP_CREATECONTROL()


int CTDLEditorFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{
    if (lpCreateControl->bToolBar)
    {
        CXTPToolBar* pToolBar = DYNAMIC_DOWNCAST(CXTPToolBar, lpCreateControl->pCommandBar);
        if (!pToolBar)
            return FALSE;

        if (pToolBar->GetBarID() == IDR_TDLEDITORGOTOBAR)
        {
            if (lpCreateControl->nID == IDC_TDLEDITOR_GOTO_EDIT)
            {
                CXTPControlCustom* pControl = (CXTPControlCustom*) CXTPControlCustom::CreateObject();
                if (!m_GotoEdit.Create(WS_CHILD | WS_VISIBLE | ES_NUMBER, CRect(0, 0, 90, 16), this, IDC_TDLEDITOR_GOTO_EDIT))
                    return FALSE;

                m_GotoEdit.SetLimitText(9);

                pControl->SetControl(&m_GotoEdit);
                lpCreateControl->pControl = pControl;
                return TRUE;
            }
        }
    }

    return FALSE;
}



Posted By: Maye Johnson
Date Posted: 22 March 2005 at 12:03pm
I added ES_WANTRETURN to the Create call, but it didn't change anything.  What I want is a masked input control in the toolbar, set to accept only numbers and have a specified input length.  That's why I used CEdit, but then I don't get the Enter key and the input field doesn't get outlined when the mouse is over it.


Posted By: Barto
Date Posted: 23 March 2005 at 8:03am

I have code like this that works for me:

ON_XTP_EXECUTE(ID_PARTNAME, OnPartname)
void CPartView::OnPartname(NMHDR* pNMHDR, LRESULT* pResult)
{
 CXTPControlEdit* pControl = (CXTPControlEdit*)((NMXTPCONTROL*)pNMHDR)->pControl;
 m_pPartRef->m_pPart->m_sName = pControl->GetEditText();
 GetDocument()->SetModifiedFlag();
 GetDocument()->UpdateAllViews(this);

 *pResult = TRUE;
}

ON_XTP_CREATECONTROL()
int CPartFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{
 if(lpCreateControl->nID == ID_PARTNAME) {
  CXTPControlEdit* pEdit = (CXTPControlEdit*)CXTPControlEdit::CreateObject();
  pEdit->SetWidth(250);
  lpCreateControl->pControl = pEdit;
  return TRUE;
 }
 return FALSE;
}



Posted By: xxcln
Date Posted: 25 June 2007 at 9:53pm
//header file
afx_msg void OnUpdateGoto(CCmdUI* pCmdUI);
//cpp file
ON_UPDATE_COMMAND_UI(ID_WINDOW_GOTO, OnUpdateGoto)
 
void CMainFrame::OnUpdateGoto(CCmdUI* pCmdUI)
{
 pCmdUI->Enable(MDIGetActive() != NULL);
}



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