輕鬆開發多點觸控? 如何簡化並加速裝置開發? 想嘗試接CASE賺外快?
[ 回上頁 ] [ 討論區發言規則 ]
N900超智慧電腦手機 震撼登台?
如何簡化並加速裝置開發?

誰有用Win32去控制雙螢幕的範例



回饋點數 :
更改我的閱讀文章字型大小
作者 : player(PLAYER)
[ 貼文 1519 | 人氣 138661 | 評價 2620 | 送出評價 104 次 ] 貼文超過1000則人氣指數超過100000點
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
2006/5/25 下午 07:14:19
麻煩請幫忙找一下好嗎?
記得好像是用跟裝置相關的API
作者 : player(PLAYER)
[ 貼文 1519 | 人氣 138661 | 評價 2620 | 送出評價 104 次 ] 貼文超過1000則人氣指數超過100000點
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
2006/5/25 下午 07:30:59
換一個方法問好了

GetDesktopWindow()
是取的目前桌面的HWND

那如果是雙螢幕時
該如何取的另一個螢幕的桌面的HWND呢?
作者 : johnny6740(牧童哥)
[ 貼文 791 | 人氣 24021 | 評價 3770 | 送出評價 31 次 ] VC++優秀好手驅動程式優秀好手Assembly優秀好手貼文超過500則人氣指數超過10000點
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
主題發起人player註記此篇回應為很有道理 2006/5/26 上午 09:28:28
參考看看

http://www.codeproject.com/system/multiplemonitor.asp
作者 : johnny6740(牧童哥)
[ 貼文 791 | 人氣 24021 | 評價 3770 | 送出評價 31 次 ] VC++優秀好手驅動程式優秀好手Assembly優秀好手貼文超過500則人氣指數超過10000點
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
主題發起人player註記此篇回應為很有道理 2006/5/26 上午 10:45:33
之前別人問的

http://www.programmer-club.com/pc2020v5/forum/ShowSameTitleN.asp?board_pc2020=vc&id=22919&szKeyword=dualview
作者 : jonay(jonay)
[ 貼文 624 | 人氣 8025 | 評價 3680 | 送出評價 27 次 ] C++ Builder優秀好手貼文超過500則
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
主題發起人player註記此篇回應為很有道理 2006/5/26 下午 01:54:00
以前留下的資料參考看看
In order to give applications access to multiple-monitor information, Microsoft has added several new Win32 API functions and updated several existing functions. In addition to new functions, there is also a new type of handle, the HMONITOR, which represents a physical display device. In order to get and set the settings of a particular monitor, you first need to obtain an HMONITOR, which will always point to the same monitor.
The first of the new functions we will discuss is MonitorFromPoint, which has the following definition:
HMONITOR MonitorFromPoint(POINT pt,
DWORD dwFlags);
The returned HMONITOR is the monitor that contains the POINT passed to the function. If no monitor contains the specified point, then the return value of MonitorFromPoint is determined by dwFlags, for which there are three possible values: MONITOR_DEFAULTTONULL returns NULL if the point is not contained by any monitor, MONITOR_DEFAULTTOPRIMARY returns the primary display device, and MONITOR_DEFAULTTONEAREST returns the monitor closest to the point.
HMONITOR MonitorFromRect(LPRECT lprc,
DWORD dwFlags);
HMONITOR MonitorFromWindow(HWND hWnd,
DWORD dwFlags);
MonitorFromRect and MonitorFromWindow return the handle of the monitor that contains the largest portion of the specified rectangle or window. If no monitor contains the specified rectangle or window, the return value depends upon the value of the dwFlags field, which has the same possible values for these two functions as it does for MonitorFromPoint.
Once you have obtained an HMONITOR, you can use the function GetMonitorInfo to retrieve a MONITORINFO structure filled with data relevant to the specified monitor, as follows:
BOOL GetMonitorInfo( HMONITOR hmonitor, LPMONITORINFO lpmi);
typedef struct tagMONITORINFO
{
DWORD cbSize;
RECT rcMonitor;
RECT rcWork;
DWORD dwFlags;
} MONITORINFO, *LPMONITORINFO;
作者 : jonay(jonay)
[ 貼文 624 | 人氣 8025 | 評價 3680 | 送出評價 27 次 ] C++ Builder優秀好手貼文超過500則
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
主題發起人player註記此篇回應為很有道理 2006/5/26 下午 01:55:38
typedef struct tagMONITORINFOEXA
{
MONITORINFO;
TCHAR szDevice[CCHDEVICENAME];
} MONITORINFOEX, *LPMONITORINFOEX;

