Win32Splash.cxx

Go to the documentation of this file.
00001 // @(#)root/winnt:$Id: Win32Splash.cxx 35483 2010-09-20 19:23:57Z rdm $
00002 // Author: Bertrand Bellenot   30/07/02
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifdef WIN32
00013 #include "Windows4Root.h"
00014 #include "RVersion.h"
00015 #include "strlcpy.h"
00016 #include <stdlib.h>
00017 #include <stdio.h>
00018 #include <ocidl.h>
00019 #include <olectl.h>
00020 
00021 #define ID_SPLASHSCREEN      25
00022 
00023 static const char *gConception[] = {
00024    "Rene Brun",
00025    "Fons Rademakers",
00026    0
00027 };
00028 
00029 static const char *gLeadDevelopers[] = {
00030    "Rene Brun",
00031    "Philippe Canal",
00032    "Fons Rademakers",
00033    0
00034 };
00035 
00036 static const char *gRootDevelopers[] = {
00037    "Ilka Antcheva",
00038    "Maarten Ballintijn",
00039    "Bertrand Bellenot",
00040    "Olivier Couet",
00041    "Valery Fine",
00042    "Gerardo Ganis",
00043    "Eddy Offermann",
00044    "Valeriy Onuchin",
00045    0
00046 };
00047 
00048 static const char *gCintDevelopers[] = {
00049    "Masaharu Goto",
00050    0
00051 };
00052 
00053 static const char *gRootDocumentation[] = {
00054    "Ilka Antcheva",
00055    "Suzanne Panacek",
00056    0
00057 };
00058 
00059 static char **gContributors = 0;
00060 
00061 typedef struct tagImgInfo {
00062    IPicture *Ipic;
00063    SIZE sizeInHiMetric;
00064    SIZE sizeInPix;
00065    char *Path;
00066 } IMG_INFO;
00067 
00068 static IMG_INFO gImageInfo;
00069 
00070 ///////////////////////////////////////////////////////////////////////////////
00071 // Global Variables:
00072 static HINSTANCE    gInst; // Current instance
00073 static HWND         gSplashWnd = 0; // Splash screen
00074 static BOOL         gShow = FALSE;
00075 static DWORD        gDelayVal = 0;
00076 static HDC          gDCScreen = 0, gDCCredits = 0;
00077 static HBITMAP      gBmpScreen = 0, gBmpOldScreen = 0;
00078 static HBITMAP      gBmpCredits = 0, gBmpOldCredits = 0;
00079 static HRGN         gRgnScreen = 0;
00080 static int          gCreditsBmpWidth;
00081 static int          gCreditsBmpHeight;
00082 
00083 static bool         gStayUp        = true;
00084 static bool         gAbout         = false;
00085 static RECT         gCreditsRect   = { 15, 155, 305, 285 }; // clip rect in logo
00086 static unsigned int gCreditsWidth  = gCreditsRect.right - gCreditsRect.left; // credits pixmap size
00087 static unsigned int gCreditsHeight = gCreditsRect.bottom - gCreditsRect.top; // credits rect height
00088 
00089 static void ReadContributors()
00090 {
00091    // Read the file $ROOTSYS/README/CREDITS for the names of the
00092    // contributors.
00093 
00094    char buf[2048];
00095 #ifdef ROOTDOCDIR
00096    sprintf(buf, "%s/CREDITS", ROOTDOCDIR);
00097 #else
00098    sprintf(buf, "%s/README/CREDITS", getenv("ROOTSYS"));
00099 #endif
00100 
00101    gContributors = 0;
00102 
00103    FILE *f = fopen(buf, "r");
00104    if (!f) return;
00105 
00106    int cnt = 0;
00107    while (fgets(buf, sizeof(buf), f)) {
00108       if (!strncmp(buf, "N: ", 3)) {
00109          cnt++;
00110       }
00111    }
00112    gContributors = new char*[cnt+1];
00113 
00114    cnt = 0;
00115    rewind(f);
00116    while (fgets(buf, sizeof(buf), f)) {
00117       if (!strncmp(buf, "N: ", 3)) {
00118          int len = strlen(buf);
00119          buf[len-1] = 0;    // remove \n
00120          len -= 3;          // remove "N: "
00121          gContributors[cnt] = new char[len];
00122          strlcpy(gContributors[cnt], buf+3, len);
00123          cnt++;
00124       }
00125    }
00126    gContributors[cnt] = 0;
00127 
00128    fclose(f);
00129 }
00130 
00131 static void DrawVersion(HDC hDC)
00132 {
00133    // Draw version string.
00134    RECT drawRect;
00135    SIZE lpSize;
00136    char version[80];
00137    int  Height;
00138    sprintf(version, "Version %s", ROOT_RELEASE);
00139 
00140    Height = gImageInfo.sizeInPix.cy;
00141 
00142    GetTextExtentPoint32(hDC, version, strlen(version), &lpSize);
00143 
00144    drawRect.left = 15;
00145    drawRect.top = Height - 25;
00146    drawRect.right = 15 + lpSize.cx;
00147    drawRect.bottom = drawRect.top + lpSize.cy;
00148    DrawTextEx(hDC, version, strlen(version), &drawRect, DT_LEFT, 0);
00149 }
00150 
00151 static int DrawCreditItem(HDC hDC, const char *creditItem, const char **members,
00152                           int y, bool draw)
00153 {
00154    // Draw credit item.
00155 
00156    char credit[1024];
00157    SIZE lpSize1, lpSize2;
00158    RECT drawRect;
00159    TEXTMETRIC lptm;
00160    int i;
00161    int lineSpacing;
00162 
00163    GetTextMetrics(hDC, &lptm);
00164 
00165    lineSpacing = lptm.tmAscent + lptm.tmDescent;
00166 
00167    strcpy(credit, creditItem);
00168    for (i = 0; members && members[i]; i++) {
00169       if (i) strcat(credit, ", ");
00170       GetTextExtentPoint32(hDC, credit, strlen(credit), &lpSize1);
00171       GetTextExtentPoint32(hDC, members[i], strlen(members[i]), &lpSize2);
00172       if((lpSize1.cx + lpSize2.cx) > (int) gCreditsWidth) {
00173          drawRect.left = 0;
00174          drawRect.top = y;
00175          drawRect.right = gCreditsRect.right;
00176          drawRect.bottom = y + lineSpacing;
00177          if (draw)
00178             DrawTextEx(hDC, credit, strlen(credit), &drawRect, DT_LEFT, 0);
00179          y += lineSpacing;
00180          strcpy(credit, "   ");
00181       }
00182       strcat(credit, members[i]);
00183    }
00184    drawRect.left = 0;
00185    drawRect.top = y;
00186    drawRect.right = gCreditsRect.right;
00187    drawRect.bottom = y + lineSpacing;
00188    if (draw)
00189       DrawTextEx(hDC, credit, strlen(credit), &drawRect, DT_LEFT, 0);
00190 
00191    return y;
00192 }
00193 
00194 static int DrawCredits(HDC hDC, bool draw, bool extended)
00195 {
00196    // Draw credits. If draw is true draw credits,
00197    // otherwise just return size of all credit text.
00198    // If extended is true draw or returns size for extended full
00199    // credits list.
00200 
00201    char user_name[256];
00202    TEXTMETRIC lptm;
00203    DWORD length = sizeof (user_name);
00204    int lineSpacing, y;
00205 
00206    GetTextMetrics(hDC, &lptm);
00207 
00208    lineSpacing = lptm.tmAscent + lptm.tmDescent;
00209    y = 0; // 140
00210    y = DrawCreditItem(hDC, "Conception: ", gConception, y, draw);
00211    y += 2 * lineSpacing - 3;
00212    y = DrawCreditItem(hDC, "Lead Developers: ", gLeadDevelopers, y, draw);
00213    y += 2 * lineSpacing - 3;  // special layout tweak
00214    y = DrawCreditItem(hDC, "Core Engineering: ", gRootDevelopers, y, draw);
00215    y += 2 * lineSpacing - 3;  // to just not cut the bottom of the "p"
00216    y = DrawCreditItem(hDC, "CINT C/C++ Intepreter: ", gCintDevelopers, y, draw);
00217    y += 2 * lineSpacing - 3;
00218    y = DrawCreditItem(hDC, "Documentation: ", gRootDocumentation, y, draw);
00219 
00220    if (extended && gContributors) {
00221       y += 2 * lineSpacing;
00222       y = DrawCreditItem(hDC, "Contributors: ", (const char **)gContributors, y, draw);
00223 
00224       y += 2 * lineSpacing;
00225       y = DrawCreditItem(hDC, "Our sincere thanks and apologies to anyone who deserves", 0, y, draw);
00226       y += lineSpacing;
00227       y = DrawCreditItem(hDC, "credit but fails to appear in this list.", 0, y, draw);
00228 
00229       if (GetUserName (user_name, &length)) {
00230          char *name = new char [strlen(user_name)+1];
00231          strcpy(name, user_name);
00232          char *s = strchr(name, ',');
00233          if (s) *s = 0;
00234          char line[1024];
00235          sprintf(line, "Extra special thanks go to %s,", name);
00236          delete [] name;
00237          y += 2 * lineSpacing;
00238          y = DrawCreditItem(hDC, line, 0, y, draw);
00239          y += lineSpacing;
00240          y = DrawCreditItem(hDC, "one of our favorite users.", 0, y, draw);
00241       }
00242    }
00243    return y;
00244 }
00245 
00246 void CreateCredits(HDC hDC, bool extended)
00247 {
00248    HFONT   hFont, hOldFont;
00249    HBRUSH  hBr;
00250    LOGFONT lf;
00251    RECT    fillRect;
00252 
00253    gRgnScreen = CreateRectRgnIndirect(&gCreditsRect);
00254    SelectClipRgn(hDC, gRgnScreen);
00255 
00256    gDCScreen = CreateCompatibleDC(hDC);
00257    gBmpScreen = CreateCompatibleBitmap(hDC, (gCreditsRect.right - gCreditsRect.left),
00258                                       (gCreditsRect.bottom - gCreditsRect.top) );
00259    gBmpOldScreen = (HBITMAP)SelectObject(gDCScreen, gBmpScreen);
00260 
00261    gDCCredits = CreateCompatibleDC(hDC);
00262 
00263    gCreditsBmpWidth = (gCreditsRect.right - gCreditsRect.left);
00264    gCreditsBmpHeight = DrawCredits(gDCCredits, false, extended);
00265 
00266    gBmpCredits = CreateCompatibleBitmap(gDCCredits, gCreditsBmpWidth, gCreditsBmpHeight);
00267    gBmpOldCredits = (HBITMAP)SelectObject(gDCCredits, gBmpCredits);
00268 
00269    hBr = CreateSolidBrush(RGB(255,255,255));
00270    fillRect.top = fillRect.left = 0;
00271    fillRect.bottom = gCreditsBmpHeight;
00272    fillRect.right = gCreditsBmpWidth;
00273    FillRect(gDCCredits, &fillRect, hBr);
00274 
00275    memset((void*)&lf, 0, sizeof(lf));
00276    lf.lfHeight = 14;
00277    lf.lfWeight = 400;
00278    lf.lfQuality = NONANTIALIASED_QUALITY;
00279    strcpy(lf.lfFaceName, "Arial");
00280    hFont = CreateFontIndirect(&lf);
00281 
00282    if(hFont)
00283       hOldFont = (HFONT)SelectObject(gDCCredits, hFont);
00284 
00285    SetBkMode(gDCCredits, TRANSPARENT);
00286    SetTextColor(gDCCredits, 0x00000000);
00287 
00288    DrawCredits(gDCCredits, true, extended);
00289 
00290    SetBkColor(gDCCredits, 0x00FFFFFF);
00291    SelectObject(gDCCredits, hOldFont);
00292 }
00293 
00294 void ScrollCredits(BOOL extended)
00295 {
00296    // Track scroll position
00297 
00298    static int nScrollY = 0;
00299 
00300    if (!gShow)
00301       return;
00302    if (!IsWindow(gSplashWnd))
00303       return;
00304    HDC hDC = GetDC(gSplashWnd);
00305 
00306    if(gDCCredits == 0) {
00307       CreateCredits(hDC, extended);
00308       nScrollY = 0;
00309    }
00310 
00311    BitBlt(gDCScreen, 0, 0, gCreditsBmpWidth, gCreditsBmpHeight, gDCCredits,
00312           0, nScrollY, SRCCOPY);
00313    BitBlt(hDC, gCreditsRect.left, gCreditsRect.top,
00314           (gCreditsRect.right - gCreditsRect.left),
00315           (gCreditsRect.bottom - gCreditsRect.top),
00316           gDCScreen, 0, 0, SRCCOPY);
00317 
00318    GdiFlush();
00319 
00320    if (extended) {
00321       // delay scrolling by the specified time
00322       Sleep(100);
00323 
00324       if (nScrollY == 0)
00325          Sleep(2000);
00326 
00327       // continue scrolling
00328       nScrollY += 1;
00329       if (nScrollY > (int) (gCreditsBmpHeight - 2*gCreditsHeight))
00330          nScrollY = -int(gCreditsHeight);
00331    }
00332 }
00333 
00334 ///////////////////////////////////////////////////////////////////////////////
00335 // Foward declarations of functions included in this code module:
00336 ATOM                MyRegisterClass(HINSTANCE hInstance);
00337 LRESULT CALLBACK    SplashWndProc(HWND, UINT, WPARAM, LPARAM);
00338 
00339 
00340 void *OpenGraphic(char *name)
00341 {
00342    IPicture *Ipic = 0;
00343    SIZE sizeInHiMetric,sizeInPix;
00344    const int HIMETRIC_PER_INCH = 2540;
00345    HDC hDCScreen = GetDC(0);
00346    HRESULT hr;
00347    int nPixelsPerInchX = GetDeviceCaps(hDCScreen, LOGPIXELSX);
00348    int nPixelsPerInchY = GetDeviceCaps(hDCScreen, LOGPIXELSY);
00349    wchar_t OlePathName[512];
00350 
00351    ReleaseDC(0, hDCScreen);
00352    mbstowcs(OlePathName,name,strlen(name)+1);
00353    hr = OleLoadPicturePath(OlePathName, 0, 0, 0, IID_IPicture,
00354                            (void **)(&Ipic));
00355    if (hr)
00356       return 0;
00357    if (Ipic) {
00358       // get width and height of picture
00359       hr = Ipic->get_Width(&sizeInHiMetric.cx);
00360       if (!SUCCEEDED(hr))
00361          goto err;
00362       Ipic->get_Height(&sizeInHiMetric.cy);
00363       if (!SUCCEEDED(hr))
00364          goto err;
00365 
00366       // convert himetric to pixels
00367       sizeInPix.cx = (nPixelsPerInchX * sizeInHiMetric.cx +
00368                       HIMETRIC_PER_INCH / 2) / HIMETRIC_PER_INCH;
00369       sizeInPix.cy = (nPixelsPerInchY * sizeInHiMetric.cy +
00370                       HIMETRIC_PER_INCH / 2) / HIMETRIC_PER_INCH;
00371       gImageInfo.sizeInPix = sizeInPix;
00372       gImageInfo.sizeInHiMetric = sizeInHiMetric;
00373       gImageInfo.Ipic = Ipic;
00374       gImageInfo.Path = name;
00375       return Ipic;
00376    }
00377 err:
00378    return 0;
00379 }
00380 
00381 void DisplayGraphic(HWND hwnd,HDC pDC)
00382 {
00383    IPicture *Ipic = gImageInfo.Ipic;
00384    DWORD dwAttr = 0;
00385    HBITMAP Bmp,BmpOld;
00386    RECT rc;
00387    HRESULT hr;
00388    HPALETTE pPalMemOld;
00389 
00390    if (Ipic != 0) {
00391       // get palette
00392       OLE_HANDLE hPal = 0;
00393       HPALETTE hPalOld=0, hPalMemOld=0;
00394       hr = Ipic->get_hPal(&hPal);
00395 
00396       if (!SUCCEEDED(hr))
00397          return;
00398       if (hPal != 0) {
00399          hPalOld = SelectPalette(pDC,(HPALETTE)hPal,FALSE);
00400          RealizePalette(pDC);
00401       }
00402 
00403       // Fit the image to the size of the client area. Change this
00404       // For more sophisticated scaling
00405       GetClientRect(hwnd,&rc);
00406       // transparent?
00407       if (SUCCEEDED(Ipic->get_Attributes(&dwAttr)) ||
00408           (dwAttr & PICTURE_TRANSPARENT)) {
00409          // use an off-screen DC to prevent flickering
00410          HDC MemDC = CreateCompatibleDC(pDC);
00411          Bmp = CreateCompatibleBitmap(pDC,gImageInfo.sizeInPix.cx,gImageInfo.sizeInPix.cy);
00412 
00413          BmpOld = (HBITMAP)SelectObject(MemDC,Bmp);
00414          pPalMemOld = 0;
00415          if (hPal != 0) {
00416             hPalMemOld = SelectPalette(MemDC,(HPALETTE)hPal, FALSE);
00417             RealizePalette(MemDC);
00418          }
00419 
00420          // display picture using IPicture::Render
00421          hr = Ipic->Render(MemDC, 0, 0, rc.right, rc.bottom, 0,
00422                            gImageInfo.sizeInHiMetric.cy,
00423                            gImageInfo.sizeInHiMetric.cx,
00424                            -gImageInfo.sizeInHiMetric.cy, &rc);
00425 
00426          BitBlt(pDC,0, 0, gImageInfo.sizeInPix.cx, gImageInfo.sizeInPix.cy,
00427                 MemDC, 0, 0, SRCCOPY);
00428 
00429          SelectObject(MemDC,BmpOld);
00430 
00431          if (pPalMemOld)
00432             SelectPalette(MemDC,pPalMemOld, FALSE);
00433          DeleteObject(Bmp);
00434          DeleteDC(MemDC);
00435 
00436       }
00437       else {
00438          // display picture using IPicture::Render
00439          Ipic->Render(pDC, 0, 0, rc.right, rc.bottom, 0,
00440                       gImageInfo.sizeInHiMetric.cy,
00441                       gImageInfo.sizeInHiMetric.cx,
00442                       -gImageInfo.sizeInHiMetric.cy, &rc);
00443       }
00444 
00445       if (hPalOld != 0)
00446          SelectPalette(pDC,hPalOld, FALSE);
00447       if (hPal)
00448          DeleteObject((HPALETTE)hPal);
00449    }
00450 }
00451 
00452 void CloseImage(void *Ipict)
00453 {
00454    IPicture *ip = (IPicture *)Ipict;
00455 
00456    if (ip == 0)
00457       ip = gImageInfo.Ipic;
00458    if (ip == 0)
00459       return;
00460    ip->Release();
00461    memset(&gImageInfo,0,sizeof(gImageInfo));
00462 }
00463 
00464 ////////////////////////////////////////////////////////////////////////////////
00465 // Splashscreen functions
00466 ////////////////////////////////////////////////////////////////////////////////
00467 //
00468 //
00469 void DestroySplashScreen()
00470 {
00471    // Destroy the window
00472    if (IsWindow(gSplashWnd)) {
00473       DestroyWindow(gSplashWnd);
00474       gSplashWnd = 0;
00475       UnregisterClass("RootSplashScreen", gInst);
00476    }
00477    if(gDCScreen != 0 && gBmpOldScreen != 0) {
00478       SelectObject(gDCScreen, gBmpOldScreen);
00479       DeleteObject(gBmpScreen);
00480    }
00481    if(gDCCredits != 0 && gBmpOldCredits != 0) {
00482       SelectObject(gDCCredits, gBmpOldCredits);
00483       DeleteObject(gBmpCredits);
00484    }
00485    DeleteDC(gDCCredits);
00486    gDCCredits = 0;
00487    DeleteDC(gDCScreen);
00488    gDCScreen = 0;
00489    CloseImage(gImageInfo.Ipic);
00490 }
00491 
00492 ////////////////////////////////////////////////////////////////////////////////
00493 //
00494 //
00495 BOOL CreateSplashScreen(HWND hParent)
00496 {
00497    int xScreen;
00498    int yScreen;
00499    // Crenter the splashscreen
00500    xScreen = GetSystemMetrics(SM_CXFULLSCREEN);
00501    yScreen = GetSystemMetrics(SM_CYFULLSCREEN);
00502 
00503    gStayUp = true;
00504 
00505    gSplashWnd = CreateWindowEx(
00506             WS_EX_TOOLWINDOW,
00507             "RootSplashScreen",
00508             0,
00509             WS_POPUP | WS_VISIBLE,
00510             (xScreen - 360)/2,
00511             (yScreen - 240)/2,
00512             360, 240,
00513             hParent,
00514             0,
00515             gInst,
00516             0);
00517 
00518    return (gSplashWnd != 0);
00519 }
00520 
00521 
00522 ////////////////////////////////////////////////////////////////////////////////
00523 //
00524 //
00525 BOOL PreTranslateMessage(MSG* pMsg)
00526 {
00527    if (!IsWindow(gSplashWnd))
00528       return FALSE;
00529 
00530    // If we get a keyboard or mouse message, hide the splash screen.
00531    if (pMsg->message == WM_KEYDOWN ||
00532        pMsg->message == WM_SYSKEYDOWN ||
00533        pMsg->message == WM_LBUTTONDOWN ||
00534        pMsg->message == WM_RBUTTONDOWN ||
00535        pMsg->message == WM_MBUTTONDOWN ||
00536        pMsg->message == WM_NCLBUTTONDOWN ||
00537        pMsg->message == WM_NCRBUTTONDOWN ||
00538        pMsg->message == WM_NCMBUTTONDOWN) {
00539       DestroySplashScreen();
00540       return TRUE;    // message handled here
00541    }
00542    return FALSE;   // message not handled
00543 }
00544 
00545 void CreateSplash(DWORD time, BOOL extended)
00546 {
00547    MSG msg;
00548    MyRegisterClass(gInst);
00549    gShow = FALSE;
00550    if(extended)
00551       gAbout = true;
00552    if(time > 0) {
00553       gDelayVal = time * 1000;
00554    }
00555    else return;
00556 
00557    if (extended)
00558       ReadContributors();
00559 
00560    // Create the splash screen
00561    CreateSplashScreen(0);
00562 
00563    // Main message loop:
00564    while (gStayUp) {
00565       if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
00566          PreTranslateMessage(&msg);
00567          TranslateMessage(&msg);
00568          DispatchMessage(&msg);
00569       }
00570       if(gShow) {
00571          if(extended) {
00572             ScrollCredits(extended);
00573          }
00574          else {
00575             ScrollCredits(extended);
00576             gShow = false;
00577          }
00578       }
00579    }
00580 
00581    DestroySplashScreen();
00582 }
00583 
00584 ///////////////////////////////////////////////////////////////////////////////
00585 //
00586 //  FUNCTION: MyRegisterClass()
00587 //
00588 //  PURPOSE: Registers the window class.
00589 //
00590 //  COMMENTS:
00591 //
00592 //    This function and its usage is only necessary if you want this code
00593 //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
00594 //    function that was added to Windows 95. It is important to call this function
00595 //    so that the application will get 'well formed' small icons associated
00596 //    with it.
00597 //
00598 ATOM MyRegisterClass(HINSTANCE hInstance)
00599 {
00600    WNDCLASSEX wcex;
00601 
00602    wcex.cbSize = sizeof(WNDCLASSEX);
00603 
00604    wcex.style          = CS_HREDRAW | CS_VREDRAW;
00605    wcex.lpfnWndProc    = (WNDPROC)SplashWndProc;
00606    wcex.cbClsExtra     = 0;
00607    wcex.cbWndExtra     = 0;
00608    wcex.hInstance      = hInstance;
00609    wcex.hIcon          = 0;
00610    wcex.hCursor        = LoadCursor(0, IDC_ARROW);
00611    wcex.hbrBackground  = 0;
00612    wcex.lpszMenuName   = 0;
00613    wcex.lpszClassName  = "RootSplashScreen";
00614    wcex.hIconSm        = 0;
00615    return RegisterClassEx(&wcex);
00616 }
00617 
00618 
00619 
00620 ////////////////////////////////////////////////////////////////////////////
00621 // Message handler for splash screen.
00622 //
00623 LRESULT CALLBACK SplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00624 {
00625    PAINTSTRUCT ps;
00626    HDC hDC;
00627    LOGFONT lf;
00628    static HFONT hFont;
00629    const char bmpDir[] = "\\icons\\Splash.gif";
00630    HWND hwndFound;         // this is what is returned to the caller
00631    char pszNewWindowTitle[1024]; // contains fabricated WindowTitle
00632    char pszOldWindowTitle[1024]; // contains original WindowTitle
00633    char FullBmpDir[256];
00634    char *RootSysDir;
00635    int xScreen;
00636    int yScreen;
00637 
00638    switch (message) {
00639       case WM_CREATE:
00640          if(!gAbout)
00641             SetTimer(hWnd, ID_SPLASHSCREEN, gDelayVal, 0);
00642          RootSysDir = getenv("ROOTSYS");
00643          sprintf(FullBmpDir,"%s%s",RootSysDir,bmpDir);
00644          // Retrieve a handle identifying the file.
00645          OpenGraphic(FullBmpDir);
00646          hDC = GetDC(hWnd);
00647          DisplayGraphic(hWnd, hDC);
00648          SetBkMode(hDC, TRANSPARENT);
00649          memset((void*)&lf, 0, sizeof(lf));
00650          lf.lfHeight = 14;
00651          lf.lfWeight = 400;
00652          lf.lfQuality = NONANTIALIASED_QUALITY;
00653          strcpy(lf.lfFaceName, "Arial");
00654          hFont = CreateFontIndirect(&lf);
00655          xScreen = GetSystemMetrics(SM_CXFULLSCREEN);
00656          yScreen = GetSystemMetrics(SM_CYFULLSCREEN);
00657          SetWindowPos(hWnd, HWND_TOPMOST, (xScreen - gImageInfo.sizeInPix.cx)/2,
00658                       (yScreen - gImageInfo.sizeInPix.cy)/2, gImageInfo.sizeInPix.cx,
00659                       gImageInfo.sizeInPix.cy, 0 );
00660          break;
00661 
00662       case WM_TIMER:
00663          if (wParam == ID_SPLASHSCREEN) {
00664             KillTimer (hWnd, ID_SPLASHSCREEN);
00665             DestroySplashScreen();
00666          }
00667          break;
00668 
00669       case WM_DESTROY:
00670          gStayUp = false;
00671          PostQuitMessage(0);
00672 
00673       case WM_PAINT:
00674          hDC = BeginPaint(hWnd, &ps);
00675          RECT rt;
00676          GetClientRect(hWnd, &rt);
00677          RootSysDir = getenv("ROOTSYS");
00678          sprintf(FullBmpDir,"%s%s",RootSysDir,bmpDir);
00679          OpenGraphic(FullBmpDir);
00680          hDC = GetDC(hWnd);
00681          DisplayGraphic(hWnd, hDC);
00682          SetBkMode(hDC, TRANSPARENT);
00683          if(hFont)
00684             SelectObject(hDC, hFont);
00685          DrawVersion(hDC);
00686          EndPaint(hWnd, &ps);
00687          gShow = TRUE;
00688          // fetch current window title
00689          GetConsoleTitle(pszOldWindowTitle, 1024);
00690          // format a "unique" NewWindowTitle
00691          wsprintf(pszNewWindowTitle,"%d/%d", GetTickCount(), GetCurrentProcessId());
00692          // change current window title
00693          SetConsoleTitle(pszNewWindowTitle);
00694          // ensure window title has been updated
00695          Sleep(40);
00696          // look for NewWindowTitle
00697          hwndFound=FindWindow(NULL, pszNewWindowTitle);
00698          // restore original window title
00699          ShowWindow(hwndFound, SW_RESTORE);
00700          SetForegroundWindow(hwndFound);
00701          SetConsoleTitle("ROOT session");
00702          break;
00703 
00704       default:
00705          return DefWindowProc(hWnd, message, wParam, lParam);
00706    }
00707    return 0;
00708 }
00709 #endif

Generated on Tue Jul 5 14:12:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1