1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #include "status/status.hh"
|
---|
10 |
|
---|
11 |
|
---|
12 | enum {MAX_UPDATES=100};
|
---|
13 |
|
---|
14 | class win32_status_class
|
---|
15 | {
|
---|
16 | public:
|
---|
17 | HWND hwndPB; // handle of progress bar
|
---|
18 |
|
---|
19 | int last_p;
|
---|
20 |
|
---|
21 | virtual i4_bool update(float percent)
|
---|
22 | {
|
---|
23 | int p=percent*MAX_UPDATES;
|
---|
24 | while (last_p!=p)
|
---|
25 | {
|
---|
26 | last_p++;
|
---|
27 | SendMessage(hwndPB, PBM_STEPIT, 0, 0);
|
---|
28 | }
|
---|
29 | }
|
---|
30 |
|
---|
31 | win32_status_class(HWND hwndPB) : hwndPB(hwndPB)
|
---|
32 | {
|
---|
33 | last_p=0;
|
---|
34 | }
|
---|
35 |
|
---|
36 | virtual ~i4_status_class()
|
---|
37 | {
|
---|
38 | DestroyWindow(hwndPB);
|
---|
39 | }
|
---|
40 | };
|
---|
41 |
|
---|
42 | // this is operating system dependant
|
---|
43 | i4_status_class *i4_create_status(const i4_const_str &description)
|
---|
44 | {
|
---|
45 | RECT rcClient; // client area of parent window
|
---|
46 | int cyVScroll; // height of scroll bar arrow
|
---|
47 | HWND hwndPB; // handle of progress bar
|
---|
48 | HANDLE hFile; // handle of file
|
---|
49 | DWORD cb; // size of file and count of bytes read
|
---|
50 | LPCH pch; // address of data read from file
|
---|
51 | LPCH pchTmp; // temporary pointer
|
---|
52 |
|
---|
53 | // Ensure that the common control DLL is loaded and create a
|
---|
54 | // progress bar along the bottom of the client area of the
|
---|
55 | // parent window. Base the height of the progress bar on
|
---|
56 | // the height of a scroll bar arrow.
|
---|
57 | InitCommonControls();
|
---|
58 |
|
---|
59 |
|
---|
60 | hwndPB = CreateWindowEx(0, PROGRESS_CLASS, (LPSTR) NULL,
|
---|
61 | WS_BORDER | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
62 | 320, 20,
|
---|
63 | 0, (HMENU) 0, i4_win32_instance, NULL);
|
---|
64 |
|
---|
65 |
|
---|
66 | // Set the range and increment of the progress bar.
|
---|
67 | SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0, MAX_UPDATES));
|
---|
68 | SendMessage(hwndPB, PBM_SETSTEP, (WPARAM) 1, 0);
|
---|
69 |
|
---|
70 | return new win32_status_class(hwndPB);
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 |
|
---|