small doubt
-
Hi all i have void MyDialog::OnButton56() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 56, 1); pView->SendMessage(WM_CHAR,56,1); pView->SendMessage(WM_KEYUP, 56, 1); } void MyDialog::OnButton57() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 57, 1); pView->SendMessage(WM_CHAR,57,1); pView->SendMessage(WM_KEYUP, 57, 1); } void MyDialog::OnButton48() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 48, 1); pView->SendMessage(WM_CHAR,48,1); pView->SendMessage(WM_KEYUP, 48, 1); } where my dialog box is created in the frame and i am getting the pointer of view from CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); but i a creating it in each and every fuction which i don't want to do so i was trying to create in the Dialogs constructor so that too it to the CWnd pointer which is parent for all what do i needto write in the constructor ofthe dialog MyDialog::MyDialog(CWnd* pParent,CWnd* pView) : CDialog(MyDialog::IDD, pParent) { //pView =(CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); } Request to all to continue this
-
Hi all i have void MyDialog::OnButton56() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 56, 1); pView->SendMessage(WM_CHAR,56,1); pView->SendMessage(WM_KEYUP, 56, 1); } void MyDialog::OnButton57() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 57, 1); pView->SendMessage(WM_CHAR,57,1); pView->SendMessage(WM_KEYUP, 57, 1); } void MyDialog::OnButton48() { CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); pView->SendMessage(WM_KEYDOWN, 48, 1); pView->SendMessage(WM_CHAR,48,1); pView->SendMessage(WM_KEYUP, 48, 1); } where my dialog box is created in the frame and i am getting the pointer of view from CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); but i a creating it in each and every fuction which i don't want to do so i was trying to create in the Dialogs constructor so that too it to the CWnd pointer which is parent for all what do i needto write in the constructor ofthe dialog MyDialog::MyDialog(CWnd* pParent,CWnd* pView) : CDialog(MyDialog::IDD, pParent) { //pView =(CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); } Request to all to continue this
Tripura.K wrote: CTrailView *pView = (CTrailView *)((CMainFrame*)GetParent())->GetActiveView(); :eek:What is this? It is a guess based on the knowlege that only a certain view type will be a parent to this dialog. It also suggest.........(never mind)
// makes no since
MyDialog::MyDialog(CWnd* pParent,CWnd* pView)
: CDialog(MyDialog::IDD, pParent)
{
//pView =(CTrailView *)((CMainFrame*)GetParent())->GetActiveView();
}// This assumes it is a modal dialog and the view does not change,
MyDialog::MyDialog(CWnd* pParent,CWnd* pView)
: CDialog(MyDialog::IDD, pParent)
{
m_pView = pView;
}Simplify... all the function do the same thing.
void MyDialog::MyButton(TCHAR ch)
{
// ... write code here one time
}void MyDialog::OnButton56()
{
MyButton(56);
}void MyDialog::OnButton57()
{
MyButton(57);
}INTP