15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Handling Return in CTreeCtrl

Ray Frohnhoefer -- rayf@datatree.com
Friday, September 06, 1996

Environment: VC++4.2, Win95

I have a CTreeControl on a dialog box on a property page.  When I
double-click, the nodes are expanded or collapsed.  I am trying to get the
same effect from hitting the return key, but the overrides for messages
NM_RETURN and TVN_KEYDOWN never get control.  I've used SPY and see the
WM_KEYDOWN message and can capture it in PreTranslateMessage, but then don't
know all the "protocol" of what messages need to be send to contract/expand
nodes, and handle some of the other actions of the control which are
"hidden".  Can anyone suggest a workaround or some other problem I may be
missing?

TIA
Ray F

           Gott wuerfelt nicht.
                        - Albert Einstein                     
----------------------------------------------------------------------------
*  Ray Frohnhoefer                email: rayf@datatree.com, Frohnzie@aol.com
*  DataTree Corporation           web:   http://www.datatree.com       
*  550 West C Street, Ste. 2040   phone: (619) 231-3300 x131            
*  San Diego, CA  92101           fax:   (619) 231-3301
*                                  




Ravi -- Bikkula@albpig.cho.ge.com
Saturday, September 07, 1996


Hi  Ray,
 I faced similar problem when I wanted to end the editing of items
with return in Tree control. Basically you need to implement   
Pretranslatemessage for
your property page and catch the keys you require.
Following code of mine  may be useful to you.

#############################################################

BOOL CXXXPage::PreTranslateMessage(MSG* pMsg)
{
 if (m_bEdting)
 {
  if (pMsg->message == WM_KEYDOWN)
  {
   if(pMsg->wParam == VK_RETURN)
   {
    CString pointName;
    m_pointEdit->GetWindowText(pointName);
    HTREEITEM hItem =  m_pointsTree.GetSelectedItem();
    //todo
    return TRUE;
   }
   else
   {
    if(pMsg->wParam == VK_ESCAPE)
    {
     m_pointEdit->Undo();
     return TRUE;
    }
           return CMyPropPage::PreTranslateMessage(pMsg);
   }
  }
 }
 }
 return CMyPropPage::PreTranslateMessage(pMsg);
}

#############################################################

Thanx and Regards
...................................................................
Ravi Kumar Bikkula
Off :                                                 Res :
GE Fanuc Automation                   4,Farnsworth Drive , Apt #9
Albany, NY 12203 5189                Slingerlands, NY 12159
Ph #  (518) 464-4695                    Ph # (518) 869-8515
mail :              Bikkula@albpig.cho.ge.com
 -------------------------------------------------------------------------

                                                                            
                             



 ----------
From:  owner-mfc-l[SMTP:owner-mfc-l@majordomo.netcom.com]
Sent:  Friday, September 06, 1996 10:46 AM
To:  mfc-l
Subject:  Handling Return in CTreeCtrl

Environment: VC++4.2, Win95

I have a CTreeControl on a dialog box on a property page.  When I
double-click, the nodes are expanded or collapsed.  I am trying to get   
the
same effect from hitting the return key, but the overrides for messages
NM_RETURN and TVN_KEYDOWN never get control.  I've used SPY and see the
WM_KEYDOWN message and can capture it in PreTranslateMessage, but then   
don't
know all the "protocol" of what messages need to be send to   
contract/expand
nodes, and handle some of the other actions of the control which are
"hidden".  Can anyone suggest a workaround or some other problem I may be
missing?

TIA
Ray F

           Gott wuerfelt nicht.
                        - Albert Einstein
 --------------------------------------------------------------------------  
 --
*  Ray Frohnhoefer                email: rayf@datatree.com,   
Frohnzie@aol.com
*  DataTree Corporation           web:   http://www.datatree.com
*  550 West C Street, Ste. 2040   phone: (619) 231-3300 x131
*  San Diego, CA  92101           fax:   (619) 231-3301
*






| Вернуться в корень Архива |