How to displaybitmap on second monitor?
-
I have attached two monitors two my system. Now i want to display a bitmap image on my second monitor.I am able to display a solid fill blue rectangle and able to display a text on it. How can send a bitmap image? Is it possible to send the raw image data without using the BITMAP? Below is the code:
int count = 0; void CMonitorTestDlg::OnBnClickedButtonFlashAll() { CMonitor monitor; CMonitors monitors; CString cstr[2]; for ( int i = 0; i < monitors.GetCount(); i++ ) { count = i+1; monitor = monitors.GetMonitor( i ); FlashMonitor( monitor); Sleep( 500 ); } } void CMonitorTestDlg::FlashMonitor( CMonitor& monitor, bool WorkSpace) { CRect rect; if ( WorkSpace ) //get the work area rect of the monitor this window is on monitor.GetWorkAreaRect( &rect ); else monitor.GetMonitorRect( &rect ); CMonitorDC dc( &monitor ); if(count ==1) { // create and select a solid blue brush CBrush brushBlue(RGB(0, 255, 0)); CBrush* pOldBrush = dc.SelectObject(&brushBlue); rect.DeflateRect(200,200); dc.Rectangle(&rect); COLORREF clr1 = RGB(0,0,0); dc.SetTextColor(clr1); dc.DrawText("Primary Monitor",17,&rect,1); // put back the old objects dc.SelectObject(pOldBrush); } else { // create and select a solid blue brush /*CBrush brushBlue(RGB(0, 0, 255)); CBrush* pOldBrush = dc.SelectObject(&brushBlue); rect.DeflateRect(200,200); dc.Rectangle(&rect); COLORREF clr1 = RGB(0,0,0); dc.SetTextColor(clr1); dc.DrawText("Secondary Monitor",17,&rect,1); // put back the old objects dc.SelectObject(pOldBrush);*/ /*How can i send a bitmap image or a image buffer to second monitor.I have tried to use Bltblt but create compatibleDc need a CDC object not the CMonitor dc.*/ } Sleep( 2000 ); ::InvalidateRect( NULL, &rect, TRUE ); }
Code that i have tried to send a bitmap// load IDB_BITMAP1 from our resources CBitmap bmp; if (bmp.LoadBitmap(IDB_BITMAP1)) { // Get the size of the bitmap BITMAP bmpInfo; bmp.GetBitmap(&bmpInfo); // Create an in-memory DC compatible with the // display DC we're using to paint CDC dcMemory; //dcMemory.CreateCompatibleDC(dc); // Cant do this CMonitorDC * to CDC * // Select the bitmap into the in-memory DC CBitmap* pOldBitmap = dcMemory.