Calling a function defined in the View Class 
Author Message
 Calling a function defined in the View Class

Hi,

I have written an SDI application and want to call a function (in the View)
immediately after the splash screen has been destroyed.

That is, in the splash code:

void CSplashWnd::HideSplashScreen()
{
        CWnd* pMainWnd = AfxGetMainWnd();
        DestroyWindow();
//    I want to call a function in the View here.
        pMainWnd->UpdateWindow();

Quote:
}

Does anybody know how to do this?

Thanks

DAVE



Tue, 01 Aug 2000 03:00:00 GMT  
 Calling a function defined in the View Class

You could send a userdefined message to the mainwindow.

void CSplashWnd::HideSplashScreen()
{
    ....
    AfxGetMainWnd()->SendMessage(WM_APP+1,0,0);
    ....

Quote:
}

//
// Now add a handler for the message in mainfrm.cpp/mainfrm.h
//

// Insert the following line just before DECLARE_MESSAGE_MAP() in the
// CMainFrame class.

LRESULT OnMyMessage(WPARAM wp, LPARAM lp);

// Add function body to mainfrm.cpp

LRESULT CMainFrame::OnMyMessage(WPARAM, LPARAM)
{
    //
    // Youy code goes here
    //
    return 0;

Quote:
}

David John Evans skrev i meddelelsen ...
Quote:
>Hi,

>I have written an SDI application and want to call a function (in the View)
>immediately after the splash screen has been destroyed.

>That is, in the splash code:

>void CSplashWnd::HideSplashScreen()
>{
>        CWnd* pMainWnd = AfxGetMainWnd();
>        DestroyWindow();
>//    I want to call a function in the View here.
>        pMainWnd->UpdateWindow();
>}

>Does anybody know how to do this?

>Thanks

>DAVE



Tue, 01 Aug 2000 03:00:00 GMT  
 Calling a function defined in the View Class

Sorry the prev message was for calling a message in the main frame class --
now what you whanted. I'll try again.

void CSplashWnd::HideSplashScreen()
{
    ....
    CWnd* pWnd = AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_PANE_FIRST);
    if(pWnd)
        pWnd->SendMessage(WM_APP+1);
    ....

Quote:
}

// Insert the following line just before DECLARE_MESSAGE_MAP() in your
// views class definition.
LRESULT OnMyMessage(WPARAM wp, LPARAM lp);

// Add function your views .cpp file

LRESULT CMyView::OnMyMessage(WPARAM, LPARAM)
{
    //
    // Youy code goes here
    //
    return 0;

Quote:
}

David John Evans skrev i meddelelsen ...
Quote:
>Hi,

>I have written an SDI application and want to call a function (in the View)
>immediately after the splash screen has been destroyed.

>That is, in the splash code:

>void CSplashWnd::HideSplashScreen()
>{
>        CWnd* pMainWnd = AfxGetMainWnd();
>        DestroyWindow();
>//    I want to call a function in the View here.
>        pMainWnd->UpdateWindow();
>}

>Does anybody know how to do this?

>Thanks

>DAVE



Tue, 01 Aug 2000 03:00:00 GMT  
 Calling a function defined in the View Class

YOU ALSO NEED TO DO THIS !!!!

// Insert this line in views .cpp file just before END_MESSAGE_MAP()

ON_MESSAGE(WM_APP+1, OnMyMessage)

// This works for me :-)


Quote:
>Sorry the prev message was for calling a message in the main frame class --
>now what you whanted. I'll try again.

>void CSplashWnd::HideSplashScreen()
>{
>    ....
>    CWnd* pWnd = AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_PANE_FIRST);
>    if(pWnd)
>        pWnd->SendMessage(WM_APP+1);
>    ....
>}

>// Insert the following line just before DECLARE_MESSAGE_MAP() in your
>// views class definition.
>LRESULT OnMyMessage(WPARAM wp, LPARAM lp);

>// Add function your views .cpp file

>LRESULT CMyView::OnMyMessage(WPARAM, LPARAM)
>{
>    //
>    // Youy code goes here
>    //
>    return 0;
>}

>David John Evans skrev i meddelelsen ...
>>Hi,

>>I have written an SDI application and want to call a function (in the
View)
>>immediately after the splash screen has been destroyed.

>>That is, in the splash code:

>>void CSplashWnd::HideSplashScreen()
>>{
>>        CWnd* pMainWnd = AfxGetMainWnd();
>>        DestroyWindow();
>>//    I want to call a function in the View here.
>>        pMainWnd->UpdateWindow();
>>}

>>Does anybody know how to do this?

>>Thanks

>>DAVE



Tue, 01 Aug 2000 03:00:00 GMT  
 Calling a function defined in the View Class

And make sure you've got the view created. You can create it and hide it
until you need it if you have to.

--Agent



Sun, 06 Aug 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Calling View class from User define class

2. class view dosen't shows member variable's and functions defined with macros

3. What function can I call from View class?

4. Calling a function in the view class

5. calling a function in view class from dialog

6. how to call func defined in class A from class B

7. Calling a member of a View Class from the CWinApp Class

8. destructor is called before copy-constructor on temporary class (allocated on stack during function call)

9. View class functions needed by other class

10. newbie One class calling functions in another class

11. Inherited class function calls from a pointer assigned to the base class

12. class view dosen't shows member variable's defined with macros

 

 
Powered by phpBB® Forum Software