基于WINDOWS 32API封装的显示器类: (1) 头文件

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-02 01:57 点击:

 1/************************************************************************
 2  @file monitor.h
 3  * Author: qinqing
 4  * Date:   2009-12-2
 5************************************************************************/
 6
 7#ifndef _MONITOR_H
 8
 9#if WINVER < 0x0500
10#include <multimon.h>
11#endif
12#include "..\common\tstring.h"
13#include "..\common\macro.h"
14#include <map>
15
16/**
17  @brief 显示器类
18  @class CMonitor
19*/
20class CMonitor
21{
22    friend class CMonitorManager;
23public:
24    void   GetMonitorRect(RECT& rect) const;
25    void   GetWorkAreaRect(RECT& rect) const;
26    DWORD  GetPixelWidth() const;
27    DWORD  GetPixelHeight() const;
28    DWORD  GetBitsPerPixel() const;
29    DWORD  GetMonitorLeft() const;
30    DWORD  GetMonitorTop() const;
31    DWORD  GetDisplayFrequency() const;
32    bool   IsPrimaryMonitor() const;
33  tstring GetName() const { return m_strName; }
34  DWORD GetIndex() const { return m_dwIndex; }
35  operator HMONITOR() const { return m_hMonitor; }
36   
37protected:
38    void CenterRectToMonitor(LPRECT lprc, bool bWorkArea= false) const;
39
40private:
41    CMonitor(HMONITOR hMonitor, DWORD dwIndex);
42
43private:
44  HMONITOR m_hMonitor; /**////< 显示器句柄
45    DWORD    m_dwIndex;  ///< 显示器索引
46    tstring  m_strName;  ///< 显示器名称
47};
48
49/**
50  @brief 显示器管理类
51  @class CMonitorManager
52  * 仅支持多屏独立显示模式(每个显示器分辨率是独立的),其它模式(大水平,大垂直,复制)暂不考虑
53*/
54class CMonitorManager
55{
56    SINGLETON_DECLARE(CMonitorManager) ///< 单件声明宏
57
58public:
59    DWORD     GetCount();
60    CMonitor* GetMonitor(DWORD dwIndex);
61    CMonitor* GetPrimaryMonitor();
62    CMonitor* GetNearestMonitor(const RECT& rect);
63    CMonitor* GetNearestMonitor(const POINT& pt);
64    CMonitor* GetNearestMonitor(HWND hWnd);
65  
66public:
67    static void GetVirtualDesktopRect(RECT& rect);
68    bool FullScreenWindow(HWND hWnd, bool bFullScreen, int iMonitorIndex = 0);
69    bool FullScreenWindow(HWND hWndFirst, HWND hWndSecond);
70    void CenterWindow(HWND hWnd, int iMonitorIndex = 0, bool bUseWorkArea = false);
71
72protected:
73    static BOOL CALLBACK AddMonitorsCallBack(HMONITOR hMonitor,HDC hdcMonitor,LPRECT lprcMonitor,
74           LPARAM dwData);
75
76private:
77    void      CenterWindowToAll(RECT& rect, bool bUseWorkArea = false);
78    void      UpdateMonitors();
79    CMonitor* FindMonitor(HMONITOR hMonitor);
80    void      FreeMonitors();
81
82private:
83    struct WndInfo
84    {
85        WndInfo(lo

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • dos命令原来也能这样用?允许查找未知子目录指定文件
    •  windows的磁盘操作之八——格式化分区的思考
    • windows篇-第三章 安装和配置DNS服务器
    • windows篇-第二章 安装和配置Web服务器
    • windows篇-第一章 windows server 2008安装和简单配置
    •  windows server 2003断开远程之后自动注销用户
    • Windows服务器下用IIS Rewrite组件为IIS设置伪静态方法
    • Windows 2008 R2 SP1部署WSUS 3.0 SP2
    • Windows 7秘籍揭秘:用“手”写公式

    快速直达

    操作系统导航

    LinuxWindows虚拟机
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1