瀏覽代碼

invoke ReleaseDC for bbSystemDesktop commands

Simon Armstrong 8 年之前
父節點
當前提交
e4e35ec40a
共有 2 個文件被更改,包括 14 次插入4 次删除
  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 );
 }
 
+int DesktopCaps(int index){
+	HWND hwnd = GetDesktopWindow();
+	HDC dc = GetDC(hwnd);
+	int caps = GetDeviceCaps(dc,index);
+	ReleaseDC(hwnd,dc);
+	return caps;
+}
+
+
 int bbSystemDesktopWidth(){
-	return GetDeviceCaps( GetDC( GetDesktopWindow() ),HORZRES );
+	return DesktopCaps(HORZRES);
 }
 
 int bbSystemDesktopHeight(){
-	return GetDeviceCaps( GetDC( GetDesktopWindow() ),VERTRES );
+	return DesktopCaps(VERTRES);
 }
 
 int bbSystemDesktopDepth(){
-	return GetDeviceCaps( GetDC( GetDesktopWindow() ),BITSPIXEL );
+	return DesktopCaps(BITSPIXEL);
 }
 
 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 PostThreadMessageW( idThread,Msg,wParam,lParam )
 Function GetDC( hWnd )
+Function ReleaseDC( hwnd, hdc )
 Function PostQuitMessage( nExitCode )
 Function TranslateMessage( lpMsg:Byte Ptr )
 Function DestroyWindow( hWnd )