|
-
April 12th, 2004, 12:07 PM
#1
stupid question again, help.
Hi
if I have a Slider control on my CFormview then it is always on Focus. My question is:
1. is that posible to set it un-focus if I click the mouse somewhere else? so
2. If I overide the functions: OnkeyDown, onKeyUP from CSliderCtrl , how to call the OnKeyDown() , OnKeyUp() the class that handle the view?
class CACPTESTView : public CFormView
{
public:
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
}
class CSliderCtrl2 : public CSliderCtrl
{
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
}
CSliderCtrl2::OnKeyDown(.....)
{
how to call the CACPTESTView::OnKeyDonw(...);
}
Thanks in millions.
-
April 12th, 2004, 12:18 PM
#2
1) I dont think so. Not if it is the only control. You could only place a dummy control somewhere else that gets the focus.
2)
I think the slider control is placed in the CACPTESTView, if that is so:
CSliderCtrl2::OnKeyDown(.....)
{
CACPTESTView* pView = (CACPTESTView*) GetParent();
pView->OnKeyDown(...);
}
A more conviencing way MIGHT be (normally the better way in more complex applications):
1) defining a new USER message (e.g. in CACPTEST.h):
#define WM_USER_ONSLIDERKEYDOWN WM_USER + 1
2) Send or post the message to the Parent window
CSliderCtrl2::OnKeyDown(.....)
{
GetParent()->SendMessage( WM_USER_ONSLIDERKEYDOWN, ... );
// or - for assynchronous execution without feedback via return value:
// GetParent()->PostMessage( WM_USER_ONSLIDERKEYDOWN, ... );
}
3) Create a handler for the WM_USER_ONSLIDERKEYDOWN message in the View class:
3a) add ON_MESSAGE( WM_USER_ONSLIDERKEYDOWN, ...) in the MESSAGE_MAP area of APCTESTView.c
3b) add an corresponding message handler method to CAFXTESTView class.
Last edited by Marco F; April 12th, 2004 at 12:27 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|