Browse Source

invoke ReleaseDC for bbSystemDesktop commands

Simon Armstrong 8 years ago
parent
commit
e4e35ec40a
2 changed files with 14 additions and 4 deletions
  1. 13 4
      mod/brl.mod/system.mod/system.win32.c
  2. 1 0
      mod/pub.mod/win32.mod/user32.bmx

+ 13 - 4
mod/brl.mod/system.mod/system.win32.c

@@ -498,18 +498,27 @@ void bbSystemStartAsyncOp( BBAsyncOp asyncOp,int asyncInfo,BBSyncOp syncOp,BBObj
 	CreateThread( 0,0,asyncOpThread,p,0,&threadId );
 	CreateThread( 0,0,asyncOpThread,p,0,&threadId );
 }
 }
 
 
+int DesktopCaps(int index){
+	HWND hwnd = GetDesktopWindow();
+	HDC dc = GetDC(hwnd);
+	int caps = GetDeviceCaps(dc,index);
+	ReleaseDC(hwnd,dc);
+	return caps;
+}
+
+
 int bbSystemDesktopWidth(){
 int bbSystemDesktopWidth(){
-	return GetDeviceCaps( GetDC( GetDesktopWindow() ),HORZRES );
+	return DesktopCaps(HORZRES);
 }
 }
 
 
 int bbSystemDesktopHeight(){
 int bbSystemDesktopHeight(){
-	return GetDeviceCaps( GetDC( GetDesktopWindow() ),VERTRES );
+	return DesktopCaps(VERTRES);
 }
 }
 
 
 int bbSystemDesktopDepth(){
 int bbSystemDesktopDepth(){
-	return GetDeviceCaps( GetDC( GetDesktopWindow() ),BITSPIXEL );
+	return DesktopCaps(BITSPIXEL);
 }
 }
 
 
 int bbSystemDesktopHertz(){
 int bbSystemDesktopHertz(){
-	return GetDeviceCaps( GetDC( GetDesktopWindow() ),VREFRESH );
+	return DesktopCaps(VREFRESH);
 }
 }

+ 1 - 0
mod/pub.mod/win32.mod/user32.bmx

@@ -723,6 +723,7 @@ Function SendMessageW( hWnd,MSG,wParam,lParam )
 Function PostThreadMessageA( idThread,Msg,wParam,lParam )
 Function PostThreadMessageA( idThread,Msg,wParam,lParam )
 Function PostThreadMessageW( idThread,Msg,wParam,lParam )
 Function PostThreadMessageW( idThread,Msg,wParam,lParam )
 Function GetDC( hWnd )
 Function GetDC( hWnd )
+Function ReleaseDC( hwnd, hdc )
 Function PostQuitMessage( nExitCode )
 Function PostQuitMessage( nExitCode )
 Function TranslateMessage( lpMsg:Byte Ptr )
 Function TranslateMessage( lpMsg:Byte Ptr )
 Function DestroyWindow( hWnd )
 Function DestroyWindow( hWnd )