ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

settingsdlg.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Applications Manager
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            base/applications/rapps/settingsdlg.c
00005  * PURPOSE:         Settings Dialog
00006  * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
00007  */
00008 
00009 #include "rapps.h"
00010 
00011 SETTINGS_INFO NewSettingsInfo;
00012 
00013 #define IS_CHECKED(a, b) \
00014     a = (SendDlgItemMessage(hDlg, b, BM_GETCHECK, 0, 0) == BST_CHECKED) ? TRUE : FALSE
00015 
00016 BOOL
00017 ChooseFolder(HWND hwnd)
00018 {
00019     BROWSEINFO fi;
00020     LPCITEMIDLIST lpItemList;
00021     WCHAR szPath[MAX_PATH], szBuf[MAX_STR_LEN];
00022 
00023     LoadStringW(hInst, IDS_CHOOSE_FOLDER_TEXT, szBuf, sizeof(szBuf) / sizeof(TCHAR));
00024 
00025     ZeroMemory(&fi, sizeof(BROWSEINFO));
00026     fi.hwndOwner = hwnd;
00027     fi.lpszTitle = szBuf;
00028     fi.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_BROWSEFORCOMPUTER | BIF_NEWDIALOGSTYLE;
00029     fi.lpfn = NULL;
00030     fi.lParam = -1;
00031     fi.iImage = 0;
00032 
00033     if (!(lpItemList = SHBrowseForFolder(&fi))) return FALSE;
00034     SHGetPathFromIDList(lpItemList, szPath);
00035 
00036     if (wcslen(szPath) == 0) return FALSE;
00037     SetDlgItemTextW(hwnd, IDC_DOWNLOAD_DIR_EDIT, szPath);
00038 
00039     return TRUE;
00040 }
00041 
00042 static VOID
00043 InitSettingsControls(HWND hDlg, SETTINGS_INFO Info)
00044 {
00045     SendDlgItemMessage(hDlg, IDC_SAVE_WINDOW_POS, BM_SETCHECK, Info.bSaveWndPos, 0);
00046     SendDlgItemMessage(hDlg, IDC_UPDATE_AVLIST, BM_SETCHECK, Info.bUpdateAtStart, 0);
00047     SendDlgItemMessage(hDlg, IDC_LOG_ENABLED, BM_SETCHECK, Info.bLogEnabled, 0);
00048     SendDlgItemMessage(hDlg, IDC_DEL_AFTER_INSTALL, BM_SETCHECK, Info.bDelInstaller, 0);
00049 
00050     SetWindowTextW(GetDlgItem(hDlg, IDC_DOWNLOAD_DIR_EDIT),
00051                    Info.szDownloadDir);
00052 }
00053 
00054 static
00055 INT_PTR CALLBACK
00056 SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
00057 {
00058     switch (Msg)
00059     {
00060         case WM_INITDIALOG:
00061         {
00062             NewSettingsInfo = SettingsInfo;
00063             InitSettingsControls(hDlg, SettingsInfo);
00064         }
00065         break;
00066 
00067         case WM_COMMAND:
00068         {
00069             switch (LOWORD(wParam))
00070             {
00071                 case IDC_CHOOSE:
00072                     ChooseFolder(hDlg);
00073                     break;
00074 
00075                 case IDC_SAVE_WINDOW_POS:
00076                     IS_CHECKED(NewSettingsInfo.bSaveWndPos, IDC_SAVE_WINDOW_POS);
00077                     break;
00078 
00079                 case IDC_UPDATE_AVLIST:
00080                     IS_CHECKED(NewSettingsInfo.bUpdateAtStart, IDC_UPDATE_AVLIST);
00081                     break;
00082 
00083                 case IDC_LOG_ENABLED:
00084                     IS_CHECKED(NewSettingsInfo.bLogEnabled, IDC_LOG_ENABLED);
00085                     break;
00086 
00087                 case IDC_DEL_AFTER_INSTALL:
00088                     IS_CHECKED(NewSettingsInfo.bDelInstaller, IDC_DEL_AFTER_INSTALL);
00089                     break;
00090 
00091                 case IDC_DEFAULT_SETTINGS:
00092                     FillDafaultSettings(&NewSettingsInfo);
00093                     InitSettingsControls(hDlg, NewSettingsInfo);
00094                     break;
00095 
00096                 case IDOK:
00097                 {
00098                     WCHAR szDir[MAX_PATH];
00099                     DWORD dwAttr;
00100 
00101                     GetWindowTextW(GetDlgItem(hDlg, IDC_DOWNLOAD_DIR_EDIT),
00102                                    szDir, MAX_PATH);
00103 
00104                     dwAttr = GetFileAttributesW(szDir);
00105                     if (dwAttr != INVALID_FILE_ATTRIBUTES &&
00106                         (dwAttr & FILE_ATTRIBUTE_DIRECTORY))
00107                     {
00108                         wcscpy(NewSettingsInfo.szDownloadDir, szDir);
00109                     }
00110                     else
00111                     {
00112                         WCHAR szMsgText[MAX_STR_LEN];
00113 
00114                         LoadStringW(hInst,
00115                                     IDS_CHOOSE_FOLDER_ERROR,
00116                                     szMsgText, sizeof(szMsgText) / sizeof(WCHAR));
00117 
00118                         if (MessageBoxW(hDlg, szMsgText, NULL, MB_YESNO) == IDYES)
00119                         {
00120                             if (CreateDirectoryW(szDir, NULL))
00121                             {
00122                                 EndDialog(hDlg, LOWORD(wParam));
00123                             }
00124                         }
00125 
00126                         SetFocus(GetDlgItem(hDlg, IDC_DOWNLOAD_DIR_EDIT));
00127                         break;
00128                     }
00129 
00130                     SettingsInfo = NewSettingsInfo;
00131                     SaveSettings(GetParent(hDlg));
00132                     EndDialog(hDlg, LOWORD(wParam));
00133                 }
00134                 break;
00135 
00136                 case IDCANCEL:
00137                     EndDialog(hDlg, LOWORD(wParam));
00138                     break;
00139             }
00140         }
00141         break;
00142     }
00143 
00144     return FALSE;
00145 }
00146 
00147 VOID
00148 CreateSettingsDlg(HWND hwnd)
00149 {
00150     DialogBoxW(hInst,
00151                MAKEINTRESOURCEW(IDD_SETTINGS_DIALOG),
00152                hwnd,
00153                SettingsDlgProc);
00154 }

Generated on Wed May 23 2012 04:15:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.