Article View: borland.public.cppbuilder.nativeapi
Article #3992Re: Creating / mimicing the XP shutdown grey fade...
From: JD
Date: Thu, 30 Mar 2006 10:13
Date: Thu, 30 Mar 2006 10:13
59 lines
3060 bytes
3060 bytes
"Mike Collins" <its@TheBottomOfThePost.com> wrote:
>
> [...] When this happens, it appear as if the screen fades
> out so a semi-transparent grey colour.
>
> So I need to mimic the same behaviour in my application.
The final presentation of the screen is a simple gray-scale
which is quite easy to mimic:
//-------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap *Bmp = new Graphics::TBitmap;
Bmp->Width = Width;
Bmp->Height = Height;
Bmp->PixelFormat = pf24bit;
HDC hDC = ::GetWindowDC( Handle );
::BitBlt( Bmp->Canvas->Handle, 0, 0, Width, Height, hDC, 0, 0, SRCCOPY );
for( int y = 0; y < Height; ++y )
{
BYTE* ScanLine = static_cast<BYTE*>( Bmp->ScanLine[y] );
for( int x = 0; x < Width; ++x )
{
BYTE R = ScanLine[ x * 3 + 0 ];
BYTE G = ScanLine[ x * 3 + 1 ];
BYTE B = ScanLine[ x * 3 + 2 ];
BYTE L = (BYTE)((R * 0.299) + (G * 0.587) + (B * 0.114));
ScanLine[ x * 3 + 0 ] = L;
ScanLine[ x * 3 + 1 ] = L;
ScanLine[ x * 3 + 2 ] = L;
}
}
::BitBlt( hDC, 0, 0, Width, Height, Bmp->Canvas->Handle, 0, 0, SRCCOPY );
::ReleaseDC( Handle, hDC );
delete Bmp;
}
//-------------------------------------------------------------
However, XP also scales the colors gradually in a loop that's
executes (IIRC) 7 times until it gets to the gray-scale so
it's approach is quite different than the above. I'm not the
graphic's guru but I think that we used a method known as
Gamma Correction to animate the fading.
Of course, the above is an incomplete solution because it
doesn't account for when Windows causes a repaint like
when the window is disabled or looses focus or it's size or
position changes or when part of it is uncovered by another
window.
These conditions can be accounted for by BitBlt(ing) the image
when you detect WM_PAINT or WM_NCPAINT but only if the dialog
is opened.
~ JD
Technical Details
Message-ID:
<442bbd3f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<442b1df3$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ff65259e4dac42c3 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: Creating / mimicing the XP shutdown grey fade... Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 64.12.116.201 X-Forwarded-For: 172.169.106.133 References: <442b1df3$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <442bbd3f$1@newsgroups.borland.com> Date: 30 Mar 2006 03:13:03 -0700 X-Trace: newsgroups.borland.com 1143717183 207.105.83.66 (30 Mar 2006 03:13:03 -0700) Lines: 60 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail