Christian Studer 2005-12-07 07:56
You could either create a device context for the whole desktop, or use CreateDC to create a device context for a specific monitor.
Here are samples for both approaches, Preview is a PictureBox object:
Private Sub PreviewUpdate1()
Dim sys As New ULTRAMONLib.UltraMonSystem
Dim mon As ULTRAMONLib.IUltraMonMonitor
Set mon = sys.Monitors("2")
Dim dc As Long: dc = GetDC(0)
Dim rc As RECT: GetClientRect Preview.hwnd, rc
StretchBlt Preview.hdc, 0, 0, rc.Right, rc.Bottom, dc, mon.Left, mon.Top, mon.Width, mon.Height, SRCCOPY
ReleaseDC 0, dc
End Sub
Private Sub PreviewUpdate2()
Dim sys As New ULTRAMONLib.UltraMonSystem
Dim mon As ULTRAMONLib.IUltraMonMonitor
Set mon = sys.Monitors("2")
Dim dc As Long: dc = CreateDC(mon.AdapterDeviceName, vbNullString, vbNullString, vbNullString)
Dim rc As RECT: GetClientRect Preview.hwnd, rc
StretchBlt Preview.hdc, 0, 0, rc.Right, rc.Bottom, dc, 0, 0, mon.Width, mon.Height, SRCCOPY
DeleteDC dc
End Sub
To use mirroring from your application, you could run UMMirrorClient.exe with the /w argument, and use a control as the parent window:
Shell "C:\Program Files\UltraMon\UMMirrorClient.exe /w 1,0,0,0," & Picture1.hWnd
For more on UMMirrorClient.exe command line arguments, see UltraMon Help > Scripting > Command-line arguments.
Christian Studer - www.realtimesoft.com
|