| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2418 人关注过本帖
标题:只显示到扩展屏的VC6实现方法
只看楼主 加入收藏
wsg1212
Rank: 1
来 自:518抽奖软件
等 级:新手上路
帖 子:14
专家分:0
注 册:2015-5-6
收藏
 问题点数:0 回复次数:0 
只显示到扩展屏的VC6实现方法

在开发518年会抽奖软件(www.)的时候,软件需支持扩展屏,电脑屏后台操作,扩展大屏滚动抽奖。主要包括以下三个功能,主窗口全屏化(主屏内)、主窗口窗口化(主屏内)、主窗口只显示到扩展屏(第二屏)。

一、主窗口全屏化、窗口化(主屏内)

    //创建窗口 - 以 WS_POPUP 样式创建窗口
        m_hMain = CreateWindow (WNDCLASS_NAME, g_title, WS_POPUP, 0, 0, 0, 0, NULL, NULL, m_hInst, NULL);

    //窗口化 - x/y:窗口位于主屏的位置,w/h:窗口的宽高
        MoveWindow (m_hMain, m_wmode.x, m_wmode.y, m_wmode.w, m_wmode.h, TRUE);

    //全屏化 - cx/cy:主屏的大小
        int cx = GetSystemMetrics (SM_CXSCREEN);
        int cy = GetSystemMetrics (SM_CYSCREEN);
        MoveWindow (m_hMain, 0, 0, cx, cy, TRUE);
   
二、主窗口只显示到扩展屏(第二屏)

    //枚举显示屏 - 获得扩展屏(第二屏)的坐标,left/top/right/bottom
        static BOOL CALLBACK Callback_enumMonitors (HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
        {
            RECT* pRect = (RECT*) dwData;
        
            MONITORINFO mi = {0};         
            mi.cbSize = sizeof (MONITORINFO);
            GetMonitorInfo (hMonitor, &mi);
            if (mi.dwFlags != MONITORINFOF_PRIMARY)
            {
                *pRect = mi.rcMonitor;
                return FALSE;
            }
            return TRUE;
        }

    //显示主窗口到扩展屏
        void Tapp::show_expanscrn ()
        {
            RECT rc = {0};
            EnumDisplayMonitors (NULL, NULL, Callback_enumMonitors, (LPARAM) &rc);
            if (rc.left == 0 && rc.top == 0 && rc.right == 0 && rc.bottom == 0)
                MessageBox (m_hMain, L"无扩展屏", g_title, MB_OK | MB_ICONWARNING);
            else
                MoveWindow (m_hMain, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE);
        }
   
三、对话框位于扩展屏中央

    //对话框默认是位于主屏的中央的,如果想位于扩展屏中央,就要在对话框的 WM_INITDIALOG 消息中,执行下列函数
        Tfuns::center_box (hDlg);

        void Tfuns::center_box (HWND hDlg)
        {
            RECT rc;
            HWND hDesktop = GetDesktopWindow ();
            GetWindowRect (hDesktop, &rc);
            int desk_h = rc.bottom - rc.top;
            int desk_w = rc.right - rc.left;
        
            GetWindowRect (hDlg, &rc);
            int wnd_w = rc.right - rc.left;
            int wnd_h = rc.bottom - rc.top;
        
            int x = (desk_w - wnd_w) / 2;
            if (x < 0) x = 0;
        
            int y = (desk_h - wnd_h) / 2;
            if (y < 0) y = 0;
        
            SetWindowPos (hDlg, NULL, x, y, 0, 0, SWP_NOSIZE);
        }
   
搜索更多相关主题的帖子: 大屏 开发 软件 
2016-11-19 19:54
快速回复:只显示到扩展屏的VC6实现方法
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015060 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved