SPLASH.C

Go to the documentation of this file.
00001 /* splash.c     Opening Splash Screen */
00002 
00003 #include <stdlib.h>
00004 #include <stdio.h>
00005 #include <windows.h>
00006 #include <commctrl.h>
00007 
00008 #define X__Malloc(s)    LocalAlloc(LMEM_FIXED,s)
00009 #define X__Free(p)      LocalFree((HLOCAL)p)
00010 
00011 #if __ZTC__ || __SC__
00012 #ifndef max
00013 #define max(a,b)  ( ((a) > (b)) ? (a) : (b) )
00014 #endif
00015 #endif
00016 
00017 #if __X__MIPS__
00018 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00019 #endif
00020 
00021 static char IniFilename[256],
00022             IniSection[]  = "LOGON";
00023 static HINSTANCE hDLLinstance=NULL;
00024 static BITMAP    Bitmap;
00025 static HBITMAP   hBitmap=NULL;
00026 static BOOL      showanim=TRUE;
00027 static HCURSOR   ghcurHand=NULL;
00028 #include "splash.h"
00029 
00030 #if __WATCOMC__
00031 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00032 #else
00033 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00034 #endif
00035   HANDLE ghMod;
00036   switch (dwReason) {
00037     case DLL_PROCESS_ATTACH:
00038 #if __X__MIPS__
00039       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00040 #endif
00041       hDLLinstance = hDLL;  /* handle to DLL file */
00042       break;
00043     case DLL_PROCESS_DETACH:
00044 #if __X__MIPS__
00045       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00046 #endif
00047       break;
00048   }
00049   return (int)TRUE;
00050 }
00051 
00052 #if __SC__
00053 #pragma startaddress(DllMain)
00054 #endif
00055 
00056 static char WIN32_environment[512];
00057 
00058 char *R_GetEnv(char const *aa){
00059  if(GetEnvironmentVariable((LPTSTR)aa,(LPTSTR)WIN32_environment,256) == 0)
00060    return NULL;
00061  return WIN32_environment;
00062 }
00063 
00064 static void CentreDialogOnScreen(HWND hwnd){
00065  RECT rcDlg;
00066  long Xres,Yres;
00067  Yres=GetSystemMetrics(SM_CYSCREEN);
00068  Xres=GetSystemMetrics(SM_CXSCREEN);
00069  GetWindowRect(hwnd,&rcDlg);
00070  OffsetRect(&rcDlg,-rcDlg.left,-rcDlg.top);
00071  OffsetRect(&rcDlg,(Xres-rcDlg.right)/2,(Yres-rcDlg.bottom)/2);
00072  SetWindowPos(hwnd,HWND_TOP,rcDlg.left,rcDlg.top,0,0,SWP_NOSIZE);
00073  return;
00074 }
00075 
00076 PSTR FileInPath(PSTR pstrPath){
00077  PSTR pstr;
00078  pstr = pstrPath + strlen(pstrPath);
00079  while (pstr > pstrPath) {
00080      pstr = (AnsiPrev(pstrPath, pstr));
00081      if (*pstr == '\\' || *pstr == ':' || *pstr == '/') {
00082          pstr = (AnsiNext(pstr));
00083          break;
00084      }
00085  }
00086  return pstr;
00087 }
00088 
00089 static int CALLBACK LogonDlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00090 
00091 int _PrgmLogon(HWND hwnd,int no_wait){
00092  int retval;
00093  // Get the INI file to use and working folder for temporary files
00094  {
00095   FILE *fini=NULL; int ix;
00096   char TempPath[256];
00097   GetModuleFileName(hDLLinstance,IniFilename,256);
00098   *FileInPath(IniFilename) = '\0';
00099   strcpy(TempPath,IniFilename);
00100   strcat(IniFilename,"OPENFX_.CFG");
00101   if((fini=fopen(IniFilename,"r")) != NULL){
00102     fscanf(fini,"%ld",&ix);
00103     strcpy(TempPath,"X");
00104     fscanf(fini," %[^\n]",TempPath);
00105     if(ix > 1){
00106       fscanf(fini," %[^\n]",IniFilename);
00107     }
00108     else  *FileInPath(IniFilename) = '\0';
00109     fclose(fini);
00110   }
00111   else {
00112     char *pE;
00113     pE=R_GetEnv("TEMP");
00114     if(pE != NULL){
00115       strcpy(TempPath,pE);  strcat(TempPath,"\\");
00116       strcpy(IniFilename,TempPath);
00117       *FileInPath(TempPath) = '\0';
00118     }
00119     *FileInPath(IniFilename) = '\0';
00120   }
00121   strcat(IniFilename,"OPENFX_.INI");
00122  }
00123  //
00124  retval=(int)DialogBoxParam(hDLLinstance,MAKEINTRESOURCE(DLG_LOGON),hwnd,
00125               (DLGPROC)LogonDlgProc,(LPARAM)no_wait);
00126  return retval;
00127 }
00128 
00129 static int CALLBACK LogonDlgProc(HWND hwnd,UINT msg,WPARAM wparam,
00130                                  LPARAM lparam){
00131  static int ilist[3]={DLG_LOGON_IMAGE_NEW,
00132                       DLG_LOGON_IMAGE_DESIGN,
00133                       DLG_LOGON_IMAGE_HELP};
00134  static UINT StartupTimer=0;
00135  char str[32];
00136  char ttt[256],name[256];
00137  char text0[256],text1[256],text2[256],text3[256],text4[256];
00138  int DisplayBits,bm;
00139  HDC hDCcaps;
00140  HWND hDesktopWnd;
00141  HANDLE hfbm;
00142  DWORD version;
00143  switch( msg ) {
00144    case WM_INITDIALOG:
00145      hDesktopWnd=GetDesktopWindow();
00146      hDCcaps=GetDC(hDesktopWnd);
00147      DisplayBits=GetDeviceCaps(hDCcaps,BITSPIXEL);
00148      ReleaseDC(hDesktopWnd,hDCcaps);
00149      version=GetVersion();
00150      if((version & 0x80000000) == 0x80000000){ /* Not Windows NT */
00151          if(LOBYTE(LOWORD(version)) < 4){
00152            showanim=0;
00153          }
00154      }
00155      strcpy(ttt,text3);
00156      GetPrivateProfileString(IniSection,"USERID","$$$",
00157                    str,sizeof(str),IniFilename);
00158      if(strncmp(str,"$$$",3) == 0){
00159        strcpy(ttt,text4);
00160      }
00161      else strcat(ttt,str);
00162      ghcurHand=LoadCursor(hDLLinstance,MAKEINTRESOURCE(IDC_PAN));
00163      CentreDialogOnScreen(hwnd);
00164      StartupTimer=SetTimer(hwnd,1,8000,NULL);
00165      {
00166        HWND pw;
00167        RECT rect;
00168        POINT p1,p2;
00169        pw=GetDlgItem(hwnd,DLG_LOGON_IMAGE_DESIGN);
00170        if(pw != NULL){
00171          GetWindowRect(pw,&rect);
00172          p1.x=rect.left;
00173          p1.y=rect.top;
00174          p2.x=rect.right;
00175          p2.y=rect.bottom;
00176          ScreenToClient(hwnd,&p1);
00177          ScreenToClient(hwnd,&p2);
00178          rect.left=p1.x;
00179          rect.top=p1.y;
00180          rect.right=p2.x;
00181          rect.bottom=p2.y;
00182          OffsetRect(&rect,0,-1);
00183          MoveWindow(pw,rect.left,rect.top,
00184                     rect.right-rect.left,
00185                     rect.bottom-rect.top,FALSE);
00186        }
00187        pw=GetDlgItem(hwnd,DLG_LOGON_IMAGE_NEW);
00188        if(pw != NULL){
00189          GetWindowRect(pw,&rect);
00190          p1.x=rect.left;
00191          p1.y=rect.top;
00192          p2.x=rect.right;
00193          p2.y=rect.bottom;
00194          ScreenToClient(hwnd,&p1);
00195          ScreenToClient(hwnd,&p2);
00196          rect.left=p1.x;
00197          rect.top=p1.y;
00198          rect.right=p2.x;
00199          rect.bottom=p2.y;
00200          OffsetRect(&rect,1,1);
00201          MoveWindow(pw,rect.left,rect.top,
00202                     rect.right-rect.left,
00203                     rect.bottom-rect.top,FALSE);
00204        }
00205      }
00206      return TRUE;
00207    case WM_DESTROY:
00208      if(StartupTimer > 0)KillTimer(hwnd,StartupTimer);
00209      if(hBitmap != NULL)DeleteObject(hBitmap); hBitmap=NULL;
00210      break;
00211    case WM_TIMER:
00212      switch(wparam){
00213        case 1:
00214          EndDialog(hwnd,1);
00215          return(TRUE);
00216          break;
00217        case 2:
00218          EndDialog(hwnd,1);
00219          return(TRUE);
00220          break;
00221        default: break;
00222      }
00223      break;
00224    case WM_LBUTTONDOWN:{
00225        HWND pw;
00226        RECT rect;
00227        POINT p1,p2,pm;
00228        int i;
00229        pm.x=LOWORD(lparam);
00230        pm.y=HIWORD(lparam);
00231        for(i=0;i<3;i++){
00232          pw=GetDlgItem(hwnd,ilist[i]);
00233          if(pw != NULL){
00234            GetWindowRect(pw,&rect);
00235            p1.x=rect.left;
00236            p1.y=rect.top;
00237            p2.x=rect.right;
00238            p2.y=rect.bottom;
00239            ScreenToClient(hwnd,&p1);
00240            ScreenToClient(hwnd,&p2);
00241            rect.left=p1.x;
00242            rect.top=p1.y;
00243            rect.right=p2.x;
00244            rect.bottom=p2.y;
00245            if(PtInRect(&rect,pm)){
00246              if(i == 0){
00247                EndDialog(hwnd,1);
00248                return(TRUE);
00249              }
00250              else if(i == 1){
00251                EndDialog(hwnd,5);
00252                return(TRUE);
00253              }
00254              else if(i == 2){
00255                EndDialog(hwnd,4);
00256                return(TRUE);
00257              }
00258            }
00259          }
00260        }
00261      }
00262      break;
00263    case WM_MOUSEMOVE:{
00264        HWND pw;
00265        RECT rect;
00266        POINT p1,p2,pm;
00267        int i,cf=0;
00268        pm.x=LOWORD(lparam);
00269        pm.y=HIWORD(lparam);
00270        for(i=0;i<3;i++){
00271          pw=GetDlgItem(hwnd,ilist[i]);
00272          if(pw != NULL){
00273            GetWindowRect(pw,&rect);
00274            p1.x=rect.left;
00275            p1.y=rect.top;
00276            p2.x=rect.right;
00277            p2.y=rect.bottom;
00278            ScreenToClient(hwnd,&p1);
00279            ScreenToClient(hwnd,&p2);
00280            rect.left=p1.x;
00281            rect.top=p1.y;
00282            rect.right=p2.x;
00283            rect.bottom=p2.y;
00284            if(PtInRect(&rect,pm)){
00285              cf=1;
00286              if(StartupTimer > 0){
00287                KillTimer(hwnd,StartupTimer);
00288                StartupTimer=0;
00289              }
00290              ShowWindow(pw,SW_SHOW);
00291            }
00292            else{
00293              ShowWindow(pw,SW_HIDE);
00294            }
00295            if(cf == 1)SetCursor(ghcurHand);
00296            else SetCursor(LoadCursor(NULL,IDC_ARROW));
00297          }
00298        }
00299      }
00300      break;
00301    case WM_COMMAND:
00302      switch(LOWORD(wparam)){
00303         case IDCANCEL:
00304         case DLG_LOGON_CANCEL:
00305           EndDialog(hwnd,-1);
00306           return(TRUE);
00307         case DLG_LOGON_NEW:
00308           EndDialog(hwnd,1);
00309           return(TRUE);
00310         case DLG_LOGON_LOAD:
00311           EndDialog(hwnd,2);
00312           return(TRUE);
00313         case DLG_LOGON_TEMPLATE:
00314           EndDialog(hwnd,3);
00315           return(TRUE);
00316         case DLG_LOGON_HELP:
00317           EndDialog(hwnd,4);
00318           return(TRUE);
00319         case DLG_LOGON_MODELER:
00320           EndDialog(hwnd,5);
00321           return(TRUE);
00322         default:
00323           break;
00324       }
00325       break;
00326     default: break;
00327  }
00328  return FALSE;
00329 }
00330 
00331 

Generated on Sun Apr 27 14:20:09 2014 for OpenFX by  doxygen 1.5.6