c++

I have created a dialog that runs on the main thread of an MFC application. While this dialog is made modal, it does a few things on the main thread (ie message pump thread) that takes time. Whenever something takes time, I create an automatic variable using the MFC class CWaitCursor.

While in the OnInitDialog method, it works as intended. However, If I do the same past the end of OnInitDialog, like for example in a method called in response to a custom Window Message, the the wait cursor doesn't show up. However, if I "activate the application" using EveryWAN (which is a remote control application allowing to see and control the device from the PC), then the cursor DOES show up.

I could provide the code, but it's filled with a lot of stuff that is unlikely to be related to the problem. I'll just write an example code instead that shows what I just tried to explain :

class MyDialog : public CDialog
{
public:

    BOOL OnInitDialog()
    {
        CWaitCusor oWaitCursor; // Shows wait cursor.
        Sleep( 5000 );
        PostMessage( WM_FOO, 0, 0 );
    }

    LRESULT OnFoo( WPARAM wParam, LPARAM lParam )
    {
        CWaitCusor oWaitCursor; // Does NOT show wait cursor, unless I "activate" the application...
        Sleep( 5000 );
    }
};

Do you have an idea of what could cause the wait cursor not to show up past InInitDialog ? Is it a Windows CE bug ? Is it a focus, screen refresh or a z-index problem ? Thank you.

链接地址: http://www.djcxy.com/p/39244.html

上一篇: MOUSEMOVE是由触摸/笔造成的

下一篇: C ++