user-0 提问: lParam获取的鼠标位LOWORD,HIWORD有问题，有的时候点了没有显示

回复:
user: user-1
content: f 之后一直是 FALSE

user: user-1
content: 引用 3 楼 qq_30519181 的回复:[quote=引用 1 楼 paschen 的回复:] 获得的是屏幕坐标，要转换成客户区坐标在操作！额。。。我修改了一下            point.x=LOWORD(lParam);    point.y=HIWORD(lParam);            ScreenToClient(hwnd,&point);    px=(point.x-115)/30+1;    py=(point.y-115)/30+1;可是改了之后更加不对了[/quote]   case WM_LBUTTONDOWN: 		px=(LOWORD(lParam)-115)/30+1; 		py=(HIWORD(lParam)-115)/30+1; 		if(px<=15&&py<=15&&f&&qizi[px][py]==0) 		{ 			qizi[px][py]=1; 			f=!f; 			InvalidateRect(hwnd,NULL,FALSE); 		} 		else 			MessageBeep(0);   		return 0;   我知道你什么原因了，之前代码没细看，你代码中if(px<=15&&py<=15&&f&&qizi[px][py]==0) 这句第二次一直是是FALSE，导致即使点击了左键，也不会运行qizi[px][py]=1;这一句

user: user-2
content: LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) {     static BOOL f=TRUE;     int x,px,py,y,i,j;     static int qizi[15][15];     RECT rect;     switch(message) {     case WM_CREATE:         for(i=0;i<15;i++)             for(j=0;j<15;j++)                 qizi[i][j]=0;         return 0;      case WM_LBUTTONDOWN:         px=(LOWORD(lParam)-115)/30+1;         py=(HIWORD(lParam)-115)/30+1;         if(px<=15&&py<=15&&f&&qizi[px][py]==0) {             qizi[px][py]=1;             f=!f;             InvalidateRect(hwnd,NULL,FALSE);         } else             MessageBeep(0);         return 0;      case WM_RBUTTONDOWN:         px=(LOWORD(lParam)-115)/30+1;         py=(HIWORD(lParam)-115)/30+1;         if(px<=15&&py<=15&&!f&&qizi[px][py]==0) {             qizi[px][py]=2;             f=!f;             InvalidateRect(hwnd,NULL,FALSE);         } else             MessageBeep(0);         return 0;      case WM_PAINT:         HDC hdc;         PAINTSTRUCT ps;         hdc=BeginPaint(hwnd,&ps);         HBRUSH hobrush,hbrush1,hbrush2;         hbrush1=CreateSolidBrush(RGB(0,0,0));         hbrush2=CreateSolidBrush(RGB(255,255,255));         for(x=0;x<15;x++) {             MoveToEx(hdc,100+30*x,100,NULL);             LineTo(hdc,100+30*x,520);             MoveToEx(hdc,100,100+30*x,NULL);             LineTo(hdc,520,100+30*x);         }         hobrush=SelectObject(hdc,hbrush1);         for(x=0;x<15;x++)             for(y=0;y<15;y++) {                 if(qizi[x][y]==1) {                     SelectObject(hdc,hbrush1);                     Ellipse(hdc,(100+30*x)-sr,(100+30*y)-sr,(100+30*x)+sr,(100+30*y)+sr);                 } else if(qizi[x][y]==2) {                     SelectObject(hdc,hbrush2);                     Ellipse(hdc,(100+30*x)-sr,(100+30*y)-sr,(100+30*x)+sr,(100+30*y)+sr);                 }             }         SelectObject(hdc,hobrush);         DeleteObject(hbrush2);         DeleteObject(hbrush1);         EndPaint(hwnd,&ps);         return 0;     case WM_DESTROY:         PostQuitMessage(0);         return 0;      }     return DefWindowProc(hwnd,message,wParam,lParam); }

user: user-2
content: DeleteObject The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. After the object is deleted, the specified handle is no longer valid.   BOOL DeleteObject(   HGDIOBJ hObject   // handle to graphic object );   Parameters hObject  Handle to a logical pen, brush, font, bitmap, region, or palette.  Return Values If the function succeeds, the return value is nonzero.  If the specified handle is not valid or is currently selected into a device context, the return value is zero.   Windows NT: To get extended error information, callGetLastError.  Remarks Do not delete a drawing object (pen or brush) while it is still selected into a device context.  When a pattern brush is deleted, the bitmap associated with the brush is not deleted. The bitmap must be deleted independently.   Windows CE: The DeleteObject function returns false if the object is currently selected into a device context.  QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Requires version 1.0 or later.   Header: Declared in wingdi.h.   Import Library: Use gdi32.lib.  See Also Device Contexts Overview, Device Context Functions, SelectObject

user: user-0
content: 额。。。我修改了一下            point.x=LOWORD(lParam); 	   point.y=HIWORD(lParam);            ScreenToClient(hwnd,&point); 	   px=(point.x-115)/30+1; 	   py=(point.y-115)/30+1;可是改了之后更加不对了

user: user-0
content: 引用 1 楼 paschen 的回复:获得的是屏幕坐标，要转换成客户区坐标在操作！额。。。我修改了一下            point.x=LOWORD(lParam);    point.y=HIWORD(lParam);            ScreenToClient(hwnd,&point);    px=(point.x-115)/30+1;    py=(point.y-115)/30+1;可是改了之后更加不对了

user: user-1
content: 获得的是屏幕坐标，要转换成客户区坐标在操作！