Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenprogress.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Services 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: base/applications/mscutils/servman/progress.c 00005 * PURPOSE: Progress dialog box message handler 00006 * COPYRIGHT: Copyright 2006-2010 Ged Murphy <gedmurphy@reactos.org> 00007 * 00008 */ 00009 00010 #include "precomp.h" 00011 00012 #define PROGRESSRANGE 20 00013 00014 VOID 00015 CompleteProgressBar(HWND hProgDlg) 00016 { 00017 HWND hProgBar; 00018 UINT Pos = 0; 00019 00020 /* Get a handle to the progress bar */ 00021 hProgBar = GetDlgItem(hProgDlg, 00022 IDC_SERVCON_PROGRESS); 00023 if (hProgBar) 00024 { 00025 /* Get the current position */ 00026 Pos = SendMessageW(hProgBar, 00027 PBM_GETPOS, 00028 0, 00029 0); 00030 00031 /* Loop until we hit the max */ 00032 while (Pos <= PROGRESSRANGE) 00033 { 00034 /* Increment the progress bar */ 00035 SendMessageW(hProgBar, 00036 PBM_DELTAPOS, 00037 Pos, 00038 0); 00039 00040 /* Wait for 15ms, it gives it a smooth feel */ 00041 Sleep(15); 00042 Pos++; 00043 } 00044 } 00045 } 00046 00047 VOID 00048 IncrementProgressBar(HWND hProgDlg, 00049 UINT NewPos) 00050 { 00051 HWND hProgBar; 00052 00053 /* Get a handle to the progress bar */ 00054 hProgBar = GetDlgItem(hProgDlg, 00055 IDC_SERVCON_PROGRESS); 00056 if (hProgBar) 00057 { 00058 /* Do we want to increment the default amount? */ 00059 if (NewPos == DEFAULT_STEP) 00060 { 00061 /* Yes, use the step value we set on create */ 00062 SendMessageW(hProgBar, 00063 PBM_STEPIT, 00064 0, 00065 0); 00066 } 00067 else 00068 { 00069 /* No, use the value passed */ 00070 SendMessageW(hProgBar, 00071 PBM_SETPOS, 00072 NewPos, 00073 0); 00074 } 00075 } 00076 } 00077 00078 VOID 00079 InitializeProgressDialog(HWND hProgDlg, 00080 LPWSTR lpServiceName) 00081 { 00082 /* Write the service name to the dialog */ 00083 SendDlgItemMessageW(hProgDlg, 00084 IDC_SERVCON_NAME, 00085 WM_SETTEXT, 00086 0, 00087 (LPARAM)lpServiceName); 00088 00089 /* Set the progress bar to the start */ 00090 SendDlgItemMessageW(hProgDlg, 00091 IDC_SERVCON_PROGRESS, 00092 PBM_SETPOS, 00093 0, 00094 0); 00095 } 00096 00097 INT_PTR CALLBACK 00098 ProgressDialogProc(HWND hDlg, 00099 UINT Message, 00100 WPARAM wParam, 00101 LPARAM lParam) 00102 { 00103 switch(Message) 00104 { 00105 case WM_INITDIALOG: 00106 { 00107 HWND hProgBar; 00108 00109 /* Get a handle to the progress bar */ 00110 hProgBar = GetDlgItem(hDlg, 00111 IDC_SERVCON_PROGRESS); 00112 00113 /* Set the progress bar range */ 00114 SendMessageW(hProgBar, 00115 PBM_SETRANGE, 00116 0, 00117 MAKELPARAM(0, PROGRESSRANGE)); 00118 00119 /* Set the progress bar step */ 00120 SendMessageW(hProgBar, 00121 PBM_SETSTEP, 00122 (WPARAM)1, 00123 0); 00124 } 00125 break; 00126 00127 case WM_COMMAND: 00128 switch(LOWORD(wParam)) 00129 { 00130 case IDOK: 00131 DestroyWindow(hDlg); 00132 break; 00133 00134 } 00135 break; 00136 00137 default: 00138 return FALSE; 00139 } 00140 00141 return TRUE; 00142 } 00143 00144 HWND 00145 CreateProgressDialog(HWND hParent, 00146 UINT LabelId) 00147 { 00148 HWND hProgDlg; 00149 LPWSTR lpProgStr; 00150 00151 /* open the progress dialog */ 00152 hProgDlg = CreateDialogW(hInstance, 00153 MAKEINTRESOURCEW(IDD_DLG_PROGRESS), 00154 hParent, 00155 ProgressDialogProc); 00156 if (hProgDlg != NULL) 00157 { 00158 /* Load the label Id */ 00159 if (AllocAndLoadString(&lpProgStr, 00160 hInstance, 00161 LabelId)) 00162 { 00163 /* Write it to the dialog */ 00164 SendDlgItemMessageW(hProgDlg, 00165 IDC_SERVCON_INFO, 00166 WM_SETTEXT, 00167 0, 00168 (LPARAM)lpProgStr); 00169 00170 HeapFree(GetProcessHeap(), 00171 0, 00172 lpProgStr); 00173 } 00174 } 00175 00176 return hProgDlg; 00177 } 00178 00179 BOOL 00180 DestroyProgressDialog(HWND hwnd, 00181 BOOL bComplete) 00182 { 00183 BOOL bRet = FALSE; 00184 00185 if (hwnd) 00186 { 00187 if (bComplete) 00188 { 00189 /* Complete the progress bar */ 00190 CompleteProgressBar(hwnd); 00191 00192 /* Wait, for asthetics */ 00193 Sleep(500); 00194 } 00195 00196 bRet = DestroyWindow(hwnd); 00197 } 00198 00199 return bRet; 00200 } Generated on Fri May 25 2012 04:15:19 for ReactOS by
1.7.6.1
|