Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

DlgSplash.cpp

Go to the documentation of this file.
00001 //
00002 // DlgSplash.cpp
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "ImageServices.h"
00025 #include "DlgSplash.h"
00026 #include "FragmentBar.h"
00027 
00028 IMPLEMENT_DYNAMIC(CSplashDlg, CDialog)
00029 
00030 BEGIN_MESSAGE_MAP(CSplashDlg, CDialog)
00031         ON_WM_PAINT()
00032         ON_MESSAGE(WM_PRINTCLIENT, OnPrintClient)
00033 END_MESSAGE_MAP()
00034 
00035 #ifndef WS_EX_LAYERED
00036 #define WS_EX_LAYERED           0x80000
00037 #define LWA_ALPHA                       0x02
00038 #endif
00039 #define AW_BLEND                        0x00080000
00040 #define AW_HIDE                         0x00010000
00041 
00042 #define SPLASH_WIDTH            528
00043 #define SPLASH_HEIGHT           236
00044 
00045 
00047 // CSplashDlg construction
00048 
00049 CSplashDlg::CSplashDlg(int nMax, BOOL bSilent) : CDialog( CSplashDlg::IDD, NULL )
00050 {
00051         m_nPos          = 0;
00052         m_nMax          = nMax;
00053 
00054         m_bSilent       = bSilent;
00055         m_sState        = _T("Version ") + theApp.m_sVersion + _T("...");
00056 
00057         m_hUser32                       = NULL;
00058         m_pfnAnimateWindow      = NULL;
00059 
00060 #ifdef _DEBUG
00061         // m_bSilent = TRUE;
00062 #endif
00063 
00064         Create( IDD );
00065 }
00066 
00067 CSplashDlg::~CSplashDlg()
00068 {
00069         if ( m_hUser32 != NULL ) FreeLibrary( m_hUser32 );
00070 }
00071 
00072 void CSplashDlg::DoDataExchange(CDataExchange* pDX)
00073 {
00074         CDialog::DoDataExchange(pDX);
00075 }
00076 
00078 // CSplashDlg message handlers
00079 
00080 BOOL CSplashDlg::OnInitDialog()
00081 {
00082         CDialog::OnInitDialog();
00083 
00084         CClientDC dcScreen( this );
00085 
00086         CImageServices::LoadBitmap( &m_bmSplash, IDR_SPLASH, RT_PNG );
00087 
00088         m_bmBuffer.CreateCompatibleBitmap( &dcScreen, SPLASH_WIDTH, SPLASH_HEIGHT );
00089         m_dcBuffer1.CreateCompatibleDC( &dcScreen );
00090         m_dcBuffer2.CreateCompatibleDC( &dcScreen );
00091 
00092         if ( m_bSilent ) return TRUE;
00093 
00094         SetWindowPos( NULL, 0, 0, SPLASH_WIDTH, SPLASH_HEIGHT, SWP_NOMOVE );
00095         CenterWindow();
00096 
00097         if ( theApp.m_bNT && ( m_hUser32 = LoadLibrary( _T("User32.dll") ) ) )
00098         {
00099                 (FARPROC&)m_pfnAnimateWindow = GetProcAddress( m_hUser32, "AnimateWindow" );
00100 
00101                 if ( m_pfnAnimateWindow != NULL )
00102                 {
00103                         (*m_pfnAnimateWindow)( GetSafeHwnd(), 250, AW_BLEND );
00104                 }
00105         }
00106 
00107         SetWindowPos( &wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW );
00108         UpdateWindow();
00109 
00110         return TRUE;
00111 }
00112 
00113 void CSplashDlg::Step(LPCTSTR pszText)
00114 {
00115         m_nPos ++;
00116         m_sState.Format( _T("Starting %s..."), pszText );
00117 
00118         CClientDC dc( this );
00119         DoPaint( &dc );
00120 }
00121 
00122 void CSplashDlg::Topmost()
00123 {
00124         if ( IsWindowVisible() )
00125         {
00126                 SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW );
00127         }
00128 }
00129 
00130 void CSplashDlg::Hide()
00131 {
00132         m_sState = _T("Ready");
00133         Invalidate();
00134 
00135         if ( m_pfnAnimateWindow != NULL )
00136         {
00137                 (*m_pfnAnimateWindow)( GetSafeHwnd(), 250, AW_HIDE|AW_BLEND );
00138         }
00139 
00140         DestroyWindow();
00141         delete this;
00142 }
00143 
00144 LONG CSplashDlg::OnPrintClient(WPARAM wParam, LPARAM lParam)
00145 {
00146         LONG lResult = Default();
00147 
00148         CDC* pDC = CDC::FromHandle( (HDC)wParam );
00149         DoPaint( pDC );
00150 
00151         return lResult;
00152 }
00153 
00154 void CSplashDlg::OnPaint()
00155 {
00156         CPaintDC dc( this );
00157         DoPaint( &dc );
00158 }
00159 
00160 void CSplashDlg::DoPaint(CDC* pDC)
00161 {
00162         CBitmap* pOld1 = (CBitmap*)m_dcBuffer1.SelectObject( &m_bmSplash );
00163         CBitmap* pOld2 = (CBitmap*)m_dcBuffer2.SelectObject( &m_bmBuffer );
00164 
00165         m_dcBuffer2.BitBlt( 0, 0, SPLASH_WIDTH, SPLASH_HEIGHT, &m_dcBuffer1, 0, 0, SRCCOPY );
00166 
00167         CFont* pOld3 = (CFont*)m_dcBuffer2.SelectObject( &theApp.m_gdiFontBold );
00168         m_dcBuffer2.SetBkMode( TRANSPARENT );
00169         m_dcBuffer2.SetTextColor( RGB( 0, 0, 0 ) );
00170 
00171         CRect rc( 8, 201, 520, SPLASH_HEIGHT );
00172         UINT nFormat = DT_LEFT|DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX;
00173 
00174         rc.OffsetRect( -1, 0 );
00175         m_dcBuffer2.DrawText( m_sState, &rc, nFormat );
00176         rc.OffsetRect( 2, 0 );
00177         m_dcBuffer2.DrawText( m_sState, &rc, nFormat );
00178         rc.OffsetRect( -1, -1 );
00179         m_dcBuffer2.DrawText( m_sState, &rc, nFormat );
00180         rc.OffsetRect( 0, 2 );
00181         m_dcBuffer2.DrawText( m_sState, &rc, nFormat );
00182         rc.OffsetRect( 0, -1 );
00183 
00184         m_dcBuffer2.SetTextColor( RGB( 255, 255, 255 ) );
00185         m_dcBuffer2.DrawText( m_sState, &rc, nFormat );
00186 
00187         m_dcBuffer2.SelectObject( pOld3 );
00188 
00189         rc.SetRect( 440, 223, 522, 231 );
00190         m_dcBuffer2.Draw3dRect( &rc, RGB( 0x40, 0x40, 0x40 ), RGB( 0x40, 0x40, 0x40 ) );
00191         rc.DeflateRect( 1, 1 );
00192         m_dcBuffer2.FillSolidRect( &rc, RGB( 0x25, 0x25, 0x25 ) );
00193 
00194         int nOffset;
00195         if ( theApp.m_bRTL )
00196                 nOffset = m_nMax - min( m_nPos, m_nMax );
00197         else
00198                 nOffset = 0;
00199 
00200         CFragmentBar::DrawFragment( &m_dcBuffer2, &rc, m_nMax, nOffset, min( m_nPos, m_nMax ),
00201                 RGB( 0x20, 0xB0, 0x20 ), TRUE );
00202         m_dcBuffer2.SelectClipRgn( NULL );
00203 
00204         pDC->BitBlt( 0, 0, SPLASH_WIDTH, SPLASH_HEIGHT, &m_dcBuffer2, 0, 0, SRCCOPY );
00205 
00206         m_dcBuffer2.SelectObject( pOld2 );
00207         m_dcBuffer1.SelectObject( pOld1 );
00208 }

Generated on Thu Dec 15 10:39:40 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2