Back to index

lightning-sunbird  0.9+nobinonly
dialogs.c
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code, released
00016  * March 31, 1998.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Sean Su <ssu@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #include "extern.h"
00041 #include "extra.h"
00042 #include "dialogs.h"
00043 #include "ifuncns.h"
00044 #include "parser.h"
00045 #include "rdi.h"
00046 #include "shlobj.h"
00047 
00048 #define MOZ_HWND_BROADCAST_MSG_TIMEOUT 5000
00049 #define MOZ_CLIENT_BROWSER_KEY         "Software\\Clients\\StartMenuInternet"
00050 #define MOZ_CLIENT_MAIL_KEY            "Software\\Clients\\Mail"
00051 
00052 void SetDefault()
00053 {
00054   char szBuf[MAX_BUF];
00055   char szRegKey[MAX_BUF];
00056 
00057   GetPrivateProfileString(ugUninstall.szDefaultComponent, "ClientTypeName", "", szBuf, MAX_BUF, szFileIniDefaultsInfo);
00058   wsprintf(szRegKey, "SOFTWARE\\Clients\\%s", szBuf);
00059   GetPrivateProfileString(ugUninstall.szDefaultComponent, "ClientProductKey", "", szBuf, MAX_BUF, szFileIniDefaultsInfo);
00060 
00061   SetWinReg(HKEY_LOCAL_MACHINE, szRegKey, "", REG_SZ, szBuf, lstrlen(szBuf));
00062 }
00063 
00064 void ParseDefaultsInfo()
00065 {
00066   char szBuf[MAX_BUF];
00067   char szIniKey[MAX_BUF];
00068   char szStorageDir[MAX_BUF];
00069   char szShortcutPath[MAX_BUF];
00070   char szStoredShortcutPath[MAX_BUF];
00071   char szRegKey[MAX_BUF];
00072   char szClientTypeName[MAX_BUF];
00073   char szClientProductKey[MAX_BUF];
00074   int  iIndex;
00075   DWORD dwIconsVisible;
00076 
00077   // If szAppPath is a null sting, i.e. we cannot find where the app has been installed:
00078   //   - HIDEICONS will still remove the shortcuts but
00079   //   - SHOWICONS will do nothing because we won't be able to find the shortcuts to display.
00080   ParsePath(ugUninstall.szAppPath, szStorageDir, MAX_BUF, PP_PATH_ONLY);
00081   lstrcat(szStorageDir, "defaults\\shortcuts\\");
00082 
00083   // CLEANUP ISSUE:  For all of the SHOWICON and HIDEICONS blocks below, there is a lot of
00084   //   redundancy:
00085   //   - Right now I'm just trying to create icons and, if I can't, trying under the PERSONAL
00086   //     key instead.  I would be cleaner to check for restricted access once, and then just
00087   //     create the appropriate key each time.
00088   //   - Creating a ShowIcon() and a HideIcon() function would rid us much of the redundency.
00089 
00090 
00091   // Deal with Desktop Icons
00092   iIndex = 0;
00093   wsprintf(szIniKey, "DesktopShortcut%d", iIndex);
00094   GetPrivateProfileString(ugUninstall.szDefaultComponent, szIniKey, "", szBuf, MAX_BUF, szFileIniDefaultsInfo);
00095   while(szBuf[0] != '\0')
00096   {
00097     strcpy(szShortcutPath, "COMMON_DESKTOP");
00098     DecryptVariable(szShortcutPath, MAX_BUF);
00099 
00100     if((ugUninstall.mode == SHOWICONS) && (szStorageDir[0] != '\0'))
00101     {
00102       wsprintf(szStoredShortcutPath, "%s%s", szStorageDir, szBuf);
00103       FileCopy(szStoredShortcutPath, szShortcutPath, 0);
00104       if( (!FileExists(szShortcutPath)) && (!(ulOSType & OS_WIN9x)) )
00105       {
00106         strcpy(szShortcutPath, "PERSONAL_DESKTOP");
00107         DecryptVariable(szShortcutPath, MAX_BUF);
00108         FileCopy(szStoredShortcutPath, szShortcutPath, 0);
00109       }
00110     }
00111 
00112     if (ugUninstall.mode == HIDEICONS)
00113     {
00114       AppendBackSlash(szShortcutPath, MAX_BUF);
00115       lstrcat(szShortcutPath, szBuf);
00116       if( (!FileExists(szShortcutPath)) && (!(ulOSType & OS_WIN9x)) )
00117       {
00118         strcpy(szShortcutPath, "PERSONAL_DESKTOP");
00119         DecryptVariable(szShortcutPath, MAX_BUF);
00120         AppendBackSlash(szShortcutPath, MAX_BUF);
00121         lstrcat(szShortcutPath, szBuf);
00122       }
00123 
00124       FileDelete(szShortcutPath);
00125     }
00126 
00127     iIndex++;
00128     wsprintf(szIniKey, "DesktopShortcut%d", iIndex);
00129     GetPrivateProfileString(ugUninstall.szDefaultComponent, szIniKey, "", szBuf, MAX_BUF, szFileIniDefaultsInfo);
00130   }
00131 
00132   // Deal with StartMenu Icons
00133   iIndex = 0;
00134   wsprintf(szIniKey, "StartMenuShortcut%d", iIndex);
00135   GetPrivateProfileString(ugUninstall.szDefaultComponent, szIniKey, "", szBuf, MAX_BUF, szFileIniDefaultsInfo);
00136   while(szBuf[0] != '\0')
00137   {
00138     strcpy(szShortcutPath, "COMMON_STARTMENU");
00139     DecryptVariable(szShortcutPath, MAX_BUF);
00140 
00141     if((ugUninstall.mode == SHOWICONS) && (szStorageDir[0] != '\0'))
00142     {
00143       lstrcpy(szStoredShortcutPath, szStorageDir);
00144       lstrcat(szStoredShortcutPath, szBuf);
00145       FileCopy(szStoredShortcutPath, szShortcutPath, 0);
00146       if( (!FileExists(szShortcutPath)) && (!(ulOSType & OS_WIN9x)) )
00147       {
00148         strcpy(szShortcutPath, "PERSONAL_STARTMENU");
00149         DecryptVariable(szShortcutPath, MAX_BUF);
00150         FileCopy(szStoredShortcutPath, szShortcutPath, 0);
00151       }
00152     }
00153 
00154     if (ugUninstall.mode == HIDEICONS)
00155     {
00156       AppendBackSlash(szShortcutPath, MAX_BUF);
00157       lstrcat(szShortcutPath, szBuf);
00158       if( (!FileExists(szShortcutPath)) && (!(ulOSType & OS_WIN9x)) )
00159       {
00160         strcpy(szShortcutPath, "PERSONAL_STARTMENU");
00161         DecryptVariable(szShortcutPath, MAX_BUF);
00162         AppendBackSlash(szShortcutPath, MAX_BUF);
00163         lstrcat(szShortcutPath, szBuf);
00164       }
00165 
00166       FileDelete(szShortcutPath);
00167     }
00168 
00169     iIndex++;
00170     wsprintf(szIniKey, "StartMenuShortcut%d", iIndex);
00171     GetPrivateProfileString(ugUninstall.szDefaultComponent, szIniKey, "", szBuf, MAX_BUF, szFileIniDefaultsInfo);
00172   }
00173 
00174   // Deal with QuickLaunch Bar Icons
00175   iIndex = 0;
00176   wsprintf(szIniKey, "QuickLaunchBarShortcut%d", iIndex);
00177   GetPrivateProfileString(ugUninstall.szDefaultComponent, szIniKey, "", szBuf, MAX_BUF, szFileIniDefaultsInfo);
00178   while(szBuf[0] != '\0')
00179   {
00180     GetWinReg(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "AppData", szShortcutPath, MAX_BUF);
00181     lstrcat(szShortcutPath, "\\Microsoft\\Internet Explorer\\Quick Launch");
00182 
00183     if((ugUninstall.mode == SHOWICONS) && (szStorageDir[0] != '\0'))
00184     {
00185       wsprintf(szStoredShortcutPath, "%s%s", szStorageDir, szBuf);
00186       FileCopy(szStoredShortcutPath, szShortcutPath, 0);
00187       if( (!FileExists(szShortcutPath)) && (!(ulOSType & OS_WIN9x)) )
00188       {
00189         GetWinReg(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GrpConv\\MapGroups", "Quick Launch", szShortcutPath, MAX_BUF);
00190         FileCopy(szStoredShortcutPath, szShortcutPath, 0);
00191       }
00192     }
00193 
00194     if (ugUninstall.mode == HIDEICONS)
00195     {
00196       AppendBackSlash(szShortcutPath, MAX_BUF);
00197       lstrcat(szShortcutPath, szBuf);
00198       if( (!FileExists(szShortcutPath)) && (!(ulOSType & OS_WIN9x)) )
00199       {
00200         GetWinReg(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GrpConv\\MapGroups", "Quick Launch", szShortcutPath, MAX_BUF);
00201         AppendBackSlash(szShortcutPath, MAX_BUF);
00202         lstrcat(szShortcutPath, szBuf);
00203       }
00204 
00205       FileDelete(szShortcutPath);
00206     }
00207 
00208     ++iIndex;
00209     wsprintf(szIniKey, "QuickLaunchBarShortcut%d", iIndex);
00210     GetPrivateProfileString(ugUninstall.szDefaultComponent, szIniKey, "", szBuf, MAX_BUF, szFileIniDefaultsInfo);
00211   }
00212 
00213   GetPrivateProfileString(ugUninstall.szDefaultComponent, "ClientTypeName", "", szClientTypeName, MAX_BUF, szFileIniDefaultsInfo);
00214   GetPrivateProfileString(ugUninstall.szDefaultComponent, "ClientProductKey", "", szClientProductKey, MAX_BUF, szFileIniDefaultsInfo);
00215   wsprintf(szRegKey, "SOFTWARE\\Clients\\%s\\%s\\InstallInfo", szClientTypeName, szClientProductKey);
00216 
00217   if (ugUninstall.mode == SHOWICONS)
00218     dwIconsVisible = 1;
00219   else
00220     dwIconsVisible = 0;
00221 
00222   SetWinRegNumValue(HKEY_LOCAL_MACHINE, szRegKey, "IconsVisible", dwIconsVisible);
00223 }
00224 
00225 void ParseAllUninstallLogs()
00226 {
00227   char  szFileInstallLog[MAX_BUF];
00228   char  szKey[MAX_BUF];
00229   sil   *silFile;
00230   DWORD dwFileFound;
00231   DWORD dwRv = 0;
00232 
00233   UndoDesktopIntegration();
00234   CleanupMailIntegration();
00235   dwFileFound = GetLogFile(ugUninstall.szLogPath, ugUninstall.szLogFilename, szFileInstallLog, sizeof(szFileInstallLog));
00236   while(dwFileFound)
00237   {
00238     if((silFile = InitSilNodes(szFileInstallLog)) != NULL)
00239     {
00240       FileDelete(szFileInstallLog);
00241       dwRv = Uninstall(silFile);
00242       DeInitSilNodes(&silFile);
00243       if(dwRv == WTD_CANCEL)
00244         break;
00245     }
00246 
00247     dwFileFound = GetLogFile(ugUninstall.szLogPath, ugUninstall.szLogFilename, szFileInstallLog, sizeof(szFileInstallLog));
00248   }
00249 
00250   if(dwRv != WTD_CANCEL)
00251   {
00252     lstrcpy(szFileInstallLog, ugUninstall.szLogPath);
00253     AppendBackSlash(szFileInstallLog, MAX_BUF);
00254     lstrcat(szFileInstallLog, ugUninstall.szLogFilename);
00255     if(FileExists(szFileInstallLog))
00256     {
00257       if((silFile = InitSilNodes(szFileInstallLog)) != NULL)
00258       {
00259         FileDelete(szFileInstallLog);
00260         Uninstall(silFile);
00261         DeInitSilNodes(&silFile);
00262       }
00263     }
00264 
00265     /* clean up the uninstall windows registry key */
00266     lstrcpy(szKey, "Software\\Microsoft\\Windows\\CurrentVersion\\uninstall\\");
00267     lstrcat(szKey, ugUninstall.szUninstallKeyDescription);
00268     RegDeleteKey(HKEY_LOCAL_MACHINE, szKey);
00269 
00270     /* update Wininit.ini to remove itself at reboot */
00271     RemoveUninstaller(ugUninstall.szUninstallFilename);
00272 
00273     // Calling SHChangeNotify() will update the file association icons
00274     // in case they had been reset.
00275     SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
00276   }
00277 
00278   /* Broadcast message only if the windows registry keys exist
00279    * in case they were changed during uninstallation.  If they
00280    * were, then the broadcast will alert the OS to update the appropriate UIs.
00281    * This needs to be done regardless if the user canceled the uninstall
00282    * process or not.
00283    */
00284   if(WinRegKeyExists(HKEY_LOCAL_MACHINE, MOZ_CLIENT_BROWSER_KEY))
00285   {
00286     SendMessageTimeout(HWND_BROADCAST,
00287                        WM_SETTINGCHANGE,
00288                        0,
00289                        (LPARAM)MOZ_CLIENT_BROWSER_KEY,
00290                        SMTO_NORMAL|SMTO_ABORTIFHUNG,
00291                        MOZ_HWND_BROADCAST_MSG_TIMEOUT,
00292                        NULL);
00293   }
00294   if(WinRegKeyExists(HKEY_LOCAL_MACHINE, MOZ_CLIENT_MAIL_KEY))
00295   {
00296     SendMessageTimeout(HWND_BROADCAST,
00297                        WM_SETTINGCHANGE,
00298                        0,
00299                        (LPARAM)MOZ_CLIENT_MAIL_KEY,
00300                        SMTO_NORMAL|SMTO_ABORTIFHUNG,
00301                        MOZ_HWND_BROADCAST_MSG_TIMEOUT,
00302                        NULL);
00303   }
00304 }
00305 
00306 LRESULT CALLBACK DlgProcUninstall(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
00307 {
00308   char  szBuf[MAX_BUF];
00309   RECT  rDlg;
00310 
00311   switch(msg)
00312   {
00313     case WM_INITDIALOG:
00314       SetWindowText(hDlg, diUninstall.szTitle);
00315       wsprintf(szBuf, diUninstall.szMessage0, ugUninstall.szDescription);
00316       SetDlgItemText(hDlg, IDC_MESSAGE0, szBuf);
00317       GetPrivateProfileString("Dialog Uninstall", "Yes", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00318       SetDlgItemText(hDlg, IDWIZNEXT, szBuf);
00319       GetPrivateProfileString("Dialog Uninstall", "No", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00320       SetDlgItemText(hDlg, IDCANCEL, szBuf);
00321       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00322       SendDlgItemMessage (hDlg, IDWIZNEXT, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00323       SendDlgItemMessage (hDlg, IDCANCEL, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00324 
00325       if(GetClientRect(hDlg, &rDlg))
00326         SetWindowPos(hDlg, HWND_TOP, (dwScreenX/2)-(rDlg.right/2), (dwScreenY/2)-(rDlg.bottom/2), 0, 0, SWP_NOSIZE);
00327 
00328       break;
00329 
00330     case WM_COMMAND:
00331       switch(LOWORD(wParam))
00332       {
00333         case IDWIZNEXT:
00334           EnableWindow(GetDlgItem(hDlg, IDWIZNEXT), FALSE);
00335           EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE);
00336           ParseAllUninstallLogs();
00337           VerifyAndDeleteInstallationFolder();
00338           DestroyWindow(hDlg);
00339           PostQuitMessage(0);
00340           break;
00341 
00342         case IDCANCEL:
00343           DestroyWindow(hDlg);
00344           PostQuitMessage(0);
00345           break;
00346 
00347         default:
00348           break;
00349       }
00350       break;
00351   }
00352   return(0);
00353 }
00354 
00355 LRESULT CALLBACK DlgProcWhatToDo(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
00356 {
00357   char  szBuf[MAX_BUF];
00358   RECT  rDlg;
00359 
00360   switch(msg)
00361   {
00362     case WM_INITDIALOG:
00363       GetPrivateProfileString("Messages", "DLG_REMOVE_FILE_TITLE", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00364       SetWindowText(hDlg, szBuf);
00365 
00366       if((LPSTR)lParam != NULL)
00367         SetDlgItemText(hDlg, IDC_STATIC_SHARED_FILENAME, (LPSTR)lParam);
00368 
00369       GetPrivateProfileString("Dialog Uninstall", "Message1", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00370       SetDlgItemText(hDlg, IDC_MESSAGE0, szBuf);
00371       GetPrivateProfileString("Dialog Uninstall", "Message2", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00372       SetDlgItemText(hDlg, IDC_MESSAGE1, szBuf);
00373       GetPrivateProfileString("Dialog Uninstall", "FileName", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00374       SetDlgItemText(hDlg, IDC_STATIC, szBuf);
00375       GetPrivateProfileString("Dialog Uninstall", "No", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00376       SetDlgItemText(hDlg, ID_NO, szBuf);
00377       GetPrivateProfileString("Dialog Uninstall", "NoToAll", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00378       SetDlgItemText(hDlg, ID_NO_TO_ALL, szBuf);
00379       GetPrivateProfileString("Dialog Uninstall", "Yes", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00380       SetDlgItemText(hDlg, ID_YES, szBuf);
00381       GetPrivateProfileString("Dialog Uninstall", "YesToAll", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00382       SetDlgItemText(hDlg, ID_YES_TO_ALL, szBuf);
00383 
00384       SendDlgItemMessage (hDlg, IDC_MESSAGE0, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00385       SendDlgItemMessage (hDlg, IDC_MESSAGE1, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00386       SendDlgItemMessage (hDlg, IDC_STATIC, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00387       SendDlgItemMessage (hDlg, IDC_STATIC_SHARED_FILENAME, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00388       SendDlgItemMessage (hDlg, ID_NO, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00389       SendDlgItemMessage (hDlg, ID_NO_TO_ALL, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00390       SendDlgItemMessage (hDlg, ID_YES, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00391       SendDlgItemMessage (hDlg, ID_YES_TO_ALL, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00392 
00393       if(GetClientRect(hDlg, &rDlg))
00394         SetWindowPos(hDlg, HWND_TOP, (dwScreenX/2)-(rDlg.right/2), (dwScreenY/2)-(rDlg.bottom/2), 0, 0, SWP_NOSIZE);
00395 
00396       break;
00397 
00398     case WM_COMMAND:
00399       switch(LOWORD(wParam))
00400       {
00401         case ID_NO:
00402           EndDialog(hDlg, WTD_NO);
00403           break;
00404 
00405         case ID_NO_TO_ALL:
00406           EndDialog(hDlg, WTD_NO_TO_ALL);
00407           break;
00408 
00409         case ID_YES:
00410           EndDialog(hDlg, WTD_YES);
00411           break;
00412 
00413         case ID_YES_TO_ALL:
00414           EndDialog(hDlg, WTD_YES_TO_ALL);
00415           break;
00416 
00417         default:
00418           break;
00419       }
00420       break;
00421   }
00422   return(0);
00423 }
00424 
00425 LRESULT CALLBACK DlgProcMessage(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam)
00426 {
00427   RECT      rDlg;
00428   HWND      hSTMessage = GetDlgItem(hDlg, IDC_MESSAGE); /* handle to the Static Text message window */
00429   HDC       hdcSTMessage;
00430   SIZE      sizeString;
00431   LOGFONT   logFont;
00432   HFONT     hfontTmp;
00433   HFONT     hfontOld;
00434   int       i;
00435 
00436   switch(msg)
00437   {
00438     case WM_INITDIALOG:
00439           SendDlgItemMessage (hDlg, IDC_MESSAGE, WM_SETFONT, (WPARAM)ugUninstall.definedFont, 0L); 
00440       break;
00441 
00442     case WM_COMMAND:
00443       switch(LOWORD(wParam))
00444       {
00445         case IDC_MESSAGE:
00446           hdcSTMessage = GetWindowDC(hSTMessage);
00447 
00448           SystemParametersInfo(SPI_GETICONTITLELOGFONT,
00449                                sizeof(logFont),
00450                                (PVOID)&logFont,
00451                                0);
00452           hfontTmp = CreateFontIndirect(&logFont);
00453 
00454           if(hfontTmp)
00455             hfontOld = SelectObject(hdcSTMessage, hfontTmp);
00456 
00457           GetTextExtentPoint32(hdcSTMessage, (LPSTR)lParam, lstrlen((LPSTR)lParam), &sizeString);
00458           SelectObject(hdcSTMessage, hfontOld);
00459           DeleteObject(hfontTmp);
00460           ReleaseDC(hSTMessage, hdcSTMessage);
00461 
00462           SetWindowPos(hDlg, HWND_TOP,
00463                       (dwScreenX/2)-((sizeString.cx + 40)/2), (dwScreenY/2)-((sizeString.cy + 40)/2),
00464                       sizeString.cx + 40, sizeString.cy + 40,
00465                       SWP_SHOWWINDOW);
00466 
00467           if(GetClientRect(hDlg, &rDlg))
00468             SetWindowPos(hSTMessage,
00469                          HWND_TOP,
00470                          rDlg.left,
00471                          rDlg.top,
00472                          rDlg.right,
00473                          rDlg.bottom,
00474                          SWP_SHOWWINDOW);
00475 
00476           for(i = 0; i < lstrlen((LPSTR)lParam); i++)
00477           {
00478             if((((LPSTR)lParam)[i] == '\r') || (((LPSTR)lParam)[i] == '\n')) 
00479               ((LPSTR)lParam)[i] = ' ';
00480           }
00481 
00482           SetDlgItemText(hDlg, IDC_MESSAGE, (LPSTR)lParam);
00483           break;
00484       }
00485       break;
00486   }
00487   return(0);
00488 }
00489 
00490 void ProcessWindowsMessages()
00491 {
00492   MSG msg;
00493 
00494   while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
00495   {
00496     TranslateMessage(&msg);
00497     DispatchMessage(&msg);
00498   }
00499 }
00500 
00501 void ShowMessage(LPSTR szMessage, BOOL bShow)
00502 {
00503   char szBuf[MAX_BUF];
00504 
00505   if(ugUninstall.mode != SILENT)
00506   {
00507     if((bShow) && (hDlgMessage == NULL))
00508     {
00509       ZeroMemory(szBuf, sizeof(szBuf));
00510       GetPrivateProfileString("Messages", "MB_MESSAGE_STR", "", szBuf, sizeof(szBuf), szFileIniUninstall);
00511       hDlgMessage = InstantiateDialog(hWndMain, DLG_MESSAGE, szBuf, DlgProcMessage);
00512       SendMessage(hDlgMessage, WM_COMMAND, IDC_MESSAGE, (LPARAM)szMessage);
00513     }
00514     else if(!bShow && hDlgMessage)
00515     {
00516       DestroyWindow(hDlgMessage);
00517       hDlgMessage = NULL;
00518     }
00519   }
00520 }
00521 
00522 HWND InstantiateDialog(HWND hParent, DWORD dwDlgID, LPSTR szTitle, WNDPROC wpDlgProc)
00523 {
00524   char szBuf[MAX_BUF];
00525   HWND hDlg = NULL;
00526 
00527   if((hDlg = CreateDialog(hInst, MAKEINTRESOURCE(dwDlgID), hParent, wpDlgProc)) == NULL)
00528   {
00529     char szEDialogCreate[MAX_BUF];
00530 
00531     if(GetPrivateProfileString("Messages", "ERROR_DIALOG_CREATE", "", szEDialogCreate, sizeof(szEDialogCreate), szFileIniUninstall))
00532     {
00533       wsprintf(szBuf, szEDialogCreate, szTitle);
00534       PrintError(szBuf, ERROR_CODE_SHOW);
00535     }
00536 
00537     PostQuitMessage(1);
00538   }
00539 
00540   return(hDlg);
00541 }