DXGL r32 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r31‎ | r32 | r33 >
Date:22:25, 18 December 2011
Author:admin
Status:new
Tags:
Comment:
Handle mouse moves in ddraw render window
Finish DXGLTest mouse test
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /dxgltest/Tests2D.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -1388,11 +1388,50 @@
13891389 }
13901390 LRESULT glDirectDraw7::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
13911391 {
 1392+ int oldx,oldy;
 1393+ float mulx, muly;
 1394+ int translatex, translatey;
 1395+ LPARAM newpos;
 1396+ HWND hParent;
 1397+ LONG sizes[6];
 1398+ HCURSOR cursor;
13921399 if(msg == WM_CREATE)
13931400 {
13941401 SetWindowLongPtr(hwnd,GWLP_USERDATA,(LONG_PTR)this);
13951402 return 0;
13961403 }
 1404+ if(msg == WM_SETCURSOR)
 1405+ {
 1406+ hParent = GetParent(hwnd);
 1407+ cursor = (HCURSOR)GetClassLong(hParent,GCL_HCURSOR);
 1408+ SetCursor(cursor);
 1409+ return SendMessage(hParent,msg,wParam,lParam);
 1410+ }
 1411+ if((msg >= WM_MOUSEFIRST) && (msg <= WM_MOUSELAST))
 1412+ {
 1413+ hParent = GetParent(hwnd);
 1414+ if((dxglcfg.scaler != 0) && fullscreen)
 1415+ {
 1416+ oldx = LOWORD(lParam);
 1417+ oldy = HIWORD(lParam);
 1418+ GetSizes(sizes);
 1419+ mulx = (float)sizes[2] / (float)sizes[0];
 1420+ muly = (float)sizes[3] / (float)sizes[1];
 1421+ translatex = (sizes[4]-sizes[0])/2;
 1422+ translatey = (sizes[5]-sizes[1])/2;
 1423+ oldx -= translatex;
 1424+ oldy -= translatey;
 1425+ oldx = (int)((float)oldx * mulx);
 1426+ oldy = (int)((float)oldy * muly);
 1427+ if(oldx < 0) oldx = 0;
 1428+ if(oldy < 0) oldy = 0;
 1429+ if(oldx >= sizes[2]) oldx = sizes[2]-1;
 1430+ if(oldy >= sizes[3]) oldy = sizes[3]-1;
 1431+ newpos = oldx + (oldy << 16);
 1432+ return SendMessage(hParent,msg,wParam,newpos);
 1433+ }
 1434+ else return SendMessage(hParent,msg,wParam,lParam);
 1435+ }
13971436 return DefWindowProc(hwnd,msg,wParam,lParam);
13981437 }
13991438 void glDirectDraw7::GetHandles(HWND *hwnd, HWND *hrender)
Index: dxgltest/Tests2D.cpp
@@ -132,7 +132,21 @@
133133 if(paintwnd) EndPaint(hWnd,&paintstruct);
134134 return 0;
135135 case WM_MOUSEMOVE:
136 - RunTestMouse(testnum,WM_MOUSEMOVE,wParam,lParam);
 136+ case WM_LBUTTONDOWN:
 137+ case WM_LBUTTONUP:
 138+ case WM_LBUTTONDBLCLK:
 139+ case WM_RBUTTONDOWN:
 140+ case WM_RBUTTONUP:
 141+ case WM_RBUTTONDBLCLK:
 142+ case WM_MBUTTONDOWN:
 143+ case WM_MBUTTONUP:
 144+ case WM_MBUTTONDBLCLK:
 145+ case WM_MOUSEWHEEL:
 146+ case WM_XBUTTONDOWN:
 147+ case WM_XBUTTONUP:
 148+ case WM_XBUTTONDBLCLK:
 149+ case WM_MOUSEHWHEEL:
 150+ RunTestMouse(testnum,Msg,wParam,lParam);
137151 if(!fullscreen)
138152 {
139153 p.x = 0;
@@ -200,6 +214,48 @@
201215 case WM_MOUSEMOVE:
202216 _tcscat(message,_T("WM_MOUSEMOVE "));
203217 break;
 218+ case WM_LBUTTONDOWN:
 219+ _tcscat(message,_T("WM_LBUTTONDOWN "));
 220+ break;
 221+ case WM_LBUTTONUP:
 222+ _tcscat(message,_T("WM_LBUTTONUP "));
 223+ break;
 224+ case WM_LBUTTONDBLCLK:
 225+ _tcscat(message,_T("WM_LBUTTONDBLCLK "));
 226+ break;
 227+ case WM_RBUTTONDOWN:
 228+ _tcscat(message,_T("WM_RBUTTONDOWN "));
 229+ break;
 230+ case WM_RBUTTONUP:
 231+ _tcscat(message,_T("WM_RBUTTONUP "));
 232+ break;
 233+ case WM_RBUTTONDBLCLK:
 234+ _tcscat(message,_T("WM_RBUTTONDBLCLK "));
 235+ break;
 236+ case WM_MBUTTONDOWN:
 237+ _tcscat(message,_T("WM_MBUTTONDOWN "));
 238+ break;
 239+ case WM_MBUTTONUP:
 240+ _tcscat(message,_T("WM_MBUTTONUP "));
 241+ break;
 242+ case WM_MBUTTONDBLCLK:
 243+ _tcscat(message,_T("WM_MBUTTONDBLCLK "));
 244+ break;
 245+ case WM_MOUSEWHEEL:
 246+ _tcscat(message,_T("WM_MOUSEWHEEL "));
 247+ break;
 248+ case WM_XBUTTONDOWN:
 249+ _tcscat(message,_T("WM_XBUTTONDOWN "));
 250+ break;
 251+ case WM_XBUTTONUP:
 252+ _tcscat(message,_T("WM_XBUTTONUP "));
 253+ break;
 254+ case WM_XBUTTONDBLCLK:
 255+ _tcscat(message,_T("WM_XBUTTONDBLCLK "));
 256+ break;
 257+ case WM_MOUSEHWHEEL:
 258+ _tcscat(message,_T("WM_MOUSEHWHEEL "));
 259+ break;
204260 default:
205261 _tcscat(message,_T("unknown "));
206262 }