|
Antwort schreiben
Hugo 2000-08-23 03:37
Hi again Christian and folks! I recently post the "G400MAXDH, W2k & MFC" topic. Finally I got my app running under w2k with two/three monitors. I use a G400Max DualHead as secondary and an old Cirrus GL5440 I found as primary. If I configure the desktop with two monitors there's no problem with the app I wrote, I have two independent images from two cameras, each one on diferent monitors . The problem araise when the app try to paint on a monitor which is not part of the desktop. I have been reading some info and then tried to create a DC like that:
DISPLAY_DEVICE DisplayDevice; ZeroMemory(&DisplayDevice,sizeof(DisplayDevice)); DisplayDevice.cb = sizeof(DISPLAY_DEVICE); // I get the diplay name with for(int i=0;EnumDisplayDevices(NULL, i, &DisplayDevice, 0),i++) { // if it's an independent monitor... if(!(DisplayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) && (!(DisplayDevice.StateFlags &DISPLAY_DEVICE_MIRRORING_DRIVER))) { // Create a DC for it and paint a bitmap LPCTSTR lpszDriverName = (char *)DisplayDevice.DeviceName; // here lpszDriverName = "\\.\DISPLAY2" HDC hDC = CreateDC(lpszDriverName, NULL, NULL, NULL); CDC* pDC = CDC::FromHandle(hDC); PaintCameraImage(1); DeleteDC(hDC); }
It gets a NULL hDC and get the 1801 error: "The printer name is invalid." I've tried setting the display settings (ChangeDisplaySettingsEX) for the independent monitor before creating the DC and nothing, the same result... I don´t know what to do, is there a way to enable painting on a monitor that is not part of the desktop? I thought CreateDC was the way... Anyway I'll add my multimonitor config to the database. If anyone has a hint, please tell me,
Hugo
|
Christian Studer 2000-08-23 08:25
I tried this as well, doesn't work. I think it is simply a documentation error, they probably planned to support this, never implemented it and failed to remove the documentation.
According to the docs, you should also be able to use disabled monitors from DirectX, but it's the same story there.
Christian Studer http://www.realtimesoft.com
|
Hugo 2000-08-23 22:20
Yes, I tried too with DirectX and it doesn't work. I am going to ask MS developper suport and see what happens. I don't understand why we cannot do that... Thanks anyway!
Hugo
|
Hugo 2000-08-23 23:45
Hi again! I have been looking throught the MSDN home web site and found this:
"Using Multiple Monitors as Independent Displays
When using multiple monitors as independent displays, the desktop contains one display or set of displays. This set of displays always includes the primary monitor and behaves as mentioned in the other sections of this topic. An application can use any other monitor as an independent display.
The window manager knows nothing about the independent displays. They are completely controlled by the application, and no window manager functions are available to the application (all window manager calls automatically go to the primary display). Each independent display has its own origin and horizontal and vertical coordinates, and is accessed through the GDI functions such as CreateDC or the DirectX functions such as DirectDrawCreate.
To locate the independent displays, call EnumDisplayDevices and look for the displays that do not have DISPLAY_DEVICE_ATTACHED_TO_DESKTOP flag in the DISPLAY_DEVICE structure.
An application can open a display by calling
hdc = CreateDC(lpszDisplayName, lpDevMode, NULL, NULL);
In this call, the lpszDisplayName parameter is one of the device names returned by EnumDisplayDevices and lpDevMode is a description of the graphics mode for this device. The resulting hdc can be used to perform any graphics operation to the device.
Built on Wednesday, January 05, 2000 Send feedback to the Platform SDK.
© 2000 Microsoft Corporation. All rights reserved. Terms of use."
In the MSDN which comes with Visual C++ 6.0 there is: " hdc = CreateDC(lpszDisplayName, NULL, NULL, NULL); "
There is a bug of course in both cases, they should write:
hdc = CreateDC(lpszDisplayName, NULL, NULL, lpDevMode);
I have been trying that with success, now I am able to paint on an independent monitor!!!!!!!!!
Amazing, isn't it? same stuff I guess with directX...
I hope that will help you as it helps me, now back to programming! And good work for your web site!
Hugo
|
Christian Studer 2000-08-24 02:52
This is great! Works fine here as well, with Win2000. Haven't tested on Win98 yet.
Here's a basic sample if anyone else wants to try this:
DEVMODE dm; ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); EnumDisplaySettingsEx(_T("\\\\.\\DISPLAY3"), ENUM_REGISTRY_SETTINGS, &dm, 0); HDC hDc = CreateDC(_T("\\\\.\\DISPLAY3"), 0, 0, &dm); HBRUSH oldBrush = static_cast<HBRUSH>(SelectObject(hDc, GetStockObject(WHITE_BRUSH))); Rectangle(hDc, 0, 0, dm.dmPelsWidth, dm.dmPelsHeight); MoveToEx(hDc, 0, 0, 0); LineTo(hDc, dm.dmPelsWidth, dm.dmPelsHeight); SelectObject(hDc, oldBrush); DeleteDC(hDc);
You can also change display settings by setting the appropriate DEVMODE members prior to calling CreateDC.
Hugo, thanks for uncovering the best-kept secret in multi-monitor land!
Christian Studer http://www.realtimesoft.com
|
Hugo 2000-08-24 23:08
You are welcome!
Hugo
|
Kada 2000-08-29 20:14
The problem with slashes I have sold before, but here is another more complicated problem. Make a opengl rendering context. I'm trying it in following order. All is done without problem but when I'm trying to make it current(wglMakeCurrent) it returns invalid handle
CreateDC( ChoosePixelFormat( DescribePixelFormat( SetPixelFormat( wglCreateContext( hDC ); wglMakeCurrent( hDC, hRC );
Does anybody solved that problem. In case I can send you complete source code. Any comment or source code is welcome
j.kadrmas@post.cz
|
Antwort schreiben
|