Преглед на файлове

Update MSG type for NG.

woollybah преди 5 години
родител
ревизия
8a16992096
променени са 2 файла, в които са добавени 96 реда и са изтрити 9 реда
  1. 53 9
      win32.mod/user32.bmx
  2. 43 0
      win32.mod/user32.cpp

+ 53 - 9
win32.mod/user32.bmx

@@ -748,15 +748,6 @@ Const WA_INACTIVE=0
 Const WA_ACTIVE=1
 Const WA_CLICKACTIVE=2
 
-Type MSG
-	Field hWnd:Byte Ptr
-	Field message
-	Field wp:WParam
-	Field lp:LParam
-	Field time
-	Field pt_x,pt_y
-End Type
-
 Type WNDCLASS
 	Field style
 	Field lpfnWndProc:Byte Ptr
@@ -1126,7 +1117,60 @@ Type TRACKMOUSEEVENT
 	End Method
 	
 End Type
+' MSG
+Extern
+	Function bmx_win32_MSG_new:Byte Ptr()
+	Function bmx_win32_MSG_free(handle:Byte Ptr)
+	Function bmx_win32_MSG_GetHwnd:Byte Ptr(handle:Byte Ptr)
+	Function bmx_win32_MSG_GetMessage:UInt(handle:Byte Ptr)
+	Function bmx_win32_MSG_GetWParam:WParam(handle:Byte Ptr)
+	Function bmx_win32_MSG_GetLParam:LParam(handle:Byte Ptr)
+	Function bmx_win32_MSG_GetTime:Int(handle:Byte Ptr)
+	Function bmx_win32_MSG_GetPt(handle:Byte Ptr, x:Int Var, y:Int Var)
+End Extern
+Type MSG
+	Field msgPtr:Byte Ptr
+	
+	Method New()
+		msgPtr = bmx_win32_MSG_new()
+	End Method
 
+	Method Delete()
+		Free()
+	End Method
+	
+	Method Free()
+		If msgPtr Then
+			bmx_win32_MSG_free(msgPtr)
+			msgPtr = Null
+		End If
+	End Method
+	
+	Method GetHwnd:Byte Ptr()
+		Return bmx_win32_MSG_GetHwnd(msgPtr)
+	End Method
+	
+	Method GetMessage:UInt()
+		Return bmx_win32_MSG_GetMessage(msgPtr)
+	End Method
+	
+	Method GetWParam:WParam()
+		Return bmx_win32_MSG_GetWParam(msgPtr)
+	End Method
+	
+	Method GetLParam:LParam()
+		Return bmx_win32_MSG_GetLParam(msgPtr)
+	End Method
+	
+	Method GetTime:Int()
+		Return bmx_win32_MSG_GetTime(msgPtr)
+	End Method
+	
+	Method GetPt(x:Int Var, y:Int Var)
+		bmx_win32_MSG_GetPt(msgPtr, x, y)
+	End Method
+	
+End Type
 
 Extern "Win32"
 

+ 43 - 0
win32.mod/user32.cpp

@@ -70,6 +70,14 @@ extern "C" {
 	void bmx_win32_MINMAXINFO_SetmaxTrackSizeX(MINMAXINFO * info, int x);
 	void bmx_win32_MINMAXINFO_SetmaxTrackSizeY(MINMAXINFO * info, int y);
 
+	MSG * bmx_win32_MSG_new();
+	void bmx_win32_MSG_free(MSG * msg);
+	HWND bmx_win32_MSG_GetHwnd(MSG * msg);
+	UINT bmx_win32_MSG_GetMessage(MSG * msg);
+	WPARAM bmx_win32_MSG_GetWParam(MSG * msg);
+	LPARAM bmx_win32_MSG_GetLParam(MSG * msg);
+	int bmx_win32_MSG_GetTime(MSG * msg);
+	void bmx_win32_MSG_GetPt(MSG * msg, int * x, int * y);
 }
 
 // ********************************************************
@@ -324,3 +332,38 @@ void bmx_win32_MINMAXINFO_SetmaxTrackSizeY(MINMAXINFO * info, int y) {
 	info->ptMaxTrackSize.y = y;
 }
 
+// ********************************************************
+
+MSG * bmx_win32_MSG_new() {
+	return (MSG *)calloc(1, sizeof(MSG));
+}
+
+void bmx_win32_MSG_free(MSG * msg) {
+	free(msg);
+}
+
+HWND bmx_win32_MSG_GetHwnd(MSG * msg) {
+	return msg->hwnd;
+}
+
+UINT bmx_win32_MSG_GetMessage(MSG * msg) {
+	return msg->message;
+}
+
+WPARAM bmx_win32_MSG_GetWParam(MSG * msg) {
+	return msg->wParam;
+}
+
+LPARAM bmx_win32_MSG_GetLParam(MSG * msg) {
+	return msg->lParam;
+}
+
+int bmx_win32_MSG_GetTime(MSG * msg) {
+	return msg->time;
+}
+
+void bmx_win32_MSG_GetPt(MSG * msg, int * x, int * y) {
+	*x = msg->pt.x;
+	*y = msg->pt.y;
+}
+