View the DQSD CVS repository here:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/
Update of /cvsroot/dqsd/dqsd/src/DQSDTools
In directory sc8-pr-cvs1:/tmp/cvs-serv6116/src/DQSDTools
Modified Files:
Utilities.cpp Utilities.h
Log Message:
- Added GetScreenRect, IsWindowOnScreen, IsWindowOnTaskbar
- Added lengthof macro, which counts elements of statically allocated arrays
- Commented out unused UtilitiesFindDQSDWindow overload
- Fixed a number of issues with TCHAR correctness
Index: Utilities.cpp
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/Utilities.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Utilities.cpp 18 Jul 2002 20:09:06 -0000 1.6
--- Utilities.cpp 29 Jun 2003 14:36:26 -0000 1.7
***************
*** 1,5 ****
-
-
-
#include "StdAfx.h"
#include <comdef.h>
--- 1,2 ----
***************
*** 9,14 ****
HWND g_hDQSDWindow;
-
-
INTERNET_SCHEME GetScheme(LPCTSTR szURL)
{
--- 6,9 ----
***************
*** 19,23 ****
uc.dwStructSize = sizeof uc;
uc.lpszScheme = buf;
! uc.dwSchemeLength = sizeof buf;
if (InternetCrackUrl(szURL, lstrlen(szURL), ICU_DECODE, &uc))
--- 14,18 ----
uc.dwStructSize = sizeof uc;
uc.lpszScheme = buf;
! uc.dwSchemeLength = lengthof(buf);
if (InternetCrackUrl(szURL, lstrlen(szURL), ICU_DECODE, &uc))
***************
*** 35,39 ****
uc.dwStructSize = sizeof uc;
uc.lpszUrlPath = pathbuf;
! uc.dwUrlPathLength = sizeof pathbuf;
if (!InternetCrackUrl(szURL, lstrlen(szURL), ICU_DECODE, &uc))
return FALSE;
--- 30,34 ----
uc.dwStructSize = sizeof uc;
uc.lpszUrlPath = pathbuf;
! uc.dwUrlPathLength = lengthof(pathbuf);
if (!InternetCrackUrl(szURL, lstrlen(szURL), ICU_DECODE, &uc))
return FALSE;
***************
*** 54,57 ****
--- 49,54 ----
)
{
+ USES_CONVERSION;
+
TCHAR className[201];
***************
*** 59,63 ****
GetClassName(hwnd, className, 200);
! if(StrCmpI(className, "OCHost") == 0)
{
// We've found a likely looking window
--- 56,60 ----
GetClassName(hwnd, className, 200);
! if(StrCmpI(className, _T("OCHost")) == 0)
{
// We've found a likely looking window
***************
*** 76,81 ****
{
GetClassName(hWorkingWnd, className, 200);
! // ATLTRACE("ClassName: %s\n", className);
! thisClassName = className;
thisClassName += ", ";
classList.insert(0, thisClassName);
--- 73,80 ----
{
GetClassName(hWorkingWnd, className, 200);
! // Using conversion macros in a loop is irresponsible, but it
should be OK here
! // since the window hierarchy shouldn't be that deep.
! // Besides, T2A is a NOOP in ANSI builds.
! thisClassName = T2A(className);
thisClassName += ", ";
classList.insert(0, thisClassName);
***************
*** 84,88 ****
ATLTRACE("ClassList: %s\n", classList.c_str());
! MessageBox(NULL, classList.c_str(), "DQSD Window Path", MB_OK |
MB_ICONINFORMATION);
}
return TRUE;
--- 83,87 ----
ATLTRACE("ClassList: %s\n", classList.c_str());
! MessageBox(NULL, A2CT(classList.c_str()), _T("DQSD Window Path"),
MB_OK | MB_ICONINFORMATION);
}
return TRUE;
***************
*** 152,157 ****
--- 151,230 ----
}
+ //
+ // Helper to return the screen coordinates as a RECT
+ //
+ BOOL GetScreenRect(LPRECT lpRect)
+ {
+ // We need these without defining WINVER >= 0x0500
+ // They are only used on a valid platform (> Win98)
+ #define DQSD_SM_XVIRTUALSCREEN 76
+ #define DQSD_SM_YVIRTUALSCREEN 77
+ #define DQSD_SM_CXVIRTUALSCREEN 78
+ #define DQSD_SM_CYVIRTUALSCREEN 79
+
+ // Get screen rect depending on OS version
+ OSVERSIONINFO vi = {0};
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if(!GetVersionEx(&vi))
+ return FALSE;
+
+ if((vi.dwMajorVersion > 4) || (vi.dwMajorVersion == 4 && vi.dwMinorVersion >=
10))
+ {
+ // Win98, ME, 2000, XP - Support for multiple monitors
+ lpRect->top = GetSystemMetrics(DQSD_SM_YVIRTUALSCREEN);
+ lpRect->left = GetSystemMetrics(DQSD_SM_XVIRTUALSCREEN);
+ lpRect->bottom = lpRect->top +
GetSystemMetrics(DQSD_SM_CYVIRTUALSCREEN);
+ lpRect->right = lpRect->left +
GetSystemMetrics(DQSD_SM_CXVIRTUALSCREEN);
+ }
+ else
+ {
+ // Win95 or other - No support for multiple monitors
+ lpRect->top = 0;
+ lpRect->left = 0;
+ lpRect->bottom = GetSystemMetrics(SM_CYSCREEN);
+ lpRect->right = GetSystemMetrics(SM_CXSCREEN);
+ }
+
+ return TRUE;
+ }
+
+ //
+ // Attempts to determine whether the window is visible on screen
+ //
+ BOOL IsWindowOnScreen(HWND hwnd)
+ {
+ // Get window dimensions
+ RECT wndRect;
+ GetWindowRect(hwnd, &wndRect);
+ // Get screen dimensions
+ RECT screenRect;
+ GetScreenRect(&screenRect);
+ // If wndRect is contained in screenRect, it's visible
+ return (wndRect.top >= screenRect.top && wndRect.left >= screenRect.left &&
wndRect.bottom <= screenRect.bottom && wndRect.right <= screenRect.right);
+ }
+
+ //
+ // Attempts to determine whether the window is docked on the taskbar or not.
+ //
+ BOOL IsWindowOnTaskbar(HWND hwnd)
+ {
+ // Get window dimensions
+ RECT wndRect;
+ GetWindowRect(hwnd, &wndRect);
+
+ // Find the taskbar window
+ HWND hwndTaskbar = FindWindow(_T("Shell_traywnd"), NULL);
+ RECT taskbarRect;
+ GetWindowRect(hwndTaskbar, &taskbarRect);
+
+ // If wndRect is contained in taskbarRect, it's docked
+ return (wndRect.top >= taskbarRect.top && wndRect.left >= taskbarRect.left &&
wndRect.bottom <= taskbarRect.bottom && wndRect.right <= taskbarRect.right);
+ }
+
+ /*
+
+ // This code looks untested, risky, not quite correct, and it's unused. (kimgrasman,
2003-06-26)
//
***************
*** 243,245 ****
return hwndDQSD;
! }
\ No newline at end of file
--- 316,319 ----
return hwndDQSD;
! }
! */
\ No newline at end of file
Index: Utilities.h
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/Utilities.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Utilities.h 8 Jul 2002 10:32:04 -0000 1.8
--- Utilities.h 29 Jun 2003 14:36:26 -0000 1.9
***************
*** 1,7 ****
#pragma once
! extern HWND g_hDQSDWindow;
INTERNET_SCHEME GetScheme(LPCTSTR szURL);
int URLMatchesFilename(LPCTSTR szURL, LPCTSTR szFile);
--- 1,15 ----
+ #ifndef __UTILITIES_H__
+ #define __UTILITIES_H__
#pragma once
! //
! // Returns the number of elements of a statically allocated array
! //
! #define lengthof(arr) (sizeof(arr) / sizeof(*arr))
+ //
+ // URL helper functions
+ //
INTERNET_SCHEME GetScheme(LPCTSTR szURL);
int URLMatchesFilename(LPCTSTR szURL, LPCTSTR szFile);
***************
*** 10,15 ****
// Find the DQSD window (usually, but not always, on the taskbar)
//
! // Return:
! // The window handle, or null if we fail
! HWND
! UtilitiesFindDQSDWindow(LPDISPATCH pDispDocument);
--- 18,41 ----
// Find the DQSD window (usually, but not always, on the taskbar)
//
! // Return: The window handle, or null if we fail
! //
! HWND UtilitiesFindDQSDWindow(LPDISPATCH pDispDocument);
!
! extern HWND g_hDQSDWindow;
!
! //
! // Attempts to determine whether the window is placed on the taskbar or not.
! //
! BOOL IsWindowOnTaskbar(HWND hwnd);
!
! //
! // Attempts to determine whether the window is visible on screen
! //
! BOOL IsWindowOnScreen(HWND hwnd);
!
! //
! // Helper to return the screen dimensions as a RECT
! //
! BOOL GetScreenRect(LPRECT lpRect);
!
! #endif //__UTILITIES_H__
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
DQSD-CVS mailing list
https://lists.sourceforge.net/lists/listinfo/dqsd-cvs
DQSD CVS repository:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/