added: Checking for update dialog box

git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@216 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2009-10-17 22:13:14 +00:00
parent 8fa1a24350
commit fb04d22d14
12 changed files with 877 additions and 72 deletions

View File

@ -1,5 +1,6 @@
Version 0.9.0 prerelease (2009.09.16):
Version 0.9.0 prerelease (2009.09.17):
* added: Pad window - a multiline edit window
* added: Checking for update
* changed: precision:
Medium - 512 mantissa, 64 exponent
Big - 1024 mantissa, 128 exponent

View File

@ -18,7 +18,7 @@ include Makefile.dep
ttcalc: $(o)
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32
$(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32 -lwininet
resource.o: resource.rc

View File

@ -1,15 +1,17 @@
o = resource.o calculation.o convert.o functions.o iniparser.o languages.o mainwindow.o pad.o parsermanager.o programresources.o tabs.o variables.o winmain.o
o = resource.o calculation.o convert.o download.o functions.o iniparser.o languages.o mainwindow.o pad.o parsermanager.o programresources.o tabs.o update.o variables.o winmain.o
calculation.o: calculation.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h tabs.h messages.h
convert.o: convert.cpp convert.h compileconfig.h bigtypes.h
download.o: download.cpp download.h
functions.o: functions.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
iniparser.o: iniparser.cpp compileconfig.h iniparser.h
languages.o: languages.cpp compileconfig.h languages.h bigtypes.h
mainwindow.o: mainwindow.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h pad.h
mainwindow.o: mainwindow.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h pad.h update.h download.h
pad.o: pad.cpp programresources.h compileconfig.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h
parsermanager.o: parsermanager.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h tabs.h messages.h
programresources.o: programresources.cpp compileconfig.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
tabs.o: tabs.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
update.o: update.cpp update.h download.h programresources.h compileconfig.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h messages.h resource.h winmain.h tabs.h pad.h
variables.o: variables.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
winmain.o: winmain.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h pad.h

148
src/download.cpp Normal file
View File

@ -0,0 +1,148 @@
/*
* This file is a part of TTCalc - a mathematical calculator
* and is distributed under the (new) BSD licence.
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "download.h"
Download::Download()
{
buffer_len = 512;
progress = 0;
buffer = new char[buffer_len];
}
Download::~Download()
{
if( buffer )
delete [] buffer;
}
void Download::SetProgress()
{
if( !progress )
return;
SendMessage(progress, PBM_SETRANGE32, 0, all_len);
SendMessage(progress, PBM_SETPOS, 0, 0);
}
void Download::ChangeProgress(size_t size)
{
if( !progress )
return;
SendMessage(progress, PBM_SETPOS, size, 0);
}
void Download::ClearProgress()
{
if( !progress )
return;
SendMessage(progress, PBM_SETPOS, 0, 0);
}
bool Download::DownloadUrl(const char * url)
{
DWORD read;
bool res = true;
size_t down_size = 0;
HINTERNET hint = InternetOpen("TTCalcDownload",INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0);
if( !hint )
return false;
HINTERNET conn = InternetOpenUrl(hint, url, 0, 0,
INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_UI, 0);
if( conn )
{
GetLen(conn);
SetProgress();
if( Init() )
{
while( InternetReadFile(conn, buffer, buffer_len, &read) && read > 0 )
{
down_size += read;
ChangeProgress(down_size);
if( !Read(buffer, read) )
{
res = false;
break;
}
}
Close();
ClearProgress();
}
InternetCloseHandle(conn);
}
else
{
res = false;
}
InternetCloseHandle(hint);
return res;
}

71
src/download.h Normal file
View File

@ -0,0 +1,71 @@
/*
* This file is a part of TTCalc - a mathematical calculator
* and is distributed under the (new) BSD licence.
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef headerfiledownload
#define headerfiledownload
#include <windows.h>
#include <wininet.h>
#include <commctrl.h>
class Download
{
public:
Download();
~Download();
bool DownloadUrl(const char * url);
void AttachProgress(HWND p) { progress = p; }
protected:
virtual void GetLen(HINTERNET conn) { all_len = 0; }
virtual bool Init() { return false; }
virtual bool Read(char * buffer, size_t size) { return false; }
virtual void Close() {}
virtual void SetProgress();
virtual void ChangeProgress(size_t size);
virtual void ClearProgress();
char * buffer;
size_t buffer_len;
size_t all_len;
HWND progress;
};
#endif

View File

@ -37,7 +37,7 @@
#include "compileconfig.h"
#include "winmain.h"
#include "update.h"
@ -915,6 +915,16 @@ return true;
}
BOOL WmCommand_HelpCheckUpdate(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
ShowUpdateDialog(hWnd);
return true;
}
BOOL WmCommand_NewWindow(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
STARTUPINFO si;
@ -1178,6 +1188,7 @@ void CreateCommandMessagesTable(Messages<BOOL> & cmessages)
cmessages.Associate(IDM_COMPACT_VIEW, WmCommand_CompactView);
cmessages.Associate(IDM_PAD, WmCommand_Pad);
cmessages.Associate(IDM_HELP_ABOUT, WmCommand_HelpAbout);
cmessages.Associate(IDM_HELP_CHECK_UPDATE, WmCommand_HelpCheckUpdate);
cmessages.Associate(IDM_NEW_WINDOW, WmCommand_NewWindow);
cmessages.Associate(IDM_CLOSE_PROGRAM, WmCommand_CloseProgram);
cmessages.Associate(IDC_INPUT_EDIT, WmCommand_InputEditNotify);

View File

@ -50,6 +50,7 @@
#define IDD_MAIN_DIALOG 101
#define IDD_ABOUT_DIALOG 200
#define IDD_UPDATE_DIALOG 210
#define IDD_DIALOG_ADD_VARIABLE 102
#define IDD_DIALOG_ADD_FUNCTION 103
@ -206,10 +207,16 @@
#define IDM_EDIT_COPY_RESULT 40032
#define IDM_HELP_HELP 40040
#define IDM_HELP_PROJECT_PAGE 40041
#define IDM_HELP_CHECK_UPDATE 40042
#define IDM_HELP_ABOUT 40049
// about dialog
#define IDC_ABOUT_TEXT 1200
#define IDB_BITMAP_ABOUT 1201
// update dialog
#define IDC_UPDATE_INFO1 1300
#define IDC_PROGRESS 1301
#endif

View File

@ -49,6 +49,7 @@ BEGIN
BEGIN
MENUITEM "&Help", 40040
MENUITEM "&Project page", 40041
MENUITEM "&Check update...", 40042
MENUITEM SEPARATOR
MENUITEM "&About", 40049
END
@ -282,6 +283,20 @@ BEGIN
END
#endif
IDD_UPDATE_DIALOG DIALOG DISCARDABLE 0, 0, 256, 86
STYLE DS_MODALFRAME | WS_POPUP
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "Checking for update",IDC_UPDATE_INFO1,"Static",SS_LEFTNOWORDWRAP |
WS_GROUP,7,14,242,8
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,
7,33,242,14
DEFPUSHBUTTON "Next",IDOK,146,65,50,14
PUSHBUTTON "Cancel",IDCANCEL,199,65,50,14
END
#ifndef TTCALC_PORTABLE
1201 BITMAP "..\\res\\abacus_01.bmp"

452
src/update.cpp Normal file
View File

@ -0,0 +1,452 @@
/*
* This file is a part of TTCalc - a mathematical calculator
* and is distributed under the (new) BSD licence.
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstdlib>
#include "update.h"
#include "programresources.h"
#include "messages.h"
#include "resource.h"
#include "winmain.h"
namespace Update
{
bool continue_download;
int level;
std::string url;
std::string download_file_name;
int major;
int minor;
int revision;
}
/*
*/
DownloadIni::DownloadIni()
{
file = 0;
file_name = new char[MAX_PATH];
file_name[0] = 0;
}
DownloadIni::~DownloadIni()
{
if( file )
fclose(file);
DeleteTmpFile();
delete [] file_name;
}
void DownloadIni::DeleteTmpFile()
{
if( file_name[0] != 0 )
DeleteFile(file_name);
}
const char * DownloadIni::GetFileName()
{
return file_name;
}
FILE * DownloadIni::CreateTmpFile()
{
char buf[MAX_PATH];
file = 0;
file_name[0] = 0;
if( !GetTempPath(MAX_PATH, buf) )
return 0;
if( !GetTempFileName(buf, "ttcalc_", 0, file_name) )
{
file_name[0] = 0;
return 0;
}
file = fopen(file_name, "wb");
return file;
}
void DownloadIni::GetLen(HINTERNET conn)
{
char buf[100];
DWORD buf_len = sizeof(buf);
DWORD index = 0;
if( HttpQueryInfo(conn, HTTP_QUERY_CONTENT_LENGTH, buf, &buf_len, &index) )
all_len = atoi(buf);
else
all_len = 0;
}
bool DownloadIni::Init()
{
if( !CreateTmpFile() )
return false;
Update::continue_download = true;
return true;
}
bool DownloadIni::Read(char * buffer, size_t size)
{
if( !file )
return false;
fwrite(buffer, size, 1, file);
CheckMessages();
return Update::continue_download;
}
void DownloadIni::Close()
{
if( file )
fclose(file);
file = 0;
}
/*
*/
void DownloadProgram::GetLen(HINTERNET conn)
{
char buf[100];
DWORD buf_len = sizeof(buf);
DWORD index = 0;
if( HttpQueryInfo(conn, HTTP_QUERY_CONTENT_LENGTH, buf, &buf_len, &index) )
all_len = atoi(buf);
else
all_len = 0;
}
bool DownloadProgram::Init()
{
file.open(Update::download_file_name.c_str(), std::ios_base::out | std::ios_base::binary);
Update::continue_download = true;
if( !file )
return false;
return true;
}
bool DownloadProgram::Read(char * buffer, size_t size)
{
file.write(buffer, size);
CheckMessages();
return Update::continue_download;
}
void DownloadProgram::Close()
{
file.close();
}
namespace Update
{
/*
*/
bool CheckUpdateFromIni(HWND hwnd)
{
DownloadIni down_ini;
down_ini.AttachProgress(GetDlgItem(hwnd, IDC_PROGRESS));
if( down_ini.DownloadUrl("http://ttcalc.sourceforge.net/ttcalc.ini") )
{
IniParser iparser;
std::string ini_value[3];
iparser.SectionCaseSensitive(false);
iparser.Associate( "normal|url", &url );
iparser.Associate( "normal|version.major", &ini_value[0] );
iparser.Associate( "normal|version.minor", &ini_value[1] );
iparser.Associate( "normal|version.revision", &ini_value[2] );
IniParser::Error err = iparser.ReadFromFile( down_ini.GetFileName() );
if( err == IniParser::err_ok )
{
major = atoi(ini_value[0].c_str());
minor = atoi(ini_value[1].c_str());
revision = atoi(ini_value[2].c_str());
if( major > TTCALC_MAJOR_VER )
return true;
else
if( major == TTCALC_MAJOR_VER && minor > TTCALC_MINOR_VER )
return true;
else
if( major == TTCALC_MAJOR_VER && minor == TTCALC_MINOR_VER && revision > TTCALC_REVISION_VER )
return true;
}
}
return false;
}
void CheckUpdate(HWND hwnd)
{
char buffer[200];
EnableWindow(GetDlgItem(hwnd, IDOK), false);
EnableWindow(GetDlgItem(hwnd, IDC_UPDATE_INFO1), false);
if( CheckUpdateFromIni(hwnd) )
{
level = 1;
sprintf(buffer, "Version %d.%d.%d is available, press Next to download...", major, minor, revision);
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, buffer);
}
else
{
level = 100;
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, "There is not a new version available.");
SetDlgItemText(hwnd, IDOK, "Finish");
ShowWindow(GetDlgItem(hwnd, IDC_PROGRESS), SW_HIDE);
EnableWindow(GetDlgItem(hwnd, IDCANCEL), false);
}
EnableWindow(GetDlgItem(hwnd, IDOK), true);
EnableWindow(GetDlgItem(hwnd, IDC_UPDATE_INFO1), true);
}
bool SaveDialog(HWND hwnd)
{
OPENFILENAME o;
char buf[MAX_PATH];
strcpy(buf, "TTCalc_setup.exe");
o.lStructSize = sizeof(o);
o.hwndOwner = hwnd;
o.hInstance = GetPrgRes()->GetInstance();
o.lpstrFilter = "*.*\0*.*\0";
o.lpstrCustomFilter = 0;
o.nMaxCustFilter = 0;
o.nFilterIndex = 1;
o.lpstrFile = buf;
o.nMaxFile = MAX_PATH;
o.lpstrFileTitle = 0;
o.nMaxFileTitle = 0;
o.lpstrInitialDir = 0; // dac pulpit
o.lpstrTitle = 0;
o.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
o.nFileOffset = 0;
o.nFileExtension = 0;
o.lpstrDefExt = 0;
o.lCustData = 0;
o.lpfnHook = 0;
o.lpTemplateName = 0;
if( GetSaveFileName(&o) )
{
download_file_name = buf;
return true;
}
return false;
}
bool DownloadUpdate(HWND hwnd)
{
DownloadProgram down;
char buf[300];
EnableWindow(GetDlgItem(hwnd, IDOK), false);
if( SaveDialog(hwnd) )
{
_snprintf(buf, 100, "Downloading: %s", url.c_str());
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, buf);
down.AttachProgress(GetDlgItem(hwnd, IDC_PROGRESS));
if( down.DownloadUrl( url.c_str()) )
{
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, "File has been correctly saved.");
}
else
{
DeleteFile(download_file_name.c_str());
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, "There was a problem with downloading, please try again later");
}
ShowWindow(GetDlgItem(hwnd, IDC_PROGRESS), SW_HIDE);
SetDlgItemText(hwnd, IDOK, "Finish");
level = 100;
}
EnableWindow(GetDlgItem(hwnd, IDOK), true);
EnableWindow(GetDlgItem(hwnd, IDCANCEL), false);
return false;
}
BOOL UpdateInit(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, "Press Next to check for the update...");
SetDlgItemText(hwnd, IDOK, "Next");
SetDlgItemText(hwnd, IDCANCEL, "Cancel");
return true;
}
BOOL UpdateCommand(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if( LOWORD(wParam) == IDCANCEL )
{
continue_download = false;
EndDialog(hwnd, 0);
return 0;
}
if( LOWORD(wParam) == IDOK )
{
switch(level)
{
case 0:
CheckUpdate(hwnd);
break;
case 1:
DownloadUpdate(hwnd);
break;
case 100:
EndDialog(hwnd, 0);
break;
}
return 0;
}
return 1;
}
void CreateUpdateMessagesTable(Messages<BOOL> & messages)
{
messages.Associate(WM_INITDIALOG, UpdateInit);
messages.Associate(WM_COMMAND, UpdateCommand);
}
BOOL CALLBACK UpdateProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static Messages<BOOL> messages;
if( messages.Empty() )
// initiation
CreateUpdateMessagesTable(messages);
return messages.Call(msg, hwnd, msg, wParam, lParam);
}
} // namespace
void ShowUpdateDialog(HWND hwnd)
{
using namespace Update;
level = 0;
download_file_name.clear();
DialogBox(GetPrgRes()->GetInstance(), MAKEINTRESOURCE(IDD_UPDATE_DIALOG), hwnd, UpdateProc);
}

