#ifndef __CeMisc_h__
#define __CeMisc_h__
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifdef _WIN32_PPC_
# include <aygshell.h>
BOOL CeShowSip(BOOL bShow);
BOOL CeSipCenterWindow(HWND hwnd);
BOOL CeSipSizeWindow(HWND hwnd);
#endif
HINSTANCE CeGetAppInstance();
HWND CeGetAppWindow();
inline bool CeIsPPC()
{
#ifdef _WIN32_WCE
TCHAR szPlatform[32];
if (::SystemParametersInfo(SPI_GETPLATFORMTYPE, 32, szPlatform, 0))
return (!_tcsnicmp(szPlatform, _T("Palm PC"), 32)) ? true: false;
#endif // _WIN32_WCE
return false;
}
inline bool CeIsHPC()
{
#ifdef _WIN32_WCE
TCHAR szPlatform[32];
if (::SystemParametersInfo(SPI_GETPLATFORMTYPE, 32, szPlatform, 0))
return (!_tcsnicmp(szPlatform, _T("HPC"), 32)) ? true: false;
#endif // _WIN32_WCE
return false;
}
inline bool CeIsHPCPro()
{
#ifdef _WIN32_WCE
TCHAR szPlatform[32];
if (::SystemParametersInfo(SPI_GETPLATFORMTYPE, 32, szPlatform, 0))
return (!_tcsnicmp(szPlatform, _T("Jupiter"), 32)) ? true: false;
#endif // _WIN32_WCE
return false;
}
#define ProgressCtrl_SetRange(hWnd, nLower, nUpper) \
::SendMessage(hWnd, PBM_SETRANGE, 0, MAKELPARAM(nLower, nUpper))
#define ProgressCtrl_SetPos(hWnd, nPos) \
::SendMessage(hWnd, PBM_SETPOS, nPos, 0L)
#define ProgressCtrl_OffsetPos(hWnd, nPos) \
::SendMessage(hWnd, PBM_DELTAPOS, nPos, 0L)
#define ProgressCtrl_SetStep(nStep) \
::SendMessage(hWnd, PBM_SETSTEP, nStep, 0L)
#define ProgressCtrl_StepIt() \
::SendMessage(hWnd, PBM_STEPIT, 0, 0L)
//
// Short cuts for funtions I like to use that don't exist in Windows CE Win32 ...
//
#ifndef EqualMemory
# define EqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
#endif
#ifndef MoveMemory
# define MoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
#endif
#ifndef CopyMemory
# define CopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
#endif
#ifndef FillMemory
# define FillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
#endif
#ifndef ZeroMemory
# define ZeroMemory(Destination,Length) memset((Destination),0,(Length))
#endif
class CeSize;
class CeRect;
class CePoint;
/////////////////////////////////////////////////////////////////////////////
// CeSize - An extent, similar to Windows SIZE structure.
class CeSize : public tagSIZE
{
public:
// Constructors
CeSize();
CeSize(int initCX, int initCY);
CeSize(SIZE initSize);
CeSize(POINT initPt);
CeSize(DWORD dwSize);
// Operations
BOOL operator==(SIZE size) const;
BOOL operator!=(SIZE size) const;
void operator+=(SIZE size);
void operator-=(SIZE size);
// Operators returning CeSize values
CeSize operator+(SIZE size) const;
CeSize operator-(SIZE size) const;
CeSize operator-() const;
// Operators returning CePoint values
CePoint operator+(POINT point) const;
CePoint operator-(POINT point) const;
// Operators returning CeRect values
CeRect operator+(const RECT* lpRect) const;
CeRect operator-(const RECT* lpRect) const;
};
/////////////////////////////////////////////////////////////////////////////
// CePoint - A 2-D point, similar to Windows POINT structure.
class CePoint : public tagPOINT
{
public:
// Constructors
CePoint();
CePoint(int initX, int initY);
CePoint(POINT initPt);
CePoint(SIZE initSize);
CePoint(DWORD dwPoint);
// Operations
void Offset(int xOffset, int yOffset);
void Offset(POINT point);
void Offset(SIZE size);
BOOL operator==(POINT point) const;
BOOL operator!=(POINT point) const;
void operator+=(SIZE size);
void operator-=(SIZE size);
void operator+=(POINT point);
void operator-=(POINT point);
// Operators returning CePoint values
CePoint operator+(SIZE size) const;
CePoint operator-(SIZE size) const;
CePoint operator-() const;
CePoint operator+(POINT point) const;
// Operators returning CeSize values
CeSize operator-(POINT point) const;
// Operators returning CeRect values
CeRect operator+(const RECT* lpRect) const;
CeRect operator-(const RECT* lpRect) const;
};
/////////////////////////////////////////////////////////////////////////////
// CeRect - A 2-D rectangle, similar to Windows RECT structure.
typedef const RECT* LPCRECT; // pointer to read/only RECT
class CeRect : public tagRECT
{
public:
// Constructors
CeRect();
CeRect(int l, int t, int r, int b);
CeRect(const RECT& srCeRect);
CeRect(LPCRECT lpSrCeRect);
CeRect(POINT point, SIZE size);
CeRect(POINT topLeft, POINT bottomRight);
// Attributes (in addition to RECT members)
int Width() const;
int Height() const;
CeSize Size() const;
CePoint& TopLeft();
CePoint& BottomRight();
const CePoint& TopLeft() const;
const CePoint& BottomRight() const;
CePoint CenterPoint() const;
// convert between CeRect and LPRECT/LPCRECT (no need for &)
operator LPRECT();
operator LPCRECT() const;
BOOL IsRectEmpty() const;
BOOL IsRectNull() const;
BOOL PtInRect(POINT point) const;
// Operations
void SetRect(int x1, int y1, int x2, int y2);
void SetRect(POINT topLeft, POINT bottomRight);
void SetRectEmpty();
void CopyRect(LPCRECT lpSrCeRect);
BOOL EqualRect(LPCRECT lpRect) const;
void InflateRect(int x, int y);
void InflateRect(SIZE size);
void InflateRect(LPCRECT lpRect);
void InflateRect(int l, int t, int r, int b);
void DeflateRect(int x, int y);
void DeflateRect(SIZE size);
void DeflateRect(LPCRECT lpRect);
void DeflateRect(int l, int t, int r, int b);
void OffsetRect(int x, int y);
void OffsetRect(SIZE size);
void OffsetRect(POINT point);
void NormalizeRect();
// operations that fill '*this' with result
BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2);
BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2);
BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2);
// Additional Operations
void operator=(const RECT& srCeRect);
BOOL operator==(const RECT& rect) const;
BOOL operator!=(const RECT& rect) const;
void operator+=(POINT point);
void operator+=(SIZE size);
void operator+=(LPCRECT lpRect);
void operator-=(POINT point);
void operator-=(SIZE size);
void operator-=(LPCRECT lpRect);
void operator&=(const RECT& rect);
void operator|=(const RECT& rect);
// Operators returning CeRect values
CeRect operator+(POINT point) const;
CeRect operator-(POINT point) const;
CeRect operator+(LPCRECT lpRect) const;
CeRect operator+(SIZE size) const;
CeRect operator-(SIZE size) const;
CeRect operator-(LPCRECT lpRect) const;
CeRect operator&(const RECT& rect2) const;
CeRect operator|(const RECT& rect2) const;
CeRect MulDiv(int nMultiplier, int nDivisor) const;
// Window short cuts
void ScreenToClient(HWND hWnd);
void ClientToScreen(HWND hWnd);
};
///////////////////////////////////////////////////////////////////////////////
//
// Functions that are not contained in any header file but exist
// in all versions of CE.
// Note: these functions are documented only in Platform Builder, and
// are likely to be restricted in future versions of Windows CE.
//
// The functions GetSystemMemoryDivision() and SetSystemMemoryDivision()
// allow you to change the relationship between memory and the object store.
// The prototypes are:
#ifdef __cplusplus
extern "C"{
#endif
BOOL WINAPI GetSystemMemoryDivision(LPDWORD storePages, LPDWORD ramPages, LPDWORD pageSize);
DWORD WINAPI SetSystemMemoryDivision(DWORD storePages);
#ifdef __cplusplus
}
#endif
// The function returns SYSMEM_CHANGED if executed successfully.
// The function returns SYSMEM_FAILED if storePages is out of range.
// If SYSMEM_FAILED is returned, you can get further information by calling GetLastError().
// If a reboot is necessary for the change to take effect, the function returns SYSMEM_MUSTREBOOT.
// If a previous call returned SYSMEM_MUSTREBOOT, the function
// returns SYSMEM_REBOOTPENDING. In this situation, the boundary
// cannot be adjusted further until the reboot occurs.
// You cannot shrink system memory or the object store memory beyond 256K
// each, including space for existing files and records.
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// Class Description:
// Put up the wait cursor and destry it on destruction.
//
///////////////////////////////////////////////////////////////////////////////
class CeWaitCursor
{
private:
// Set the Wait cursor
HCURSOR m_hCursor;
public:
CeWaitCursor()
{ Wait(); }
~CeWaitCursor()
{ Restore(); }
void Wait()
{ m_hCursor = ::SetCursor(::LoadCursor(NULL, IDC_WAIT)); }
void Restore()
{ ::SetCursor(m_hCursor); }
};
// implementation in inline functions
#include "CeMisc.inl"
#endif // __CeMisc_h__