Darken Windows Desktop and draw normal brightness moveable rectangle [modified]
-
Hi, I am trying to work out how to darken the Windows Desktop and then display a rectangular portion of the desktop normally (not darkened). This is for a screen area capture program. You can see the precise effect I am after in Jing http://www.jingproject.com/[^]. I understand how to make a window transparent, but that's not what I'm after. Fading the background in a Web page is also commonly done. Any tips/pointers/C++ source much appreciated. Google has not helped so far.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
modified on Monday, October 19, 2009 10:33 PM
-
Hi, I am trying to work out how to darken the Windows Desktop and then display a rectangular portion of the desktop normally (not darkened). This is for a screen area capture program. You can see the precise effect I am after in Jing http://www.jingproject.com/[^]. I understand how to make a window transparent, but that's not what I'm after. Fading the background in a Web page is also commonly done. Any tips/pointers/C++ source much appreciated. Google has not helped so far.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
modified on Monday, October 19, 2009 10:33 PM
To do this, Firstly capture the desktop image. then do the following steps. 1. Draw the captured image. 2. Draw the invererted image of captured image over it. some vc++ code snippet to help you:-
void OnDraw( CDC* pDC_i )
{
if( 0 != m_NormalImage )
{
CDC MemDc;
MemDc.CreateCompatibleDC( pDC_i );
CImage *pOldImage = MemDc.SelectObject( m_NormalImage );
CRect rect;
GetClientRect( &rect );
rect.left = HEADER_OFFSET;
rect.right = max( rect.Width(), 300 ) + HEADER_OFFSET;
rect.top = HEADER_OFFSET;
rect.bottom = HEADER_OFFSET + HEADER_HEIGHT ;
COLORREF CurrentBkgd = pDC_i->SetBkColor( IMAGE_HEADER_BKGDCOLOR );
pDC_i->SetBkColor( CurrentBkgd );
pDC_i->BitBlt( 0, HEADER_OFFSET + HEADER_HEIGHT + HEADER_OFFSET , m_nWidth, HEADER_OFFSET + m_nHeight + HEADER_HEIGHT + HEADER_OFFSET,
&MemDc, 0, 0, SRCCOPY );
if( m_bInvertStatus && 0 != m_pInverseImage )
{
DrawInverseImage( pDC_i );} MemDc.SelectObject( pOldImage ); MemDc.DeleteDC(); }
}
void SetInvertImage( HBITMAP himageinverse_i)
{
m_pinverseImage = new CBitmap();
m_pinverseImage->Attach( himageinverse_i);
}void DrawInvertImage( CDC* pDC_i )
{
if( 0 !=m_pinverseImage )
{
CDC Memdc;
Memdc.CreateCompatibleDC( pDC_i );
CBitmap *pOldBitmap = dcMem.SelectObject(m_inverseImage );
pDC_i->BitBlt( 0, HEADER_OFFSET + HEADER_HEIGHT + HEADER_OFFSET, m_nWidth, HEADER_OFFSET + m_nHeight + HEADER_HEIGHT + HEADER_OFFSET,
&dcMem, 0, 0, SRCINVERT );
dcMem.SelectObject( pOldBitmap );
dcMem.DeleteDC();
}
}Now screen will be fully black. 3. Now make the inverted image part as transparent of your wish, just refer this article.([^]) I think your task is achieved
Величие не Бога может быть недооценена.
modified on Tuesday, October 20, 2009 12:02 AM
-
Hi, I am trying to work out how to darken the Windows Desktop and then display a rectangular portion of the desktop normally (not darkened). This is for a screen area capture program. You can see the precise effect I am after in Jing http://www.jingproject.com/[^]. I understand how to make a window transparent, but that's not what I'm after. Fading the background in a Web page is also commonly done. Any tips/pointers/C++ source much appreciated. Google has not helped so far.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
modified on Monday, October 19, 2009 10:33 PM
Neville Franks wrote:
I understand how to make a window transparent, but that's not what I'm after.
I think you can do this by creating one window in the excat size of the desktop. In the erase background function first fill the background of dialog with black color. After that bitblt the content of the desktop DC to the dialog( try the SRCPAINT flag in the bitblt ). Now after that paint the rectangle that you want to show without darkening using bitblt again( this time specify SRCCOPY in it ).
-
Hi, I am trying to work out how to darken the Windows Desktop and then display a rectangular portion of the desktop normally (not darkened). This is for a screen area capture program. You can see the precise effect I am after in Jing http://www.jingproject.com/[^]. I understand how to make a window transparent, but that's not what I'm after. Fading the background in a Web page is also commonly done. Any tips/pointers/C++ source much appreciated. Google has not helped so far.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
modified on Monday, October 19, 2009 10:33 PM
As the other replies said, the trick is to take a snapshot of the desktop, then put a window on top using that image. To make the area outside your selection be a bit darker, rather than black, I used GDI+: In the following, I've already attached a Graphics object to a HDC, pts is an array of PointF's, and nPoints is the size of that array. You could just make a rectangular exclude-from-shading area too, of course.
CRect rcClient; GetClientRect (&rcClient); Color clrBrush (128,0,0,0); SolidBrush brush (clrBrush); GraphicsPath path; path.AddPolygon (pts, nPoints); Region region (Rect (rcClient.left, rcClient.top, rcClient.Width (), rcClient.Height ())); region.Exclude (&path); gfx.FillRegion (&brush, ®ion);
This does the effect over the whole of a window - your window will probably be larger than mine, but the point remains. I hope that helps, Iain.
I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[^]
-
To do this, Firstly capture the desktop image. then do the following steps. 1. Draw the captured image. 2. Draw the invererted image of captured image over it. some vc++ code snippet to help you:-
void OnDraw( CDC* pDC_i )
{
if( 0 != m_NormalImage )
{
CDC MemDc;
MemDc.CreateCompatibleDC( pDC_i );
CImage *pOldImage = MemDc.SelectObject( m_NormalImage );
CRect rect;
GetClientRect( &rect );
rect.left = HEADER_OFFSET;
rect.right = max( rect.Width(), 300 ) + HEADER_OFFSET;
rect.top = HEADER_OFFSET;
rect.bottom = HEADER_OFFSET + HEADER_HEIGHT ;
COLORREF CurrentBkgd = pDC_i->SetBkColor( IMAGE_HEADER_BKGDCOLOR );
pDC_i->SetBkColor( CurrentBkgd );
pDC_i->BitBlt( 0, HEADER_OFFSET + HEADER_HEIGHT + HEADER_OFFSET , m_nWidth, HEADER_OFFSET + m_nHeight + HEADER_HEIGHT + HEADER_OFFSET,
&MemDc, 0, 0, SRCCOPY );
if( m_bInvertStatus && 0 != m_pInverseImage )
{
DrawInverseImage( pDC_i );} MemDc.SelectObject( pOldImage ); MemDc.DeleteDC(); }
}
void SetInvertImage( HBITMAP himageinverse_i)
{
m_pinverseImage = new CBitmap();
m_pinverseImage->Attach( himageinverse_i);
}void DrawInvertImage( CDC* pDC_i )
{
if( 0 !=m_pinverseImage )
{
CDC Memdc;
Memdc.CreateCompatibleDC( pDC_i );
CBitmap *pOldBitmap = dcMem.SelectObject(m_inverseImage );
pDC_i->BitBlt( 0, HEADER_OFFSET + HEADER_HEIGHT + HEADER_OFFSET, m_nWidth, HEADER_OFFSET + m_nHeight + HEADER_HEIGHT + HEADER_OFFSET,
&dcMem, 0, 0, SRCINVERT );
dcMem.SelectObject( pOldBitmap );
dcMem.DeleteDC();
}
}Now screen will be fully black. 3. Now make the inverted image part as transparent of your wish, just refer this article.([^]) I think your task is achieved
Величие не Бога может быть недооценена.
modified on Tuesday, October 20, 2009 12:02 AM
Thanks all. Capturing the desktop as an image and then altering that seems like the way forward. I've been researching GDI+ and the Effect Class, and I plan on trying the BrightnessContrast Class tomorrow. I'll draw the normal rectangle area using the original desktop image. And use a window layered over the top of the desktop. Sounds like a plan.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
-
Neville Franks wrote:
I understand how to make a window transparent, but that's not what I'm after.
I think you can do this by creating one window in the excat size of the desktop. In the erase background function first fill the background of dialog with black color. After that bitblt the content of the desktop DC to the dialog( try the SRCPAINT flag in the bitblt ). Now after that paint the rectangle that you want to show without darkening using bitblt again( this time specify SRCCOPY in it ).
Thanks, see my reply to ARJ 09 above.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
-
As the other replies said, the trick is to take a snapshot of the desktop, then put a window on top using that image. To make the area outside your selection be a bit darker, rather than black, I used GDI+: In the following, I've already attached a Graphics object to a HDC, pts is an array of PointF's, and nPoints is the size of that array. You could just make a rectangular exclude-from-shading area too, of course.
CRect rcClient; GetClientRect (&rcClient); Color clrBrush (128,0,0,0); SolidBrush brush (clrBrush); GraphicsPath path; path.AddPolygon (pts, nPoints); Region region (Rect (rcClient.left, rcClient.top, rcClient.Width (), rcClient.Height ())); region.Exclude (&path); gfx.FillRegion (&brush, ®ion);
This does the effect over the whole of a window - your window will probably be larger than mine, but the point remains. I hope that helps, Iain.
I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[^]
Thanks Iain, see my reply to ARJ 09 above.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com