Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off beeping when pressing ENTER on a single-line EDIT control under Windows CE?

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.

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.

Thanks in advance.

like image 913
gablin Avatar asked Dec 08 '22 01:12

gablin


1 Answers

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. ^^

The final code now reads:


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 );
}
like image 57
gablin Avatar answered Apr 05 '23 23:04

gablin