Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - OnCreateControl, edit control in toolbar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

OnCreateControl, edit control in toolbar

 Post Reply Post Reply
Author
Message
Maye Johnson View Drop Down
Groupie
Groupie


Joined: 16 October 2004
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Maye Johnson Quote  Post ReplyReply Direct Link To This Post Topic: OnCreateControl, edit control in toolbar
    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?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
Maye Johnson View Drop Down
Groupie
Groupie


Joined: 16 October 2004
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Maye Johnson Quote  Post ReplyReply Direct Link To This Post 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;
}

Back to Top
Maye Johnson View Drop Down
Groupie
Groupie


Joined: 16 October 2004
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Maye Johnson Quote  Post ReplyReply Direct Link To This Post 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.


Edited by Maye Johnson
Back to Top
Barto View Drop Down
Groupie
Groupie


Joined: 27 February 2005
Location: Germany
Status: Offline
Points: 60
Post Options Post Options   Thanks (0) Thanks(0)   Quote Barto Quote  Post ReplyReply Direct Link To This Post 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;
}

Back to Top
xxcln View Drop Down
Newbie
Newbie
Avatar

Joined: 05 June 2007
Location: China
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote xxcln Quote  Post ReplyReply Direct Link To This Post 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);
}
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.188 seconds.