Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written the below function to generate a fake blue screen of death (BSOD) - which works well on a single monitor. I am not sure what is the best way to go about dealing with multiple monitors.

C++
void BSOD(){
	
     HDC        hdcScr, hdcMem, hdcOrig ;
     int        cx, cy, lines ;
     HBITMAP    hBitmap, hOriginal ;
     HWND       hwnd ;
	 RECT rect;
     HFONT hFont = CreateFont(
                   27, 16, 0, 0,FW_NORMAL, FALSE, FALSE, FALSE,
                   ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
                   DEFAULT_QUALITY,DEFAULT_PITCH|FF_ROMAN,"Courier New"
             );

     if (LockWindowUpdate (hwnd = GetDesktopWindow ())){
          hdcScr  = GetDCEx (hwnd, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE) ;
          hdcMem  = CreateCompatibleDC (hdcScr) ;
          hdcOrig  = CreateCompatibleDC (hdcScr) ;
          
          cx      = GetSystemMetrics (SM_CXSCREEN) ;
          cy      = GetSystemMetrics (SM_CYSCREEN);
          hBitmap = CreateCompatibleBitmap (hdcScr, cx, cy) ;
          hOriginal = CreateCompatibleBitmap (hdcScr, cx, cy) ;
          rect.top = 0;
	  rect.left = 0;
	  rect.right = cx;
	  rect.bottom = cy;
			
          SelectObject (hdcMem, hBitmap) ;
          FillRect(hdcMem, &rect, CreateSolidBrush(RGB(0,0,0x77)));
          SelectObject(hdcMem, hFont);
          SetTextColor(hdcMem,RGB(0xFF,0xFF,0xFF));
          SetBkColor(hdcMem,RGB(0,0,0x77));    
       
	  lines = 18;
          while(lines--) write_out(hdcMem,lines);
		  
	  BitBlt (hdcScr, 0, 0, cx, cy, hdcMem,  0,  0, SRCCOPY) ;

	  Sleep(5000);
	  BitBlt (hdcScr, 0, 0, cx, cy, hdcOrig,  0,  0, SRCCOPY) ;
          
          DeleteDC (hdcMem) ;
          ReleaseDC (hwnd, hdcScr) ;
          DeleteObject (hBitmap) ;
             
          LockWindowUpdate (NULL) ;
     }
     return ;
}
Posted
Updated 12-Aug-14 13:22pm
v2

1 solution

I publish an article about Multimonitor Windows issues and some useful tasks how to deal with it.

I hope it is a joke, dont ferget that some people may get very terrified ;-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900