⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _w32sys.h

📁 Windows CE 6.0 Word Application 源码
💻 H
📖 第 1 页 / 共 3 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft shared
// source or premium shared source license agreement under which you licensed
// this source code. If you did not accept the terms of the license agreement,
// you are not authorized to use this source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the SOURCE.RTF on your install media or the root of your tools installation.
// THE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/*
 *  _w32sys.h
 *
 *  Purpose:
 *      Isolate various Win 32 system dependencies.
 *
 */

#ifndef _W32SYS_H

#define _W32SYS_H

#if defined(PEGASUS)
#if !defined(WINNT)
#include "memory.h"                             // for memmove
#endif
#define NOMAGELLAN                              // No Magellan on Win CE
#define NODROPFILES                             // No drop files support on Win CE
#define NOMETAFILES                             // No metafiles on Win CE
#define NOPEDDUMP                               // No support for ped debug dump on CE
#define NOFONTSUBINFO                           // Avoid reading fontsubinfo profile on CE
#define NODUMPFORMATRUNS                        // Don't dump formatting if we run out of memory.
#define CONVERT2BPP

#define dxCaret     2                           // caret width
#define FONTCACHESIZE 8
#define DEFAULT_UNDO_SIZE 20

#else

#define dxCaret     1                           // caret width
#define FONTCACHESIZE 16
#define DEFAULT_UNDO_SIZE 100

#endif  // defined(PEGASUS)

/*
 *  GetCaretDelta ()
 *
 *  @func   Get size of caret to add to current caret position to get the
 *  maximum extent needed to display caret.
 *
 *  @rdesc  Size of caret over 1 pixel
 *
 *  @devnote    This exists solely to abstract this calculation
 *  to handle a variable size caret.
 */
inline int GetCaretDelta()
{
    return dxCaret - 1;
}


// Used in rtfread.cpp to keep track of lossy rtf.
#ifdef PWORD_CONVERTER_V2
#define REPORT_LOSSAGE
#endif

#define SYMBOL_CODEPAGE     2
const SHORT sLanguageEnglishUS = 0x0409;
const SHORT sLanguageMask    =  0x03ff;
const SHORT sLanguageArabic  =  0x0401;
const SHORT sLanguageHebrew  =  0x040d;
// FUTURE: currently this const == sLanguageEnglishUS
//          for no reason except that it was this way
//          in RE1.0 BiDi. Consider changing, or sticking
//          the real language in, and changing the logic
//          of handling wLang a bit.
const SHORT sLanguageNonBiDi =  0x0409;


// Logical unit definition
const int LX_PER_INCH = 1440;
const int LY_PER_INCH = 1440;

// HIMETRIC units per inch (used for conversion)
const int HIMETRIC_PER_INCH = 2540;

#ifdef CopyMemory
#undef CopyMemory
#endif
#ifdef MoveMemory
#undef MoveMemory
#endif
#ifdef FillMemory
#undef FillMemory
#endif
#ifdef ZeroMemory
#undef ZeroMemory
#endif
#ifdef CompareMemory
#undef CompareMemory
#endif

#ifndef KF_ALTDOWN
#define KF_ALTDOWN    0x2000
#endif

// Use for our version of ExtTextOut
enum CONVERTMODE
{
    CM_NONE,            // Use Unicode (W) CharWidth/TextOut APIs
    CM_WCTMB,           // Convert to MBCS using WCTMB and _wCodePage
    CM_LOWBYTE          // Use low byte of 16-bit chars (for SYMBOL_CHARSET
};                      //  and when code page isn't installed)

// Opaque Type
class CTxtSelection;
class CTxtEdit;
class CCharFormat;
class CCcs;
struct IMESTYLE;
struct IMECOLORSTY;

enum UN_FLAGS
{
    UN_NOOBJECTS                = 1,
    UN_CONVERT_WCH_EMBEDDING    = 2
};

#undef GetStringTypeEx
#undef CharLower
#undef CharLowerBuff
#undef CharUpperBuff
#undef CreateIC
#undef CreateFile
#undef CreateFontIndirect
#undef CompareString
#undef DefWindowProc
//#undef GetKeyboardLayout
#undef GetProfileSection
#undef GetTextExtentPoint32
#undef GetTextFace
#undef GetWindowLong
#undef LoadBitmap
#undef LoadCursor
#undef LoadLibrary
#undef SendMessage
#undef SetWindowLong
#undef PostMessage
#undef lstrcmp
#undef lstrcmpi
#undef PeekMessage
#undef GetModuleFileName

#undef GlobalAlloc
#undef GlobalFree
#undef GlobalReAlloc
#undef GlobalLock
#undef GlobalHandle
#undef GlobalUnlock
#undef GlobalFlags
#undef GlobalSize

class CW32System
{
public :
    static BOOL         _fHaveIMMProcs;
    static DWORD        _dwPlatformId;          // platform GetVersionEx();
    static DWORD        _dwMajorVersion;        // major version from GetVersionEx()
    static INT          _icr3DDarkShadow;       // value to use for COLOR_3DDKSHADOW

    CW32System();

    ~CW32System();

