日期时间选择器(DTP)两次WM_NOTIFY与MessageBox [英] date time picker (DTP) twice WM_NOTIFY with MessageBox

查看:93
本文介绍了日期时间选择器(DTP)两次WM_NOTIFY与MessageBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello,

如果用户选择星期六或星期日,将会执行WM_NOTIFY消息的显示分支。

the shown branch of the WM_NOTIFY-message will be executed, if the user chooses Saturday or Sunday.

如果选择了DTP,则仅处理分支。

The branch is only processed, if the DTP is choosen.

BOOL bBMAktiv应该阻止多次调用MessageBoxW()。但它几乎是

The BOOL bBMAktiv should prevent the MessageBoxW() to be called more than one time. But it will almost be

执行两次(有时一次),即使用户在选择器的日期部分只点击一次。

executed twice (sometime once), even if the user clicks only one time in the date part of the picker.

没有BOOL,用户可以激活无限的MessageBox-Windows。

Without the BOOL the user is able to activate unlimited MessageBox-Windows.

第二个MessageBox窗口总是在第一个消失之后出现。

The second MessageBox-window always appears after the first is disappered.

我试过PeekMessage()来清理消息循环(代码中的不同位置) ,但没有任何效果

I tried PeekMessage() to clean up the message loop (different positions in code), but nothing worked

(任务有时会崩溃)。

有什么建议吗?谢谢。

案例WM_NOTIFY:
{
static BOOL bMBAktiv = FALSE;
LPNMDATETIMECHANGE lpDTChange =(LPNMDATETIMECHANGE)lParam;

if((bMBAktiv == FALSE)&&(lpDTChange-> nmhdr.code == DTN_DATETIMECHANGE)&&(lpDTChange-> dwFlags == GDT_VALID))
{
if((lpDTChange-> st.wDayOfWeek == 0)||(lpDTChange-> st.wDayOfWeek == 6))
{
bMBAktiv = TRUE;
MessageBoxW(hWnd,L" Message to User",L" Any title",MB_OK | MB_ICONQUESTION);

case WM_NOTIFY: { static BOOL bMBAktiv = FALSE; LPNMDATETIMECHANGE lpDTChange = (LPNMDATETIMECHANGE) lParam; if ((bMBAktiv == FALSE) && (lpDTChange->nmhdr.code == DTN_DATETIMECHANGE) && (lpDTChange->dwFlags == GDT_VALID)) { if ((lpDTChange->st.wDayOfWeek == 0) || (lpDTChange->st.wDayOfWeek == 6)) { bMBAktiv = TRUE; MessageBoxW (hWnd, L"Message to User", L"Any title", MB_OK | MB_ICONQUESTION);

bMBAktiv = FALSE;
}
其他
//其他代码....
break;

bMBAktiv = FALSE; } else // other code.... break;




推荐答案

你是从0返回FALSE / 0你的WindowProc()处理程序?
$


请参阅最后一行o示例代码  https://msdn.microsoft.com/en-us/library/windows/desktop/hh298410(v = vs.85)。 aspx  。$


Are you returning FALSE/0 from your WindowProc() handler?

Refer to the last line o fteh sample code in  https://msdn.microsoft.com/en-us/library/windows/desktop/hh298410(v=vs.85).aspx .

    // All of the above notifications require the owner to return zero.
    return FALSE;

-Seetharam

-Seetharam


这篇关于日期时间选择器(DTP)两次WM_NOTIFY与MessageBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