1 /*****************************************************************************
2 * win32_api.cpp: Various win32-specific functions
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: win32_api.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
7 * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
8 * Emmanuel Puig <karibu@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
24 *****************************************************************************/
27 //--- WIN32 -----------------------------------------------------------------
30 //--- SKIN ------------------------------------------------------------------
32 #include "os_window.h"
34 #include "event.h" // for MAX_PARAM_SIZE
38 //---------------------------------------------------------------------------
40 //---------------------------------------------------------------------------
41 void OSAPI_SendMessage( Window *win, unsigned int message, unsigned int param1,
45 SendMessage( NULL, message, param1, param2 );
47 SendMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
50 //---------------------------------------------------------------------------
51 void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
55 PostMessage( NULL, message, param1, param2 );
57 PostMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
60 //---------------------------------------------------------------------------
65 //---------------------------------------------------------------------------
67 //---------------------------------------------------------------------------
68 int OSAPI_GetNonTransparentColor( int c )
70 // Get desktop device context
71 HDC DeskDC = GetWindowDC( GetDesktopWindow() );
73 // If color is black or color is same as black wether pixel color depth
74 if( c == 0 || SetPixel( DeskDC, 0, 0, c ) == 0 )
76 if( GetDeviceCaps( DeskDC, BITSPIXEL ) < 24 )
81 ReleaseDC( GetDesktopWindow(), DeskDC );
84 //---------------------------------------------------------------------------
89 //---------------------------------------------------------------------------
91 //---------------------------------------------------------------------------
94 return GetTickCount();
96 //---------------------------------------------------------------------------
97 void OSAPI_GetScreenSize( int &w, int &h )
99 w = GetSystemMetrics(SM_CXSCREEN);
100 h = GetSystemMetrics(SM_CYSCREEN);
102 //---------------------------------------------------------------------------
103 void OSAPI_GetMousePos( int &x, int &y )
105 LPPOINT MousePos = new POINT;
106 GetCursorPos( MousePos );
111 //---------------------------------------------------------------------------
112 string OSAPI_GetWindowTitle( Window *win )
114 char *buffer = new char[MAX_PARAM_SIZE];
115 GetWindowText( ((Win32Window *)win)->GetHandle(), buffer, MAX_PARAM_SIZE );
116 string Title = buffer;
121 //---------------------------------------------------------------------------
122 bool OSAPI_RmDir( string path )
124 WIN32_FIND_DATA find;
126 string FindFiles = path + "\\*.*";
127 HANDLE handle = FindFirstFile( (char *)FindFiles.c_str(), &find );
129 while( handle != INVALID_HANDLE_VALUE )
131 // If file is neither "." nor ".."
132 if( strcmp( find.cFileName, "." ) && strcmp( find.cFileName, ".." ) )
135 File = path + "\\" + (string)find.cFileName;
137 // If file is a directory, delete it recursively
138 if( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
142 // Else, it is a file so simply delete it
145 DeleteFile( (char *)File.c_str() );
149 // If no more file in directory, exit while
150 if( !FindNextFile( handle, &find ) )
154 // Now directory is empty so can be removed
156 RemoveDirectory( (char *)path.c_str() );
160 //---------------------------------------------------------------------------