为什么响应WM_RBUTTONDBLCLK没有反应
#include<windows.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
static TCHAR szAppName[]=TEXT("DoubleClick");
static TCHAR szClassName[]=TEXT("DoubleClickClass");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName=szClassName;
wndclass.lpszMenuName=NULL;
wndclass.style=CS_VREDRAW|CS_HREDRAW;
if(!RegisterClass(&wndclass))
{
MessageBox(hwnd,TEXT("Wrong"),szAppName,MB_OK);
return 0;
}
hwnd=CreateWindow(szClassName,TEXT("KeyScroll"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
void CALLBACK out_text(int x,int y,char *text,HWND hwnd)
{
int x_scale,y_scale;
HDC TheDC;
TEXTMETRIC text_metrics;
TheDC=GetDC(hwnd);
GetTextMetrics(TheDC,&text_metrics);
y_scale=(y-1)*(text_metrics.tmHeight);
x_scale=(x-1)*(text_metrics.tmAveCharWidth);
TextOut(TheDC,x_scale,y_scale,text,strlen(text));
ReleaseDC(hwnd,TheDC);
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
char coord_string[80];
static int old_dblclk_time;
int new_dblclk_time;
PAINTSTRUCT ps;
switch(message)
{
case WM_CREATE:
old_dblclk_time=GetDoubleClickTime();
return 0;
case WM_PAINT:
BeginPaint(hwnd,&ps);
out_text(1,1,"Demonstration of setting the double clkick speed",hwnd);
out_text(1,2,"Press the left mouse button to increase delay time ",hwnd);
out_text(1,3,"Double click with the right mouse button ",hwnd);
out_text(1,4,"amount of pause avaliable between clicks grows as the",hwnd);
out_text(1,5,"time gets larger",hwnd);
EndPaint(hwnd,&ps);
return 0;
case WM_SIZE:
new_dblclk_time=GetDoubleClickTime();
sprintf(coord_string,"orig clk time-%d,new clk time-%d",old_dblclk_time,new_dblclk_time);
out_text(1,7,coord_string,hwnd);
return 0;
case WM_LBUTTONDOWN:
new_dblclk_time=(GetDoubleClickTime()*2);
if(new_dblclk_time>2000)
new_dblclk_time=250;
SetDoubleClickTime(new_dblclk_time);
sprintf(coord_string,"orig clk time-%d,new clk time-%d",old_dblclk_time,new_dblclk_time);
out_text(1,7,coord_string,hwnd);
return 0;
case WM_RBUTTONDOWN:
out_text(1,9,"right button pressed",hwnd);
return 0;
case WM_RBUTTONDBLCLK:
out_text(1,9,"Right button double click",hwnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return(DefWindowProc(hwnd,message,wParam,lParam));
}
}
如题