There are actually two versions of this structure, MONITORINFO and MONITORINFOEX. The cbSize member contains the size of the structure, and it is used by Windows to determine whether a structure is a MONITORINFO or MONITORINFOEX. After a successful call to GetMonitor, the rcMonitor member contains the rectangle of the monitor within the virtual desktop. The rcWork member contains the work area of the monitor within the virtual desktop. (A monitor's work area is the portion not covered by the taskbar.) The dwFlags member has only one possible value, MONITORINFOF_PRIMARY, which is set if the monitor is the primary display. The MONITORINFOEX structure has one additional parameter, szDevice, which contains the unique name of the device. The device name can be passed to other functions, such as ChangeDisplaySettingsEx, allowing the settings for each monitor to be changed independently.
Before you pass GetMonitorInfo a pointer to a MONITORINFO or MONITORINFOEX structure, you must set the cbSize member to the size of the structure so that Windows can determine which structure is being used. The following code sample shows how:
MONITORINFOEX mix;
mix.cbSize = sizeof(mix);
GetMonitorInfo(hMonitor,
(LPMONITORINFO)&mix);
作者 : jonay(jonay)
[ 貼文 624 | 人氣 8025 | 評價 3680 | 送出評價 27 次 ] C++ Builder優秀好手貼文超過500則
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
主題發起人player註記此篇回應為很有道理 2006/5/26 下午 01:56:36
Some changes were made to GetSystemMetrics to allow the use of multiple monitors. Passing SM_CXSCREEN and SM_CYSCREEN as parameters returns the x and y extents, respectively, of only the primary monitor. If you wish to get the x and y extents of the virtual desktop, use the new constants SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN; GetSystemMetrics will return the left and top coordinates of the virtual desktop, respectively. You can no longer assume the top-left corner of the desktop is (0,0), and the extents will do you no good if you don't know the origins. Passing the new constant SM_SAMEDISPLAYFORMAT to GetSystemMetrics will return TRUE if all of the monitors on the system have exactly the same color settings, FALSE otherwise. Use the constant SM_CMONITORS when you want to know how many monitors make up the virtual desktop. Note that this value includes only installed monitors that have been added to the desktop by the user.
The SystemParametersInfo function has also been changed slightly. The changes affect only the uiAction values SPI_GETWORKAREA and SPI_SETWORKAREA. Using the former always returns the work area of the primary monitor. If you want to get the work area of another monitor, you need to use GetMonitorInfo. Using SPI_SETWORKAREA sets the work area of the monitor that contains the RECT structure passed into the pvParam value.
EnumDisplayMonitors is a new function that allows an application to optimize its drawing code when a window is being partially displayed on multiple monitors that have different color-bit depths.
BOOL WINAPI EnumDisplayMonitors(
HDC hdc,
LPCRECT lprcClip,
MONITORENUMPROC lpfnEnum,
LPARAM dwData);
作者 : jonay(jonay)
[ 貼文 624 | 人氣 8025 | 評價 3680 | 送出評價 27 次 ] C++ Builder優秀好手貼文超過500則
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
主題發起人player註記此篇回應為很有道理 2006/5/26 下午 01:58:06
The MONITORENUMPROC callback is called for each monitor that intersects the visible region of hdc and the lprcClip parameter. If the lprcClip parameter is NULL, then no additional clipping is performed. The dwData parameter is for user-defined data and is passed through to the dwData parameter in the callback function. MONITORENUMPROC is a user-defined callback function that must have the following signature:
BOOL CALLBACK MonitorEnumProc(
HMONITOR hmonitor,
HDC hdcMonitor,
LPRC lprcMonitor,
DWORD dwData);
If the hdc passed to EnumDisplayMonitors was NULL, then hdcMonitor is NULL. Otherwise, hdcMonitor contains a valid device context whose color attributes match the display monitor defined by hmonitor. If hdcMonitor is NULL, then lprcMonitor is in virtual-desktop coordinates. It is important to note that no application needs to use EnumDisplayMonitors to handle monitors of differing bit depths, since Windows automatically dithers high-color images on lower-color devices. You should use this function only if you want to do custom dithering to ensure the best possible display. In order to help you understand exactly how EnumDisplayMonitors is used, I will present a couple of code snippets illustrating common usage scenarios.
One use for EnumDisplayMonitors is to make sure that images are drawn optimally on lower-color devices. The best way to do this is to change how your window's WndProc handles the WM_PAINT message.
case WM_PAINT:
HDC hdc;
hdc = BeginPaint(hWnd,
&paintStruct);
EnumDisplayMonitors(hdc, NULL, monitorEnumPaintProc, 0);
EndPaint(&paintStruct);
Inside your callback, you query the passed device context to determine its capabilities and display area and do your drawing accordingly.
作者 : jonay(jonay)
[ 貼文 624 | 人氣 8025 | 評價 3680 | 送出評價 27 次 ] C++ Builder優秀好手貼文超過500則
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
主題發起人player註記此篇回應為很有道理 2006/5/26 下午 01:59:49
You can also use EnumDisplayMonitors to query every monitor on the desktop. If the device context and RECT passed into EnumDisplayMonitors are both NULL, no clipping is performed and your callback function is called once for each monitor in the virtual desktop. The code in Figure 3 caches the work area of every monitor for later use. (Note that if your application actually did this, you would need to update the cached information when the WM_DISPLAYCHANGE message was received, since the values might change.)
Another way to query display devices is the EnumDisplayDevices function, which can query all devices available on the system, whether or not they're part of the virtual desktop.
BOOL WINAPI EnumDisplayDevices(
PVOID Unused,
DWORD iDevNum,
PDISPLAY_DEVICE lpDisplayDevice,
DWORD dwFlags);
Unused is reserved for future use and must be set to NULL. There are no valid values for dwFlags, so set it to 0. iDevNum is the index of the device you wish to query and is zero-based. If there is not a device available in the iDevNum position, EnumDisplayDevices returns FALSE. If there is a device in the position indicated by iDevNum, EnumDisplayDevices returns TRUE and fills in lpDisplayDevice. So to examine all devices on the system, you'd call EnumDisplayDevices for each possible index, starting with 0, until it returned FALSE. The lpDisplayDDevice parameter is a pointer to a DISPLAY_DEVICE structure, which is defined as follows:
typedef struct _DISPLAY_DEVICE {
DWORD cb;
BYTE DeviceName[32];
BYTE DeviceString[128];
DWORD StateFlags;
} DISPLAY_DEVICE, *PDISPLAY_DEVICE,
*LPDISPLAY_DEVICE;
作者 : jonay(jonay)
[ 貼文 624 | 人氣 8025 | 評價 3680 | 送出評價 27 次 ] C++ Builder優秀好手貼文超過500則
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
主題發起人player註記此篇回應為很有道理 2006/5/26 下午 02:00:21
The cb member contains the size of the structure in bytes. DeviceName is the same unique name returned by GetMonitorInfo in the szDevice member of the MONITORINFOEX structure. DeviceString is a user-friendly description of the enumerated device. Unfortunately, I was not able to find documentation on the possible values of StateFlag, but they seem self-explanatory. Here are their definitions as listed in the Win32 SDK:
#define DISPLAY_DEVICE
_ATTACHED_TO_DESKTOP
0x00000001
#define DISPLAY_DEVICE
_MULTI_DRIVER
0x00000002
#define DISPLAY_DEVICE
_PRIMARY_DEVICE
0x00000004
#define DISPLAY_DEVICE
_MIRRORING_DRIVER
0x00000008
#define DISPLAY_DEVICE
_VGA_COMPATIBLE
0x00000010
Since EnumDisplayDevices allows you to query devices that aren't part of the desktop, your application can use monitors in an exclusive manner, without having to share the screen with the desktop. To do this, find a device that doesn't have the DISPLAY_DEVICE_ATTACHED_TO_DESKTOP bit set and call the Win32 API function CreateDC, passing the name returned in the DeviceName member of lpDisplayDevice. If you create a device context in this manner, you should delete it when you're done with it by calling DeleteDC.
Next: Other Issues
Published as Power Programming in the 4/7/98 issue of PC Magazine.
作者 : ericzhaow(ericzhaow)
[ 貼文 21 | 人氣 1 | 評價 160 | 送出評價 0 次 ] 
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
2006/5/26 下午 05:16:56
在WINDOW下,雙螢幕可以當作延申桌面來操作!!

也就是說在設定好延申桌面的狀態下

Monitor 1 800X600
Monitor 2 800X600

Monitor 2的位置是在(801,0)~(1600,600)
直接WindowPos設置過去就可以了
作者 : ericzhaow(ericzhaow)
[ 貼文 21 | 人氣 1 | 評價 160 | 送出評價 0 次 ] 
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
2006/5/26 下午 05:19:07
上面是AP端的使用.....

Driver端的...就幫不上忙了

你需要的應該是Driver端的控制吧.....
作者 : player(PLAYER)
[ 貼文 1519 | 人氣 138661 | 評價 2620 | 送出評價 104 次 ] 貼文超過1000則人氣指數超過100000點
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
2006/6/1 下午 01:43:20
先EnumDisplayDevices
取得name of display device
再用 ChangeDisplaySettingsEx
配合CDS_SET_PRIMARY使用呢?
用切換Windows預設顯示裝置的方法
不知道
是否可行?
作者 : jonay(jonay)
[ 貼文 624 | 人氣 8025 | 評價 3680 | 送出評價 27 次 ] C++ Builder優秀好手貼文超過500則
[ 回應本文 ]  [ 發表新文 ]  [ 給予評價 ]  [ 給予評價 ]  [ 回上頁 ] [ 回討論區列表 ] [ 回知識入口 ]
2006/6/1 下午 03:30:11
不太清楚你要的是什麼
請到codeproject首頁下,以mutiple monitor搜尋
有幾個"飯粒"可看看
例:
http://www.codeproject.com/gdi/multimon.asp
 板主 : 徵求中
 > 驅動程式
 - 最近熱門問答精華集
 - 全部歷史問答精華集
 - 驅動程式討論區
  ■ 月熱門主題
  ■ 季熱門主題
  ■ 熱門主題Top 20
  ■ 本區Post排行榜
  ■ 本區評價排行榜
  ■ 全站專家名人榜
  ■ 全站Post排行榜
  ■ 全站評價排行榜
  ■ 全站人氣排行榜
  ■ 全站最新Post列表
  ■ 我的文章收藏
  ■ 文章收藏排行榜
  ■ 我最愛的作者
  ■ 最愛作者排行榜
 請輸入關鍵字 
  開始搜尋
 
Top 10
評價排行
驅動程式
1 新兵衛 1090 
2 eBoy 970 
3 牧童哥 780 
4 天行者 580 
5 北極熊 550 
6 燒酒仙 440 
7 KEN 350 
8 weber 290 
9 jonay 180 
10 掌握文武半邊天 180 
驅動程式
  專家等級 評價  
  一代宗師 10000  
  曠世奇才 5000  
  頂尖高手 3000  
  卓越專家 1500  
  優秀好手

750

 
Microsoft Internet Explorer 6.0. Screen 1024x768 pixel. High Color (16 bit).
2000-2010 程式設計俱樂部 http://www.programmer-club.com.tw/