source: golgotha/src/i4/status/win_status.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 14 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.1 KB
Line 
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
12enum {MAX_UPDATES=100};
13
14class win32_status_class
15{
16public:
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
43i4_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
Note: See TracBrowser for help on using the repository browser.