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

📄 misc.c

📁 英文版的 想要的话可以下载了 为大家服务
💻 C
字号:
/*
 * MISC.C
 *
 * Functions without any other reasonable home:
 *  WindowTitleSet, RectConvertToHiMetric, RectConvertToDevice
 *
 * Copyright(c) Microsoft Corp. 1992-1994 All Rights Reserved
 * Win32 version, January 1994
 */


#include <windows.h>
#include <ole.h>
#include "cosmo.h"




/*
 * WindowTitleSet
 *
 * Purpose:
 *  Handles changing the window's caption bar depending on the file
 *  that is loaded.
 *
 * Parameters:
 *  hWnd            HWND of the window to change.
 *  pszFile         LPSTR of the file loaded.
 *
 * Return Value:
 *  none.
 */

void WINAPI WindowTitleSet(HWND hWnd, LPSTR pszFile)
    {
    char        szTitle[CCHPATHMAX];

    wsprintf(szTitle, "%s - %s", (LPSTR)rgpsz[IDS_CAPTION], pszFile);
    SetWindowText(hWnd, szTitle);
    return;
    }







/*
 * RectConvertToHiMetric
 *
 * Purpose:
 *  Converts the contents of a rectangle from MM_TEXT into MM_HIMETRIC
 *  specifically for use in converting a RECT of a window into
 *  a RECT for a METAFILEPICT structure.
 *
 * Parameters:
 *  hWnd            HWND of the window providing the display context
 *  pRect           LPRECT containing the rectangle to convert.
 *
 * Return Value:
 *  None.
 */

void WINAPI RectConvertToHiMetric(HWND hWnd, LPRECT pRect)
    {
    HDC      hDC;
    POINT    pt;

    hDC=GetDC(hWnd);
    SetMapMode(hDC, MM_HIMETRIC);

    //Convert upper left corner
    pt.x=pRect->left;
    pt.y=pRect->top;
    DPtoLP(hDC, &pt, 1);
    pRect->left=pt.x;
    pRect->top=-pt.y;

    //Convert lower right corner
    pt.x=pRect->right;
    pt.y=pRect->bottom;
    DPtoLP(hDC, &pt, 1);
    pRect->right=pt.x;
    pRect->bottom=-pt.y;

    ReleaseDC(hWnd, hDC);
    return;
    }







/*
 * RectConvertToDevice
 *
 * Purpose:
 *  Converts the contents of a rectangle from MM_HIMETRIC into MM_TEXT
 *  specifically for use in converting a RECT of an OLE object into
 *  a RECT for a window.
 *
 * Parameters:
 *  hWnd            HWND of the window providing the display context
 *  pRect           LPRECT containing the rectangle to convert.
 *
 * Return Value:
 *  None.
 */

void WINAPI RectConvertToDevice(HWND hWnd, LPRECT pRect)
    {
    HDC      hDC;
    POINT    pt;

    hDC=GetDC(hWnd);
    SetMapMode(hDC, MM_HIMETRIC);

    //Convert upper left corner
    pt.x=pRect->left;
    pt.y=pRect->bottom;
    LPtoDP(hDC, &pt, 1);
    pRect->left=pt.x;
    pRect->bottom=pt.y;

    //Convert lower right corner
    pt.x=pRect->right;
    pt.y=pRect->top;
    LPtoDP(hDC, &pt, 1);
    pRect->right=pt.x;
    pRect->top=pt.y;

    ReleaseDC(hWnd, hDC);
    return;
    }

⌨️ 快捷键说明

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