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

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


Capturing WM_KEYDOWN in a CPropertyPage

Deepak Saxena -- Deepak_Saxena@ccm.ch.intel.com
Friday, July 26, 1996

Environment: VC 4.1, NT 3.51sp4

I have a property page that contains a listbox.  When the user selects
an item in the list box, I want him to be able to hit the DEL key to
remove the item.  However, I really don't want to derive a whole new
listbox class just to capture WM_KEYDOWN, so I'm just handling
WM_KEYDOWN
in my CPropertyPage derived class.  But...it seems that the
CPropertyPage
does not receive the notification.  Is there something I need to do to
ensure that my property page gets this message that does not require me
to a) derive my own CListBox based class, b) derive my own
CPropertySheet
based class?


-- 
Deepak_Saxena@ccm.ch.intel.com           | If you want my love,
http://cernan.ecn.purdue.edu/~deepak     | Don't just sit there and
shout it
Work: (602)554-1304, Home: (602)812-8933 | Do something about it.
My statements do not represent Intel     |          -Depeche Mode-



beriksen@cda.com
Wednesday, July 31, 1996

[Mini-digest: 4 responses]

     As I understand it, WM_KEYDOWN, if not handled by a control on a 
     dialog/page, is NOT necessarily sent to the dialog/page.  You may have 
     to handle this message within a derived CListBox class.
     
     Brian Eriksen
     CDA/Wiesenberger
     beriksen@cda.com


______________________________ Reply Separator _________________________________
Subject: Capturing WM_KEYDOWN in a CPropertyPage
Author:  mfc-l@netcom.com at Internet_Mail
Date:    7/31/96 6:05 AM


Environment: VC 4.1, NT 3.51sp4
     
I have a property page that contains a listbox.  When the user selects 
an item in the list box, I want him to be able to hit the DEL key to 
remove the item.  However, I really don't want to derive a whole new 
listbox class just to capture WM_KEYDOWN, so I'm just handling 
WM_KEYDOWN
in my CPropertyPage derived class.  But...it seems that the 
CPropertyPage
does not receive the notification.  Is there something I need to do to 
ensure that my property page gets this message that does not require me 
to a) derive my own CListBox based class, b) derive my own 
CPropertySheet
based class?
     
     
-- 
Deepak_Saxena@ccm.ch.intel.com           | If you want my love, 
http://cernan.ecn.purdue.edu/~deepak     | Don't just sit there and 
shout it
Work: (602)554-1304, Home: (602)812-8933 | Do something about it. 
My statements do not represent Intel     |          -Depeche Mode-

-----From: "Scott Andrew" 

The control recieves the notification not the CPropertyPage. The easiest
thing to do is to derive a class from a listbox. You can just add a KeyDown
handler from there. There is no way to do it without deriving your own
listbox class, unless you create your own WNDPROC that handles just the
WM_KEYDOWN and subclass the list box the oldfasion way. 

I would recommend deriving a class from the CListBox class. It's easy and
very little work.

Scott Andrew

-----From: Prakash N 
Environment: VC 4.1, NT 3.51sp4

Hi Deepak!!

	What I smell from your query is that you are trying to capture the =
WM_KEYDOWN message in a listbox control from a CPropertyPage dialog. You =
have not mentioned where you are writing the message handler. Since you =
have told "But...it seems that the CPropertyPage does not receive the =
notification", I presume that you have written your message map in your =
view class. Am I right?=20

But my dear chap, the behaviour of CDialog class is something peculiar =
(Your CPropertyPage is derived from CDialog and so I am talking in a =
base class perspective...).  The CDialog fellow never allows the =
messages from his child controls to go to view class.  All those =
messages from the child controls need to be processed only in the =
***Dialog*** class and *NOT* in the view class.  (In your case, =
CPropertyPage class).  So, handle the WM_KEYDOWN message from the =
listbox control (or whatever message from whatever child control of a =
dialog, for that matter...) in your propertypage class and phew!!! See =
your problem is nowhere ! ! ! !

By the way, what made you to think of "deriving a WHOLE NEW LISTBOX =
class *just* to handle WM_KEYDOWN message" ?? Do worry not... You don't =
have to do this which I feel is a dirty solution. Imagine having some =
hundred dialogs in your application each having at least 10 different =
child controls. Will you be interested in doing it in your way by having =
a class for each control which approximates 100 X 10 =3D 1000 classes =
???!!!!???  Samajgaya?

Cheers,
Prakash N
DEC, India.
pran@wings.xko.dec.com

-----From: "Anil Kumar K" 

You can add LBS_WANTKEYBOARDINPUT style to the listbox and handle the
WM_VKEYTOITEM message at the page level.

If the CWnd object owns a list box with the LBS_WANTKEYBOARDINPUT style, the
list box will send the WM_VKEYTOITEM message in response to a WM_KEYDOWN
message. 
This member function is called by the framework only for list boxes that have
the LBS_HASSTRINGS style.  

int CStylePage::OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex) 
{
	if (nKey == VK_DELETE)
	{
		pListBox->DeleteString(nIndex);
		return nIndex;
	}
	else
		return -1;
}


Hope this helps.


bye,
Anil Kumar .K
BFL Software ltd
Bangalore
INDIA



---------------------------------------------------------
Get Your *Web-Based* Free Email at http://www.hotmail.com
---------------------------------------------------------



Ravi -- Bikkula@albpig.cho.ge.com
Monday, August 05, 1996


Try writing pretranslatemessage for your property page.
That solves the problem

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@netcom.com]
Sent:  Wednesday, July 31, 1996 9:09 AM
To:  mfc-l
Subject:  Re: Capturing WM_KEYDOWN in a CPropertyPage

[Mini-digest: 4 responses]

     As I understand it, WM_KEYDOWN, if not handled by a control on a
     dialog/page, is NOT necessarily sent to the dialog/page.  You may   
have
     to handle this message within a derived CListBox class.
       

     Brian Eriksen
     CDA/Wiesenberger
     beriksen@cda.com


______________________________ Reply Separator
_________________________________
Subject: Capturing WM_KEYDOWN in a CPropertyPage
Author:  mfc-l@netcom.com at Internet_Mail
Date:    7/31/96 6:05 AM


Environment: VC 4.1, NT 3.51sp4
       

I have a property page that contains a listbox.  When the user selects
an item in the list box, I want him to be able to hit the DEL key to
remove the item.  However, I really don't want to derive a whole new
listbox class just to capture WM_KEYDOWN, so I'm just handling
WM_KEYDOWN
in my CPropertyPage derived class.  But...it seems that the
CPropertyPage
does not receive the notification.  Is there something I need to do to
ensure that my property page gets this message that does not require me
to a) derive my own CListBox based class, b) derive my own
CPropertySheet
based class?
       

       

 --
Deepak_Saxena@ccm.ch.intel.com           | If you want my love,
http://cernan.ecn.purdue.edu/~deepak     | Don't just sit there and
shout it
Work: (602)554-1304, Home: (602)812-8933 | Do something about it.
My statements do not represent Intel     |          -Depeche Mode-

 -----From: "Scott Andrew" 

The control recieves the notification not the CPropertyPage. The easiest
thing to do is to derive a class from a listbox. You can just add a   
KeyDown
handler from there. There is no way to do it without deriving your own
listbox class, unless you create your own WNDPROC that handles just the
WM_KEYDOWN and subclass the list box the oldfasion way.

I would recommend deriving a class from the CListBox class. It's easy and
very little work.

Scott Andrew

 -----From: Prakash N 
Environment: VC 4.1, NT 3.51sp4

Hi Deepak!!

        What I smell from your query is that you are trying to capture   
the =
WM_KEYDOWN message in a listbox control from a CPropertyPage dialog. You   
=
have not mentioned where you are writing the message handler. Since you =
have told "But...it seems that the CPropertyPage does not receive the =
notification", I presume that you have written your message map in your =
view class. Am I right?=20

But my dear chap, the behaviour of CDialog class is something peculiar =
(Your CPropertyPage is derived from CDialog and so I am talking in a =
base class perspective...).  The CDialog fellow never allows the =
messages from his child controls to go to view class.  All those =
messages from the child controls need to be processed only in the =
***Dialog*** class and *NOT* in the view class.  (In your case, =
CPropertyPage class).  So, handle the WM_KEYDOWN message from the =
listbox control (or whatever message from whatever child control of a =
dialog, for that matter...) in your propertypage class and phew!!! See =
your problem is nowhere ! ! ! !

By the way, what made you to think of "deriving a WHOLE NEW LISTBOX =
class *just* to handle WM_KEYDOWN message" ?? Do worry not... You don't =
have to do this which I feel is a dirty solution. Imagine having some =
hundred dialogs in your application each having at least 10 different =
child controls. Will you be interested in doing it in your way by having   
=
a class for each control which approximates 100 X 10 =3D 1000 classes =
???!!!!???  Samajgaya?

Cheers,
Prakash N
DEC, India.
pran@wings.xko.dec.com

 -----From: "Anil Kumar K" 

You can add LBS_WANTKEYBOARDINPUT style to the listbox and handle the
WM_VKEYTOITEM message at the page level.

If the CWnd object owns a list box with the LBS_WANTKEYBOARDINPUT style,   
the
list box will send the WM_VKEYTOITEM message in response to a WM_KEYDOWN
message.
This member function is called by the framework only for list boxes that   
have
the LBS_HASSTRINGS style.

int CStylePage::OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex)
{
        if (nKey == VK_DELETE)
        {
                pListBox->DeleteString(nIndex);
                return nIndex;
        }
        else
                return -1;
}


Hope this helps.


bye,
Anil Kumar .K
BFL Software ltd
Bangalore
INDIA



 ---------------------------------------------------------
Get Your *Web-Based* Free Email at http://www.hotmail.com
 ---------------------------------------------------------





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