83
src/update.h Normal file
View File

@ -0,0 +1,83 @@
/*
* This file is a part of TTCalc - a mathematical calculator
* and is distributed under the (new) BSD licence.
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
*/
/*
* Copyright (c) 2006-2009, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef headerfileupdate
#define headerfileupdate
#include <windows.h>
#include <fstream>
#include <cstdio>
#include "download.h"
void ShowUpdateDialog(HWND hwnd);
class DownloadIni : public Download
{
public:
DownloadIni();
~DownloadIni();
void DeleteTmpFile();
const char * GetFileName();
private:
FILE * CreateTmpFile();
virtual void GetLen(HINTERNET conn);
virtual bool Init();
virtual bool Read(char * buffer, size_t size);
virtual void Close();
char * file_name;
FILE * file;
};
class DownloadProgram : public Download
{
virtual void GetLen(HINTERNET conn);
virtual bool Init();
virtual bool Read(char * buffer, size_t size);
virtual void Close();
std::ofstream file;
};
#endif

View File

@ -128,16 +128,9 @@ return static_cast<int>( error_code );
/*!
the main loop of messages
*/
void MainMessagesLoop()
void SendMessage(MSG & msg)
{
MSG msg;
while( GetMessage(&msg,0,0,0) )
{
bool sent = false;
bool sent = false;
// if there's CTRL+C or CTRL+V pressed we're trying to copy
// a result from the output edit or trying to paste something from the clipboard
@ -192,10 +185,32 @@ MSG msg;
DispatchMessage(&msg);
}
}
}
}
/*!
the main loop of messages
*/
void MainMessagesLoop()
{
MSG msg;
while( GetMessage(&msg,0,0,0) )
SendMessage(msg);
}
void CheckMessages()
{
MSG msg;
while( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) )
SendMessage(msg);
}
/*!
the window-procedure for the main window
*/

View File

@ -60,7 +60,7 @@ BOOL CALLBACK MainWindowProc(HWND hWnd, UINT messge, WPARAM wParam, LPARAM lPara
unsigned __stdcall CalculationsProcedure(void *);
int ShowError( Languages::GuiMsg error_code );
void MainMessagesLoop();
void CheckMessages();
namespace MainWindowFunctions
{