 |
|
|
I have written an application to display video. When running in a dual monitor system the video become black in one and available in other. Can any body pls send me ideas about this. Thanks in advance
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
Hi~I want to ask some question about MultiMonitor. I had used EnumDisplayDevices EnumDisplaySettings and ChangeDisplaySettingsEx extended desktop to secondary monitor, but still want to realize mirror display too. I think maybe you can help me. Would you please give me some direction? Thank you!
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
For retrive bits per pixel for each monitor could be used EnumDisplaySettings() function :
DEVMODE dev; BOOL res = ::EnumDisplaySettings( MonitorName, // get from MONITORINFOEX::szDevice ENUM_CURRENT_SETTINGS, &dev ); if (res) { TRACE( "BPP for %-s is %-d\n", MonitorName, dev.dmBitsPerPel ); }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
If I understand what you're getting at take a look at the implementation of CMonitor::GetBitsPerPixel and CMonitor::CreateDC. You'll see that the value reported is specific to the HMONITOR wrapped by a particular instance of CMonitor.
HDC CMonitor::CreateDC() const { ASSERT( IsMonitor() );
CString name; GetName( name );
//create a dc for this display HDC hdc = ::CreateDC( name, name, NULL, NULL ); ASSERT( hdc != NULL );
//set the viewport based on the monitor rect's relation to the primary monitor CRect rect; GetMonitorRect( &rect );
::SetViewportOrgEx( hdc, -rect.left, -rect.top, NULL ); ::SetViewportExtEx( hdc, rect.Width(), rect.Height(), NULL );
return hdc; }
int CMonitor::GetBitsPerPixel() const { HDC hdc = CreateDC(); int ret = ::GetDeviceCaps( hdc, BITSPIXEL ) * ::GetDeviceCaps( hdc, PLANES ); VERIFY( ::DeleteDC( hdc ) );
return ret; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
One problem - the monitors could have the different bits-per-pixel values. And I didn't find the way how to solve it ;(
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I am writing a program for a Scoreboard that contains a SplitterWnd, the upper Window (ScoreboardWnd) displays the whole screen with (Period Time, Scores, .. etc). The lower window contains all the Input’s and Buttons to administrate the Scoreboard.
I now want to display only the ScoreboardWnd on another VGA screen (Full mode). I have looked at the CMonitor class and tested it properly.
On a Laptop with a 2nd VGA out I connected a 2nd TFT screen to see how the program works.
Now a few questions: How can I display out from a SplitterWnd a window on the 2nd screen? On the laptop the whole program should be displayed. The program is made with VC 7.xx!
It would be great if you have a sample for such a case I described above. Great work by the way!
Thanks in advance Best regards
Karl
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
These are very useful classes, but there is one problem. In Monitors.cpp, you assume that GetSystemMetrics(SM_CMONITORS) will return the number of monitors that EnumDisplayMonitors() will enumerate. This is usually correct, but not always. I am working on a Win2000 system where GetSystemMetrics returns 1, but EnumDisplayMonitors finds 2! When this happens, the line
pAddMonitor->pMonitors->SetAt( pAddMonitor->currentIndex, pMonitor ); will assert, because currentIndex will be greater than the array size.
I believe the reason for this is what MSDN refers to as "invisible pseudo-monitors associated with mirroring drivers". To avoid this problem, you can use the EnumDisplayDevices() API, where you can explicitly test for the flag DISPLAY_DEVICE_MIRRORING_DRIVER.
|
| Sign In·View Thread·PermaLink | 5.00/5 (3 votes) |
|
|
|
 |
|
|
Hmmm. Thanks for the heads up. I wasn't aware of the existence of "invisible pseudo-monitors" 
I'll post a fix when I get a chance.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
This may not be a complete fix, but at least it keeps the app from crashing:
static BOOL CALLBACK /*CMonitors::*/ AddMonitorsCallBack(HMONITOR hMonitor, HDC /*hdcMonitor*/, LPRECT /*lprcMonitor*/, LPARAM dwData ) { LPADDMONITOR pAddMonitor = (LPADDMONITOR)dwData;
CMonitor* pMonitor = new CMonitor; pMonitor->Attach( hMonitor );
if (pAddMonitor->currentIndex < pAddMonitor->pMonitors->GetSize()) { pAddMonitor->pMonitors->SetAt( pAddMonitor->currentIndex, pMonitor ); pAddMonitor->currentIndex++; }
return TRUE; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
How about using SetAtGrow ?
pAddMonitor->pMonitors->SetAtGrow( pAddMonitor->currentIndex, pMonitor );
MSDN Remarks
Sets the array element at the specified index. The array grows automatically if necessary (that is, the upper bound is adjusted to accommodate the new element).
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Does anybody have any ideas or code as to how to programmatically turn off and on the second monitor?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
i already include the CMonitor class...but still it is not defined....can u please help me...i try to find the documentation of this class..but failed...
error C2079: 'monitor' uses undefined class 'CMonitor'
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
When the test application has MFC statically linked in, the following errors are produced:
Linking... nafxcwd.lib(wincore.obj) : error LNK2005: _g_fMultimonPlatformNT already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _g_fMultiMonInitDone already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _g_pfnEnumDisplayDevices already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _g_pfnEnumDisplayMonitors already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _g_pfnGetMonitorInfo already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _g_pfnMonitorFromPoint already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _g_pfnMonitorFromRect already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _g_pfnMonitorFromWindow already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _g_pfnGetSystemMetrics already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _IsPlatformNT already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _InitMultipleMonitorStubs already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _xGetSystemMetrics@4 already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _xMonitorFromPoint@12 already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _xMonitorFromRect@8 already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _xMonitorFromWindow@8 already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _xGetMonitorInfo@8 already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _xEnumDisplayMonitors@16 already defined in Multimon.obj nafxcwd.lib(wincore.obj) : error LNK2005: _xEnumDisplayDevices@16 already defined in Multimon.obj Debug/MonitorTest.exe : fatal error LNK1169: one or more multiply defined symbols found
Do you know of a way around this (except of course using run time binding )?
Terry
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
Same problem in placing in a static/multithread app, simply exclude the offending libaries till the problem goes away (honest !)
For example exclude nafxcwd.lib - done in MSDEV in the link input option in Project settings
Bob
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
There is another possibility that the compiled liberaries and your programe may have build on different character set configuration. If a programe settings shows that character set is Unicode and Liberary project settings shows that character set is multi byte then this error appear. wish you good luck
kifatayullah
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi There,
THis is a great example of multi monitor...
I'm working on an app, where I want my VC++ app, running on my secondary monitor. I compile it on my second monitor, but I'm only able to get it on my primary monitor. I don't want to see it on both monitor just on display 2. From seeing at MonitorTest app, I use my CMainFrame, PreCreateWindow to do the following: cs.x = 0; cs.y = 0;
CRect rect; CMonitors::GetVirtualDesktopRect( &rect );
cs.cx = (rect.right - rect.top) - 1024; cs.cy = (rect.bottom - rect.left) - 168;
That makes my windows the size of my seconday display. my primary display resolution is 1024 X 768 and secondary is 800 X 600. THe other thing is that when I compile MonitorTEst app, on my secondary monitor it works fine, it starts running on the 2nd display, but no when I run my app.
Does anyone has any idea why this is happening? Thanks in advanced for your help.
B
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
If I understand what your trying to do, you want your app to always start on your non-primary monitor.
In your OnInitialUpdate, OnCreate, or OnInitDialog (if you're using MFC) do something like the following (untested pseudo-code):
CMonitors monitors;
CMonitor monitor; for ( int i = 0; i < monitors.GetCount(); i++ ) { monitor = monitors.GetMonitor( i ); if ( !monitor.IsPrimaryMonitor() ) break; }
ASSERT( monitor.IsMonitor() );
monitor.CenterWindowToMonitor( this ); This should cause your window to always start up on the first non-primary monitor in the monitors collection. If you have only one monitor it will center to that.
Hope this helps, don
|
| Sign In·View Thread·PermaLink | 4.00/5 (2 votes) |
|
|
|
 |
|
|
CMonitor monitor = monitors.GetMonitor(1); if (monitor.CreateDC() != NULL) { CMonitorDC monitorDC( &monitor );
monitor.GetMonitorRect(&rc); // hWnd is Handle of window which have something that i get from that StretchBlt(monitorDC, 300, 400, 400, 300, GetDC(hWnd), 0, 0, rc2.right - rc2.left, rc2.bottom - rc2.top, SRCCOPY); CString s = "Copyright by VietDoor"; rc.top = rc.bottom - 20; DrawText(monitorDC, s, s.GetLength(), &rc, DT_LEFT); }
I want to get what on hWnd to draw to Monitor, but text drawing is ok, draw something using StretchBlt function not work.
Help me.
-------------------------- ERP VN: www.erpvn.net
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |