MessageBox()在觸摸屏上的WM_ACTIVATEAPP中沒有響應

[英]MessageBox() not responsing in WM_ACTIVATEAPP on touchscreen


I notice that MessageBox routine (or any modal dialog) is not responsing (hanging) in WM_ACTIVATEAPP message processing while activating an app via touchscreen, whereas activating an app via mouse works fine.

我注意到MessageBox例程(或任何模態對話框)在通過觸摸屏激活應用程序時不響應(掛起)WM_ACTIVATEAPP消息處理,而通過鼠標激活應用程序工作正常。

case WM_ACTIVATEAPP:
    MessageBox(hWnd, TEXT("Not responsing with touchscreen"), TEXT("Help!"), MB_OK);
break;

The message box is showing without responsing of mouse-click or finger-touch and the whole application is freezing - I have to kill app by using task manager.

消息框顯示而不響應鼠標單擊或手指觸摸,整個應用程序凍結 - 我必須使用任務管理器殺死應用程序。

Is it a knowing bug of Win32 API? Is there any work around for this problem?

它是Win32 API的一個知道錯誤嗎?有沒有解決這個問題的方法?

1 个解决方案

#1


2  

WM_ACTIVATEAPP is a "difficult" message, your app is in an awkward state with your window in the process of getting activated and getting the focus but it did not yet get there by the time you get the message. You never want to do anything to block the message handler and write code that requires the active window to be known or change the active window. Like MessageBox() does. A deadlock is not unusual, especially so in a 32-bit app that runs in the Wow64 emulator.

WM_ACTIVATEAPP是一個“困難”的消息,你的應用程序處於一個尷尬的狀態,你的窗口正在被激活並獲得焦點,但是當你收到消息時它還沒有到達那里。您永遠不想做任何事情來阻止消息處理程序並編寫需要知道活動窗口的代碼或更改活動窗口。像MessageBox()一樣。死鎖並不罕見,尤其是在Wow64模擬器中運行的32位應用程序中。

Don't block, simply delay the displaying of the message box:

不要阻止,只是延遲顯示消息框:

case WM_ACTIVATEAPP:
    PostMessage(hWnd, WM_USER, NULL, NULL);
    DefWindowProc(hWnd, msg, wparam, lparam);
    break;
case WM_USER:
    MessageBox(hWnd, TEXT("Responsing with touchscreen"), TEXT("Okay!"), MB_OK); 
    break;

Whether the DefWindowProc() call is necessary is a guess, you didn't post enough code.

是否需要DefWindowProc()調用是猜測,你沒有發布足夠的代碼。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2016/01/15/72f7c1e000c92ebf3710a6e617cb0c9e.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com