开发者

After hiding dialog based app on windows mobile platform, user cannot activate it anymore

I am struggling with one problem in Windows Mobile programming (dialog based app).

I have dialog based MFC application. App is created like this:

BOOL MyApp::InitInstance()
{
    MainDlg dlg;
    dlg.DoModal();

    m_pMainWnd = &dlg;

    return FALSE;
}

This works just fine. But it has a big problem. If user minimizes application (for example by hitting "home button"), he cant retrieve application window again, which is unthinkable (because app some connections to external devices, and if this happenes, phone and device has to be reset).

I had a solution,开发者_StackOverflow中文版 but wasnt able to implement it: create CFrameWnd which will be the main window, and this window will "load" dialogs. This would mean, that application will have window and user will be able to use task manager and bring it to top (this was impossible, because dialog based app isnt listed in applications in task manager).

I would really appreciate a help from some experienced developer, who has better skills with MFC than me.

For more information: I am using eVC++ 4.0 with SP 3


Just a guess: The re-activation of the dialog somehow depends on the m_pMainWnd member, which isn't being set until after DoModal returns, i.e., when the dialog is closed. It'll not be closed when it gets hidden, so m_pMainWnd is left uninitialized.

Try setting it before calling DoModal.


Well, I finally figured it out. I had turned off Title bar, therefore task manager didnt show my app, because it didnt have any window.

But after launching app, it has title at taskbar and titlebar. To remove title bar & border, I left these options:

  • [OK] Title Bar
  • Border - thin

In code I did this:

BOOL MyDlg::OnInitDialog()
{
     ...

     ModifyStyle(WS_BORDER, 0, SWP_FRAMECHANGED);
     MoveWindow(...);
}

Now my application has window - it is visible in task manager, and also I am using as much space as possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