- Revert 44301
[reactos.git] / base / applications / mscutils / servman / progress.c
1 /*
2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/mscutils/servman/progress.c
5 * PURPOSE: Progress dialog box message handler
6 * COPYRIGHT: Copyright 2006-2007 Ged Murphy <gedmurphy@reactos.org>
7 *
8 */
9
10 #include "precomp.h"
11
12 #define PROGRESSRANGE 20
13
14 VOID
15 CompleteProgressBar(HWND hProgDlg)
16 {
17 HWND hProgBar;
18
19 hProgBar = GetDlgItem(hProgDlg,
20 IDC_SERVCON_PROGRESS);
21
22 if (hProgBar)
23 {
24 INT pos = 0;
25
26 pos = SendMessage(hProgBar,
27 PBM_GETPOS,
28 0,
29 0);
30
31 for (; pos <= PROGRESSRANGE; pos++)
32 {
33 SendMessage(hProgBar,
34 PBM_DELTAPOS,
35 pos,
36 0);
37 Sleep(15);
38 }
39 }
40 }
41
42 VOID
43 IncrementProgressBar(HWND hProgDlg)
44 {
45 HWND hProgBar;
46
47 hProgBar = GetDlgItem(hProgDlg,
48 IDC_SERVCON_PROGRESS);
49
50 if (hProgBar)
51 {
52 SendMessage(hProgBar,
53 PBM_STEPIT,
54 0,
55 0);
56 }
57 }
58
59 INT_PTR CALLBACK
60 ProgressDialogProc(HWND hDlg,
61 UINT Message,
62 WPARAM wParam,
63 LPARAM lParam)
64 {
65 switch(Message)
66 {
67 case WM_INITDIALOG:
68 {
69 HWND hProgBar;
70
71 /* set the progress bar range and step */
72 hProgBar = GetDlgItem(hDlg,
73 IDC_SERVCON_PROGRESS);
74 SendMessage(hProgBar,
75 PBM_SETRANGE,
76 0,
77 MAKELPARAM(0, PROGRESSRANGE));
78
79 SendMessage(hProgBar,
80 PBM_SETSTEP,
81 (WPARAM)1,
82 0);
83 }
84 break;
85
86 case WM_COMMAND:
87 switch(LOWORD(wParam))
88 {
89 case IDOK:
90 DestroyWindow(hDlg);
91 break;
92
93 }
94 break;
95
96 default:
97 return FALSE;
98 }
99
100 return TRUE;
101
102 }
103
104 HWND
105 CreateProgressDialog(HWND hParent,
106 LPTSTR lpServiceName,
107 UINT Event)
108 {
109 HWND hProgDlg;
110 TCHAR ProgDlgBuf[100];
111
112 /* open the progress dialog */
113 hProgDlg = CreateDialog(hInstance,
114 MAKEINTRESOURCE(IDD_DLG_PROGRESS),
115 hParent,
116 ProgressDialogProc);
117 if (hProgDlg != NULL)
118 {
119 /* write the info to the progress dialog */
120 LoadString(hInstance,
121 Event,
122 ProgDlgBuf,
123 sizeof(ProgDlgBuf) / sizeof(TCHAR));
124
125 SendDlgItemMessage(hProgDlg,
126 IDC_SERVCON_INFO,
127 WM_SETTEXT,
128 0,
129 (LPARAM)ProgDlgBuf);
130
131 /* write the service name to the progress dialog */
132 SendDlgItemMessage(hProgDlg,
133 IDC_SERVCON_NAME,
134 WM_SETTEXT,
135 0,
136 (LPARAM)lpServiceName);
137 }
138
139 return hProgDlg;
140 }