Calling a function from another Class [newbie question]
-
Hello all, i know it's a newbie question but i couldn't find a replic or a sample code for such stuf. I have a CFormView Class and a CTest Class Derived CEdit Class. on both of them i have the OnKeyDown function, but what i want to do is to call the OnKeyDown fucnt of the deriver CEdit Class from the first one.. I declared a var with CTest var on the CFormView class and in the ONKeyDown (of the CFormView i did like this
void CMy01View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
this->cd2.OnKeyDown(nChar, nRepCnt, nFlags);
}and here the one of the CTest Class
void CTest::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{MessageBox("Blood 2"); CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
All go right but when i run it nothing will happen ?? how could i fix it ?? Thnk you
"The Ultimate Limit Is Only Your Imagination."
-
Hello all, i know it's a newbie question but i couldn't find a replic or a sample code for such stuf. I have a CFormView Class and a CTest Class Derived CEdit Class. on both of them i have the OnKeyDown function, but what i want to do is to call the OnKeyDown fucnt of the deriver CEdit Class from the first one.. I declared a var with CTest var on the CFormView class and in the ONKeyDown (of the CFormView i did like this
void CMy01View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
this->cd2.OnKeyDown(nChar, nRepCnt, nFlags);
}and here the one of the CTest Class
void CTest::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{MessageBox("Blood 2"); CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
All go right but when i run it nothing will happen ?? how could i fix it ?? Thnk you
"The Ultimate Limit Is Only Your Imagination."
Did you add ON_WM_KEYDOWN to your CEdit derived classes message map? Did you use DDX_Control to bind the edit control in the dialogue template to the instance of CTest in your Form View? I've just realised I didn't mention this when I suggested you implement a derived class of CEdit. Cheers, Ash PS: I know this is complicated, hang in there!
-
Hello all, i know it's a newbie question but i couldn't find a replic or a sample code for such stuf. I have a CFormView Class and a CTest Class Derived CEdit Class. on both of them i have the OnKeyDown function, but what i want to do is to call the OnKeyDown fucnt of the deriver CEdit Class from the first one.. I declared a var with CTest var on the CFormView class and in the ONKeyDown (of the CFormView i did like this
void CMy01View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
this->cd2.OnKeyDown(nChar, nRepCnt, nFlags);
}and here the one of the CTest Class
void CTest::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{MessageBox("Blood 2"); CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
All go right but when i run it nothing will happen ?? how could i fix it ?? Thnk you
"The Ultimate Limit Is Only Your Imagination."
Please dont remove/delete your messages once you think they have been answered - leaving them posted means someone else can read them to see if they have the same or similar problem as yours (I noticed you deleted an earlier one) 'g'
-
Please dont remove/delete your messages once you think they have been answered - leaving them posted means someone else can read them to see if they have the same or similar problem as yours (I noticed you deleted an earlier one) 'g'
@ Garth: Sorry for deleting the message, i thought it was like in other forums when it's solved we may delete it to avoid the dump. @ Aescleal: I found a wasty manner to solve my prob (OnKeyDown related) which is
void CSdiView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call defaultif((nChar<=0x30)&& (nChar>= 0x39)) AfxMessageBox("Number"); CFormView::OnKeyDown(nChar, nRepCnt, nFlags);
}
BOOL CSdiView::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base classBOOL bHandleNow = false; switch (pMsg->message) { case WM\_KEYDOWN: switch (pMsg->wParam) { case 0x39: case 0x38: case 0x37: case 0x36: case 0x35: case 0x34: case 0x33: case 0x32: case 0x31: case 0x30: bHandleNow = TRUE; break; } if (bHandleNow) OnKeyDown(pMsg->wParam, LOWORD(pMsg->lParam), HIWORD(pMsg->lParam)); break; } return bHandleNow;
}
but i m only able to detected Numbers and Upper Cases Letters like A-Z and no a-z (another problem but at least i was able to detetect numbers an capital letters :rolleyes:
"The Ultimate Limit Is Only Your Imagination."