在Windows CE下在单行EDIT控件上按ENTER键时,如何关闭提示音? [英] How to turn off beeping when pressing ENTER on a single-line EDIT control under Windows CE?

查看:111
本文介绍了在Windows CE下在单行EDIT控件上按ENTER键时,如何关闭提示音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发针对使用C ++和本机WINAPI(即没有MFC等)的POCKET PC 2003(Windows CE 4.2)设备的应用程序.在其中,我有一个单行编辑控件,它位于主窗口的哪个部分(不是一个对话框);因此,Windows在按ENTER键时的正常行为是只发出哔声.

I'm developing an application targeted to a POCKET PC 2003 (Windows CE 4.2) device using C++ and native WINAPI (i.e. no MFC or the like). In it I have a single-line edit control which part of the main window (not a dialog); hence the normal behaviour of Windows when pressing ENTER is to do nothing but beep.

我使用以下代码将窗口过程子类化为编辑控件,以覆盖默认行为:

I've subclassed the window procedure for the edit control to override the default behaviour using the following code:


LRESULT CALLBACK Gui::ItemIdInputProc( HWND hwnd, UINT message, WPARAM wParam,
    LPARAM lParam ) {

    switch ( message ) {
        case WM_KEYDOWN :
            switch ( wParam ) {
                case VK_RETURN :
                    addNewItem();
                    return 0;
            }
    }

    return CallWindowProc( oldItemIdInputProc_, hwnd, message, wParam, lParam );
}

这导致与按确定"按钮等效的行为.

This causes the equivalent behaviour as pressing the 'OK' button.

由于手头的问题:此窗口过程不会覆盖发出哔声的默认行为.我怀疑还存在一些其他消息或某些消息,这些消息是由于我无法捕获而在按ENTER键时触发的;我只是不知道哪个.我真的想阻止设备发出蜂鸣声,因为当出现物品碰撞时,它会弄乱在某些情况下播放的其他声音,因此提醒用户这一点至关重要.

Now to the problem at hand: this window procedure does not override the default behaviour of making a beep. I suspect that there must be some other message or messages which are triggered as ENTER is pressed that I fail to capture; I just can't figure out which. I really want to stop the device from beeping as it messes up other sounds that are played in certain circumstances when an item collision occurs, and it is crucial that the user is alerted about that.

谢谢.

推荐答案

所有消息喷出到日志文件后,我终于设法找出引起蜂鸣的消息-WM_CHARwParam设置为VK_RETURN.停止将该消息转发到编辑控件就停止了哔哔声. ^^

After spewing all messages to a log file, I finally managed to figure out which message was causing the beeping - WM_CHAR with wParam set to VK_RETURN. Stopping that message from being forwarded to the edit control stopped the beeping. ^^

现在的最终代码为:


LRESULT CALLBACK Gui::ItemIdInputProc( HWND hwnd, UINT message, WPARAM wParam,
    LPARAM lParam ) {

    switch ( message ) {
        case WM_CHAR :
            switch ( wParam ) {
                case VK_RETURN :
                    addNewItem();
                    return 0;
            }
    }

    return CallWindowProc( oldItemIdInputProc_, hwnd, message, wParam, lParam );
}

这篇关于在Windows CE下在单行EDIT控件上按ENTER键时,如何关闭提示音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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