Changeset 542
- Timestamp:
- 11/13/2008 12:20:40 PM (3 years ago)
- Location:
- branches/eraser6/Installer/Bootstrapper
- Files:
-
- 5 edited
-
Bootstrapper.cpp (modified) (3 diffs)
-
Bootstrapper.h (modified) (4 diffs)
-
Bootstrapper.vcproj (modified) (2 diffs)
-
Main.cpp (modified) (8 diffs)
-
stdafx.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Installer/Bootstrapper/Bootstrapper.cpp
r539 r542 114 114 if (srcFile == INVALID_HANDLE_VALUE) 115 115 throw GetErrorMessage(GetLastError()); 116 117 //Seek to the 128th kb.118 LARGE_INTEGER fPos;119 fPos.QuadPart = 0;120 116 #else 121 117 HANDLE srcFile = CreateFileW(Application::Get().GetPath().c_str(), GENERIC_READ, … … 126 122 //Seek to the 128th kb. 127 123 LARGE_INTEGER fPos; 128 fPos.QuadPart = 128 * 1024; 124 fPos.QuadPart = DataOffset; 125 126 if (!SetFilePointerEx(srcFile, fPos, &fPos, FILE_BEGIN)) 127 throw GetErrorMessage(GetLastError()); 129 128 #endif 130 131 if (!SetFilePointerEx(srcFile, fPos, &fPos, FILE_BEGIN))132 throw GetErrorMessage(GetLastError());133 129 134 130 //7z archive database structure … … 183 179 throw GetErrorMessage(GetLastError()); 184 180 destFileSize -= bytesWritten; 181 Application::Get().Yield(); 185 182 } 186 183 -
branches/eraser6/Installer/Bootstrapper/Bootstrapper.h
r541 r542 24 24 #include <windows.h> 25 25 #include <string> 26 #include <map> 26 27 27 28 #include "resource.h" 28 29 #undef Yield 30 #undef min 29 31 30 32 class MainWindow … … 60 62 private: 61 63 HWND hWnd; 64 HWND hWndPanel; 62 65 HWND hWndStatusLbl; 63 66 HWND hWndProgressBar; 64 67 HWND hWndCancelBtn; 68 69 struct WndProcData 70 { 71 WndProcData(WNDPROC oldWndProc, MainWindow& owner) 72 : OldWndProc(oldWndProc), Owner(&owner) 73 { 74 } 75 76 WNDPROC OldWndProc; 77 MainWindow* Owner; 78 }; 79 80 static std::map<HWND, WndProcData> OldWndProcs; 65 81 66 82 private: … … 69 85 70 86 /// Helper function to set the window font for created windows to the system default. 87 /// 88 /// \param[in] hWnd The window whose font needs to be set. 71 89 void SetWindowFont(HWND hWnd); 90 91 /// Handles messages from user interactions. 92 LRESULT WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, 93 bool& handled); 94 95 /// Subclasses the given window. 96 /// 97 /// \param[in] owner The owner of the window. 98 /// \param[in] hWnd The handle to the window to subclass. 99 /// \param[in] wndProc The window message processor. 100 static void SubclassWindow(MainWindow& owner, HWND hWnd, WNDPROC wndProc); 101 102 /// Processes messages for the main window. 103 static LRESULT __stdcall WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 72 104 }; 73 105 … … 96 128 }; 97 129 130 /// The offset where the package data is stored. 131 const unsigned DataOffset = 160 * 1024; 132 98 133 /// Formats the system error code using FormatMessage, returning the message as 99 134 /// a std::wstring. -
branches/eraser6/Installer/Bootstrapper/Bootstrapper.vcproj
r532 r542 61 61 <Tool 62 62 Name="VCLinkerTool" 63 AdditionalDependencies="comctl32.lib 7z_C .lib"63 AdditionalDependencies="comctl32.lib 7z_Cd.lib" 64 64 LinkIncremental="2" 65 65 GenerateDebugInformation="true" … … 134 134 <Tool 135 135 Name="VCLinkerTool" 136 AdditionalDependencies="comctl32.lib D:\Development\Libraries\C++\LZMA\C\Archive\7z\LzDecode.obj"136 AdditionalDependencies="comctl32.lib 7z_C.lib" 137 137 LinkIncremental="1" 138 138 GenerateDebugInformation="true" -
branches/eraser6/Installer/Bootstrapper/Main.cpp
r541 r542 50 50 : DirName(dirName) 51 51 { 52 //Ensure there is a trailing slash 52 53 if (std::wstring(L"\\/").find(dirName[dirName.length() - 1]) == std::wstring::npos) 53 54 dirName += L"\\"; 54 55 55 56 if (!CreateDirectoryW(dirName.c_str(), NULL)) 56 throw GetErrorMessage(GetLastError()); 57 switch (GetLastError()) 58 { 59 case ERROR_ALREADY_EXISTS: 60 DeleteContents(); 61 break; 62 63 default: 64 throw GetErrorMessage(GetLastError()); 65 } 57 66 } 58 67 59 68 ~TempDir() 69 { 70 DeleteContents(); 71 RemoveDirectoryW(DirName.c_str()); 72 } 73 74 private: 75 /// The path to the directory. 76 std::wstring DirName; 77 78 private: 79 void DeleteContents() 60 80 { 61 81 //Clean up the files in the directory. … … 73 93 //Clean up. 74 94 FindClose(findHandle); 75 RemoveDirectoryW(DirName.c_str());76 95 } 77 78 private:79 std::wstring DirName;80 96 }; 81 82 /// Processes messages for the main window.83 ///84 /// Current messages processed:85 /// WM_COMMAND - process the application menu86 /// WM_PAINT - Paint the main window87 /// WM_DESTROY - post a quit message and return88 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)89 {90 switch (message)91 {92 case WM_COMMAND:93 {94 /*int wmId = LOWORD(wParam);95 switch (wmId)96 {97 default:98 99 }*/100 return DefWindowProc(hWnd, message, wParam, lParam);101 }102 103 case WM_DESTROY:104 PostQuitMessage(0);105 break;106 107 default:108 return DefWindowProc(hWnd, message, wParam, lParam);109 }110 111 return 0;112 }113 97 } 114 98 … … 191 175 } 192 176 177 std::map<HWND, MainWindow::WndProcData> MainWindow::OldWndProcs; 193 178 bool MainWindow::Create() 194 179 { … … 196 181 return false; 197 182 198 HWNDhWndPanel = CreateWindowExW(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE,183 hWndPanel = CreateWindowExW(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE, 199 184 0, 0, 294, 104, hWnd, NULL, hInstance, NULL); 200 185 hWndStatusLbl = CreateWindowExW(0, STATIC_CLASS, L"Extracting setup files...", … … 213 198 SetWindowFont(hWndProgressBar); 214 199 SetWindowFont(hWndCancelBtn); 200 215 201 SendMessage(hWndProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000)); 202 SubclassWindow(*this, hWndCancelBtn, WndProc); 203 SubclassWindow(*this, hWndPanel, WndProc); 216 204 217 205 ShowWindow(hWnd, SW_SHOWDEFAULT); … … 281 269 void MainWindow::SetProgress(float progress) 282 270 { 283 SetWindowLong (hWndProgressBar, GWL_STYLE,284 GetWindowLong (hWndProgressBar, GWL_STYLE) & (~PBS_MARQUEE));271 SetWindowLongPtr(hWndProgressBar, GWL_STYLE, 272 GetWindowLongPtr(hWndProgressBar, GWL_STYLE) & (~PBS_MARQUEE)); 285 273 SendMessage(hWndProgressBar, PBM_SETPOS, (int)(progress * 1000), 0); 286 274 } … … 288 276 void MainWindow::SetProgressIndeterminate() 289 277 { 290 SetWindowLong (hWndProgressBar, GWL_STYLE,291 GetWindowLong (hWndProgressBar, GWL_STYLE) | PBS_MARQUEE);278 SetWindowLongPtr(hWndProgressBar, GWL_STYLE, 279 GetWindowLongPtr(hWndProgressBar, GWL_STYLE) | PBS_MARQUEE); 292 280 SendMessage(hWndProgressBar, PBM_SETMARQUEE, true, 100); 293 281 } … … 296 284 { 297 285 SetWindowTextW(hWndStatusLbl, message.c_str()); 286 } 287 288 LRESULT MainWindow::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, 289 bool& handled) 290 { 291 handled = false; 292 switch (message) 293 { 294 case WM_COMMAND: 295 if (hWnd == hWndCancelBtn && HIWORD(wParam) == BN_CLICKED) 296 PostQuitMessage(1); 297 break; 298 } 299 } 300 301 void MainWindow::SubclassWindow(MainWindow& owner, HWND hWnd, WNDPROC wndProc) 302 { 303 OldWndProcs.insert(std::make_pair( 304 hWnd, WndProcData(reinterpret_cast<WNDPROC>(SetWindowLongPtr(hWnd, 305 GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(wndProc))), owner) 306 )); 307 } 308 309 LRESULT __stdcall MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 310 { 311 std::map<HWND, WndProcData>::const_iterator iter = OldWndProcs.find(hWnd); 312 if (iter != OldWndProcs.end()) 313 { 314 bool handled = false; 315 LRESULT result = iter->second.Owner->WindowProc(hWnd, message, wParam, 316 lParam, handled); 317 if (handled) 318 return result; 319 320 return CallWindowProc(iter->second.OldWndProc, hWnd, message, wParam, lParam); 321 } 322 323 switch (message) 324 { 325 case WM_DESTROY: 326 PostQuitMessage(0); 327 break; 328 329 default: 330 return DefWindowProc(hWnd, message, wParam, lParam); 331 } 332 333 return 0; 298 334 } 299 335 -
branches/eraser6/Installer/Bootstrapper/stdafx.h
r532 r542 31 31 #include <windows.h> 32 32 #include <commctrl.h> 33 #undef min34 33 35 34 #include <tchar.h> 36 35 #include <string> 36 #include <map> 37 37 38 38 //7-zip SDK
Note: See TracChangeset
for help on using the changeset viewer.
