win32 api 关于按键(alt + e)声音有关问题
win32 api 关于按键(alt + e)声音问题
用api写了个小程序,但是按alt + e 总是有按键提示音 怎么去掉呢?
部分代码:
if((GetKeyState(VK_MENU) < 0) && wParam == 'E')
{
GetCursorPos(&pty);
ScreenToClient(hwnd, &pty);
hbr = (HBRUSH) GetStockObject (NULL_BRUSH);
yuan.center.x = ptd.x;
yuan.center.y = ptd.y;
yuan.radius = sqrt((pty.x-ptd.x)*(pty.x-ptd.x)+(pty.y-ptd.y)*(pty.y-ptd.y));
SelectObject(hdc, hPen);
SelectObject(hdc, hbr);
Ellipse(hdc, yuan.center.x - yuan.radius, yuan.center.y - yuan.radius, yuan.center.x + yuan.radius, yuan.center.y + yuan.radius);
UpdateWindow(hwnd);
DeleteObject(hbr);
ReleaseDC(hwnd, hdc);
break;
}
------解决思路----------------------
Nonsystem Character Messages
A window procedure can receive four different character messages, including WM_CHAR, WM_DEADCHAR, WM_SYSCHAR, and WM_SYSDEADCHAR. The TranslateMessage function generates a WM_CHAR or WM_DEADCHAR message when it processes a WM_KEYDOWN message. Similarly, it generates a WM_SYSCHAR or WM_SYSDEADCHAR message when it processes a WM_SYSKEYDOWN message.
An application that processes keyboard input typically ignores all but the WM_CHAR message, passing any other messages to the DefWindowProc function. The system uses the WM_SYSCHAR and WM_SYSDEADCHAR messages to implement menu mnemonics.
The wParam parameter of all character messages contains the character code of the character key that was pressed. The value of the character code depends on the window class of the window receiving the message. If the Unicode version of the RegisterClass function was used to register the window class, the system provides Unicode characters to all windows of that class. Otherwise, the system provides ASCII character codes. For more information, seeUnicode and Character Sets.
The contents of the lParam parameter of a character message are identical to the contents of the lParam parameter of the key-down message that was translated to produce the character message. For information, see Keystroke Message Flags.
用api写了个小程序,但是按alt + e 总是有按键提示音 怎么去掉呢?
部分代码:
if((GetKeyState(VK_MENU) < 0) && wParam == 'E')
{
GetCursorPos(&pty);
ScreenToClient(hwnd, &pty);
hbr = (HBRUSH) GetStockObject (NULL_BRUSH);
yuan.center.x = ptd.x;
yuan.center.y = ptd.y;
yuan.radius = sqrt((pty.x-ptd.x)*(pty.x-ptd.x)+(pty.y-ptd.y)*(pty.y-ptd.y));
SelectObject(hdc, hPen);
SelectObject(hdc, hbr);
Ellipse(hdc, yuan.center.x - yuan.radius, yuan.center.y - yuan.radius, yuan.center.x + yuan.radius, yuan.center.y + yuan.radius);
UpdateWindow(hwnd);
DeleteObject(hbr);
ReleaseDC(hwnd, hdc);
break;
}
------解决思路----------------------
Nonsystem Character Messages
A window procedure can receive four different character messages, including WM_CHAR, WM_DEADCHAR, WM_SYSCHAR, and WM_SYSDEADCHAR. The TranslateMessage function generates a WM_CHAR or WM_DEADCHAR message when it processes a WM_KEYDOWN message. Similarly, it generates a WM_SYSCHAR or WM_SYSDEADCHAR message when it processes a WM_SYSKEYDOWN message.
An application that processes keyboard input typically ignores all but the WM_CHAR message, passing any other messages to the DefWindowProc function. The system uses the WM_SYSCHAR and WM_SYSDEADCHAR messages to implement menu mnemonics.
The wParam parameter of all character messages contains the character code of the character key that was pressed. The value of the character code depends on the window class of the window receiving the message. If the Unicode version of the RegisterClass function was used to register the window class, the system provides Unicode characters to all windows of that class. Otherwise, the system provides ASCII character codes. For more information, seeUnicode and Character Sets.
The contents of the lParam parameter of a character message are identical to the contents of the lParam parameter of the key-down message that was translated to produce the character message. For information, see Keystroke Message Flags.