summaryrefslogtreecommitdiff
path: root/win32/source/utils.cpp
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2003-04-20 16:42:06 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2003-04-20 16:42:06 +0000
commitce4f3efd78c110c015c54eab05f201d1caac5f8d (patch)
tree668c555d5de70518b93426f45fe3e44d7f06663c /win32/source/utils.cpp
parent80f6215b607f0ed76f7f75deaf4e4668bc6f244d (diff)
downloadxine-lib-ce4f3efd78c110c015c54eab05f201d1caac5f8d.tar.gz
xine-lib-ce4f3efd78c110c015c54eab05f201d1caac5f8d.tar.bz2
importing win32 contrib sources and msvc build environment
CVS patchset: 4641 CVS date: 2003/04/20 16:42:06
Diffstat (limited to 'win32/source/utils.cpp')
-rw-r--r--win32/source/utils.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/win32/source/utils.cpp b/win32/source/utils.cpp
new file mode 100644
index 000000000..cce30acc8
--- /dev/null
+++ b/win32/source/utils.cpp
@@ -0,0 +1,61 @@
+
+#include "xineui.h"
+
+int Question( HWND hwnd, LPSTR szFmt, ... )
+{
+
+ char szBuff[256];
+
+ *szBuff = 0;
+ wvsprintf( &szBuff[ strlen( szBuff ) ],
+ szFmt,
+ (CHAR *)(&szFmt+1) );
+
+ return MessageBox( hwnd, szBuff, "Question", MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL );
+}
+
+void Error( HWND hwnd, LPSTR szFmt, ... )
+{
+
+ char szBuff[256];
+
+ *szBuff = 0;
+ wvsprintf( &szBuff[ strlen( szBuff ) ],
+ szFmt,
+ (CHAR *)(&szFmt+1) );
+
+ MessageBox( hwnd, szBuff, "Error", MB_ICONERROR | MB_OK | MB_APPLMODAL | MB_SYSTEMMODAL );
+}
+
+BOOL CenterWindow( HWND hwnd )
+{
+ RECT window_rect;
+ GetWindowRect( hwnd, &window_rect );
+
+ int screen_x = GetSystemMetrics( SM_CXFULLSCREEN );
+ int screen_y = GetSystemMetrics( SM_CYFULLSCREEN );
+
+ int window_x = screen_x / 2 - ( window_rect.right - window_rect.left ) / 2;
+ int window_y = screen_y / 2 - ( window_rect.bottom - window_rect.top ) / 2;
+
+ return SetWindowPos( hwnd, HWND_TOP, window_x, window_y, 0, 0, SWP_NOSIZE );
+}
+
+BOOL AnchorWindow( HWND hwnd )
+{
+ HWND phwnd = GetParent( hwnd );
+
+ RECT parent_rect;
+ GetWindowRect( phwnd, &parent_rect );
+
+ RECT window_rect;
+ GetWindowRect( hwnd, &window_rect );
+
+ int center_x = parent_rect.left + ( parent_rect.right - parent_rect.left ) / 2;
+ int center_y = parent_rect.top + ( parent_rect.bottom - parent_rect.top ) / 2;
+
+ int window_x = center_x - ( window_rect.right - window_rect.left ) / 2;
+ int window_y = center_y - ( window_rect.bottom - window_rect.top ) / 2;
+
+ return SetWindowPos( hwnd, HWND_TOP, window_x, window_y, 0, 0, SWP_NOSIZE );
+}