source: trunk/gsinstaller/copyProgress.cpp@ 2500

Last change on this file since 2500 was 2073, checked in by sjboddie, 23 years ago

minor mods. changed some occurances of bool, true, and false to BOOL, TRUE
and FALSE in copyProgress.cpp (for VC++4.2) and changed all references to
gsdl.ini to instead point at gsdlsite.cfg.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1#include "copyProgress.h"
2
3#include <windows.h>
4#include <commctrl.h>
5
6#include <stdio.h>
7
8extern HINSTANCE app_instance;
9extern void gsInstall_getDesktopExt(int *x, int *y);
10
11LRESULT CALLBACK copyProgressBar_windowProc(HWND window, UINT message,
12 WPARAM wParam, LPARAM lParam)
13{
14 switch (message)
15 {
16 case WM_CREATE:
17 {
18 CREATESTRUCT *createStruct = (CREATESTRUCT *) lParam;
19 long *createParams;
20 copyProgressBar *progressBar;
21
22 createParams = (long *) createStruct->lpCreateParams;
23
24 SetWindowLong(window, GWL_USERDATA, createParams[0]);
25 progressBar = (copyProgressBar *) GetWindowLong(window, GWL_USERDATA);
26 if (progressBar == NULL)
27 {
28 MessageBox(0, "A", "A", MB_OK);
29 }
30
31 CreateWindowEx( 0, "STATIC", (char *) createParams[1], WS_CHILD | WS_VISIBLE,
32 10, 5, 180, 20, window, (HMENU) 0,
33 app_instance, NULL);
34 }
35 break;
36
37 default:
38 return(DefWindowProc(window, message, wParam, lParam));
39 }
40
41 return 0;
42}
43
44void copyProgressBar::registerClass()
45{ static BOOL registered = FALSE;
46
47 if (registered == FALSE)
48 { WNDCLASS classdef;
49
50 classdef.style = 0;
51 classdef.lpfnWndProc = copyProgressBar_windowProc;
52 classdef.cbClsExtra = 0;
53 classdef.cbWndExtra = sizeof(copyProgressBar *) + sizeof(long);
54 classdef.hInstance = app_instance;
55 classdef.hIcon = 0;
56 classdef.hCursor = NULL;
57 classdef.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
58 classdef.lpszMenuName = NULL;
59 classdef.lpszClassName = "CopyProgressBar";
60 RegisterClass(&classdef);
61 registered = TRUE;
62 }
63}
64
65copyProgressBar::copyProgressBar(unsigned long totalSize)
66{ this->total = totalSize;
67 this->copied = 0;
68}
69
70copyProgressBar::copyProgressBar()
71{ this->total = 0;
72 this->copied = 0;
73}
74
75void copyProgressBar::init(unsigned long totalSize)
76{ this->total = totalSize;
77 this->copied = 0;
78}
79
80void copyProgressBar::done(unsigned long bytesDone)
81{ unsigned int percent;
82 this->copied += bytesDone;
83
84 percent =(this->copied * 100 / this->total);
85
86 SendMessage(this->progressBar, PBM_SETPOS, percent, 0L);
87}
88
89void copyProgressBar::show()
90{ long params[2];
91 int sx, sy, dx, dy;
92
93 params[0] = (long) this;
94 params[1] = (long) "Copying files....";
95 this->registerClass();
96
97 gsInstall_getDesktopExt(&sx, &sy);
98
99 dx = (sx - 200) >> 1;
100 dy = (sy - 80) >> 1;
101
102
103 this->progressParent = CreateWindowEx( WS_EX_APPWINDOW, "CopyProgressBar",
104 "GreenStone Installer", WS_VISIBLE,
105 dx, dy, 200, 80,
106 0, (HMENU) 0,
107 app_instance, (void *) params);
108 this->progressBar = CreateWindowEx(0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE,
109 10, 30, 180, GetSystemMetrics(SM_CYVSCROLL),
110 this->progressParent, (HMENU) 0,
111 app_instance, NULL);
112}
113
114void copyProgressBar::close()
115{ // return;
116 ShowWindow(this->progressBar, SW_HIDE);
117 DestroyWindow(this->progressBar);
118
119 ShowWindow(this->progressParent, SW_HIDE);
120 DestroyWindow(this->progressParent);
121}
122
Note: See TracBrowser for help on using the repository browser.