    static LRESULT WndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
    static LRESULT ANSIWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
    static HGLOBAL WINAPI GlobalAlloc( UINT uFlags, DWORD dwBytes );
    static HGLOBAL WINAPI GlobalFree( HGLOBAL hMem );
    static UINT WINAPI GlobalFlags( HGLOBAL hMem );
    static HGLOBAL WINAPI GlobalReAlloc( HGLOBAL hMem, DWORD dwBytes, UINT uFlags );
    static DWORD WINAPI GlobalSize( HGLOBAL hMem );
    static LPVOID WINAPI GlobalLock( HGLOBAL hMem );
    static HGLOBAL WINAPI GlobalHandle( LPCVOID pMem );
    static BOOL WINAPI GlobalUnlock( HGLOBAL hMem );
    static BOOL WINAPI REGetCharWidth(
        HDC hdc,
        UINT iChar,
        LPINT pAns,
        UINT uiCodePage);
    static BOOL WINAPI REExtTextOut(
        CONVERTMODE cm,
        UINT uiCodePage,
        HDC hdc,
        int x,
        int y,
        UINT fuOptions,
        CONST RECT *lprc,
        const WCHAR *lpString,
        UINT cbCount,
        CONST INT *lpDx,
        BOOL  FEFontOnNonFEWin95);
    static CONVERTMODE WINAPI DetermineConvertMode( BYTE tmCharSet );
    static void WINAPI CalcUnderlineInfo( CCcs *pcccs, TEXTMETRIC *ptm );
    static BOOL WINAPI EnableScrollBar( HWND hWnd, UINT wSBflags, UINT wArrows );
    static BOOL WINAPI ShowScrollBar( HWND hWnd, int wBar, BOOL bShow, LONG nMax );
    static BOOL WINAPI IsEnhancedMetafileDC( HDC hdc );
    static UINT WINAPI GetTextAlign(HDC);
    static UINT WINAPI SetTextAlign(HDC, UINT);
    static UINT WINAPI InvertRect(HDC hdc, CONST RECT *lprc);
    static BOOL WINAPI GetCursorPos(POINT *ppt);
    static HPALETTE WINAPI ManagePalette(
        HDC hdc,
        CONST LOGPALETTE *plogpal,
        HPALETTE &hpalOld,
        HPALETTE &hpalNew
    );
    static int WINAPI GetMapMode(HDC hdc);
    static BOOL WINAPI WinLPtoDP(HDC hdc, LPPOINT lppoints, int nCount);
    static BOOL WINAPI WinDPtoLP(HDC hdc, LPPOINT lppoints, int nCount);

    static long WINAPI WvsprintfA(LONG cb, LPSTR szBuf, LPCSTR szFmt, va_list arglist);

    static int WINAPI MulDiv(int nNumber, int nNumerator, int nDenominator);

    // Convert Himetric along the X axis to X pixels
    static inline LONG  HimetricXtoDX(LONG xHimetric, LONG xPerInch)
    {
        // This formula is rearranged to get rid of the need for floating point
        // arithmetic. The real way to understand the formula is to use
        // (xHimetric / HIMETRIC_PER_INCH) to get the inches and then multiply
        // the inches by the number of x pixels per inch to get the pixels.
        return (LONG) MulDiv(xHimetric, xPerInch, HIMETRIC_PER_INCH);
    }

    // Convert Himetric along the Y axis to Y pixels
    static inline LONG HimetricYtoDY(LONG yHimetric, LONG yPerInch)
    {
        // This formula is rearranged to get rid of the need for floating point
        // arithmetic. The real way to understand the formula is to use
        // (xHimetric / HIMETRIC_PER_INCH) to get the inches and then multiply
        // the inches by the number of y pixels per inch to get the pixels.
        return (LONG) MulDiv(yHimetric, yPerInch, HIMETRIC_PER_INCH);
    }

    // Convert Pixels on the X axis to Himetric
    static inline LONG DXtoHimetricX(LONG dx, LONG xPerInch)
    {
        // This formula is rearranged to get rid of the need for floating point
        // arithmetic. The real way to understand the formula is to use
        // (dx / x pixels per inch) to get the inches and then multiply
        // the inches by the number of himetric units per inch to get the
        // count of himetric units.
        return (LONG) MulDiv(dx, HIMETRIC_PER_INCH, xPerInch);
    }

    // Convert Pixels on the Y axis to Himetric
    static inline LONG DYtoHimetricY(LONG dy, LONG yPerInch)
    {
        // This formula is rearranged to get rid of the need for floating point
        // arithmetic. The real way to understand the formula is to use
        // (dy / y pixels per inch) to get the inches and then multiply
        // the inches by the number of himetric units per inch to get the
        // count of himetric units.
        return (LONG) MulDiv(dy, HIMETRIC_PER_INCH, yPerInch);
    }

    //
    // Case insensitive ASCII compare
    //
    static BOOL ASCIICompareI( const BYTE *pstr1, const BYTE *pstr2, int iCount )
    {
        int i;
        for (i = 0; i < iCount && !((pstr1[i] ^ pstr2[i]) & ~0x20); i++)
            ;
        return i == iCount;
    }

    //
    // Allocate and convert a MultiByte string to a wide character string
    // Allocated strings must be freed with delete
    //
    static WCHAR *ConvertToWideChar( const char *pstr )
    {
        int istrlen;
        for (istrlen = 0; pstr[istrlen]; istrlen++);
        WCHAR *pnew = new WCHAR[istrlen + 1];
        if (pnew )
        {
            if  (0 != ::MultiByteToWideChar( CP_ACP, 0, pstr, -1, pnew, istrlen + 1))
            {
                return pnew;
            }
            else
            {
                delete[] pnew;
            }
        }
        return NULL;
    }

    //
    // functions for memory management
    //
    static LPVOID PvAlloc(ULONG cbBuf,  UINT uiMemFlags);
    static LPVOID PvReAlloc(LPVOID pvBuf, DWORD cbBuf);
    static BOOL   FreePv(LPVOID pvBuf);

    static inline void *CopyMemory(void *dst, const void *src, size_t cb)
    {
        // Will work for overlapping regions
        return memmove(dst, src, cb);
    }

    static inline void *MoveMemory(void *dst, const void *src, size_t cb)
    {
        return memmove(dst, src, cb);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -