📄 win2mac.cpp
字号:
//
// 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.
//
//----------------------------------------------------------------------------
//
// Microsoft Windows
//
// File: win2mac.cpp
//
// Contents: All functions that are not implemented for the Macintosh
// Stubs are coded so that we can link cleanly.
//
//----------------------------------------------------------------------------
#ifndef PEGASUS
#include "_common.h"
#include <mbstring.h>
#include "stdio.h"
#if defined(MACPORT) && defined(UNICODE)
#include <macname1.h>
#include <quickdraw.h>
#include <macname2.h>
AssertData
//----------------------------------------------------------------------------
//
// Mac wrapper functions
//
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//
// Function: MacCLSIDFromProgID
//
//----------------------------------------------------------------------------
#undef CLSIDFromProgID
STDAPI MacCLSIDFromProgID (LPCWSTR lpszProgID, LPCLSID lpclsid)
{
CStrIn str(lpszProgID);
return CLSIDFromProgID((LPOLESTR)str, lpclsid);
}
//----------------------------------------------------------------------------
//
// Function: MacCoTaskMemAlloc
//
//----------------------------------------------------------------------------
STDAPI_(LPVOID) MacCoTaskMemAlloc(ULONG cb)
{
IMalloc *pIMalloc = NULL;
HRESULT hr;
HGLOBAL pMem = NULL;
hr = CoGetMalloc ( MEMCTX_TASK, &pIMalloc);
if (hr)
{
goto Cleanup;
}
pMem = pIMalloc->Alloc(cb);
Cleanup:
if( pIMalloc )
pIMalloc->Release();
return (LPVOID)pMem;
}
//----------------------------------------------------------------------------
//
// Function: MacCoTaskMemFree
//
//----------------------------------------------------------------------------
STDAPI_(void) MacCoTaskMemFree(LPVOID pv)
{
IMalloc *pIMalloc = NULL;
HRESULT hr;
HGLOBAL pMem = NULL;
hr = CoGetMalloc ( MEMCTX_TASK, &pIMalloc);
if (hr)
{
goto Cleanup;
}
pIMalloc->Free(pv);
Cleanup:
if( pIMalloc )
pIMalloc->Release();
}
//----------------------------------------------------------------------------
//
// Function: MacCoTaskMemRealloc
//
//----------------------------------------------------------------------------
STDAPI_(LPVOID) MacCoTaskMemRealloc(LPVOID pv, ULONG cb)
{
IMalloc *pIMalloc = NULL;
HRESULT hr;
HGLOBAL pMem = NULL;
hr = CoGetMalloc ( MEMCTX_TASK, &pIMalloc);
if (hr)
{
goto Cleanup;
}
pMem = pIMalloc->Realloc(pv,cb);
Cleanup:
if( pIMalloc )
pIMalloc->Release();
return (LPVOID)pMem;
}
//----------------------------------------------------------------------------
//
// Function: MacGetCurrentObject
//
//----------------------------------------------------------------------------
HGDIOBJ WINAPI MacGetCurrentObject(HDC hdc, // handle of device context
UINT uObjectType) // object-type identifier
{
// GetCurrentObject is not supported under wlm, so we always simulate failure
// by returning NULL
return NULL;
}
//----------------------------------------------------------------------------
// NOTE WELL: GetDoubleClickTime() maps to GetDblTime() in the VC++ 4.0 header
// file MSDEV\MAC\INCLUDE\MACOS\EVENTS.H. The only problem is that
// GetDblTime() returns the count in "Ticks" (1/60th second) and
// we want milliseconds (0.001 sec). This should be fixed when the
// bug in the VC4 header file is fixed. - DAS 1/16/96
//----------------------------------------------------------------------------
UINT MacGetDoubleClickTime()
{
return MulDiv(100,GetDblTime(),6);
}
//----------------------------------------------------------------------------
//
// Function: MacGetMetaFileBitsEx
//
//----------------------------------------------------------------------------
UINT WINAPI MacGetMetaFileBitsEx(HMETAFILE hmf, UINT nSize, LPVOID lpvData )
{
Assert (0 && "GetMetaFileBitsEx is not implemented for Macintosh");
return NULL;
}
//----------------------------------------------------------------------------
//
// Function: MacIsValidCodePage
//
//----------------------------------------------------------------------------
WINBASEAPI BOOL WINAPI MacIsValidCodePage(UINT CodePage)
{
return TRUE;
}
//----------------------------------------------------------------------------
//
// Function: MacOleDraw
//
//----------------------------------------------------------------------------
#undef OleDraw
STDAPI MacOleDraw(
IUnknown * pUnk, //Points to the view object to be drawn
DWORD dwAspect, //Specifies how the object is to be represented
HDC hdcDraw, //Identifies the device context on which to draw
LPCRECT lprcBounds //Specifies the rectangle in which the object is drawn
)
{
Rect rect;
HRESULT ret;
GrafPtr grafptr = CheckoutPort(hdcDraw, CA_NONE);
Assert(grafptr);
rect.top = lprcBounds->top;
rect.bottom = lprcBounds->bottom;
rect.left = lprcBounds->left;
rect.right = lprcBounds->right;
ret = OleDraw(pUnk, dwAspect, grafptr, &rect);
CheckinPort(hdcDraw, CA_ALL);
return ret;
}
//----------------------------------------------------------------------------
//
// Function: MacProgIDFromCLSID
//
//----------------------------------------------------------------------------
#undef ProgIDFromCLSID
STDAPI MacProgIDFromCLSID (REFCLSID clsid, LPWSTR FAR* lplpszProgID)
{
CStrIn str(*lplpszProgID);
return ProgIDFromCLSID(clsid, (LPSTR FAR*)&str);
}
//-------------------------------------------------------------------------
//
// Function: MacRichEditWndProc
//
// Synopsis: This is the Mac WndProc callback function.
//
// Arguments: HWND hwnd,
// UINT msg,
// WPARAM wparam,
// LPARAM lparam
//
// Returns: LRESULT
//
// Notes: The function processes the messages, then often calls
// the normal PC callback function (RichEditANSIWndProc);
//
//
//-------------------------------------------------------------------------
LRESULT CALLBACK MacRichEditWndProc(
HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
TRACEBEGINPARAM(TRCSUBSYSHOST, TRCSCOPEINTERN, "MacRichEditWndProc", msg);
switch( msg )
{
case WM_MACINTOSH:
{
if (LOWORD(wparam) == WLM_SETMENUBAR)
return TRUE; // dont change the menu bar
}
break;
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
{
MacSimulateMouseButtons(msg,wparam);
}
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -