145 lines
3.9 KiB
C++
145 lines
3.9 KiB
C++
//---------------------------------------------------------------------------
|
|
|
|
#include <vcl.h>
|
|
#pragma hdrstop
|
|
#include "GlobalUnit.h"
|
|
#include "UpdateFormUnit.h"
|
|
//---------------------------------------------------------------------------
|
|
#pragma package(smart_init)
|
|
#pragma link "PNGButton"
|
|
#pragma resource "*.dfm"
|
|
TUpdateForm *UpdateForm;
|
|
|
|
//---------------------------------------------------------------------------
|
|
__fastcall TUpdateForm::TUpdateForm(TComponent* Owner)
|
|
: TForm(Owner)
|
|
{
|
|
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TUpdateForm::FormCreate(TObject *Sender)
|
|
{
|
|
SetTransparent( this );
|
|
// Left = Screen->Width / 2 - Width / 2;
|
|
// Top = Screen->Height / 2 - Height / 2;
|
|
HRGN hRgn = CreateRoundRectRgn(0, 0, Width + 1, Height + 1, 20, 20);
|
|
SetWindowRgn(Handle, hRgn, TRUE);
|
|
DeleteObject(hRgn);
|
|
ShowMSG();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TUpdateForm::WMNCHitTest(TWMNCHitTest &Msg) {
|
|
TForm::Dispatch(&Msg);
|
|
|
|
if (Msg.Result == HTCLIENT && Msg.XPos > Left + 10 && Msg.XPos <
|
|
Left + Width - 20 && Msg.YPos < Top + 24)
|
|
Msg.Result = HTCAPTION;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void TUpdateForm::ShowMSG()
|
|
{
|
|
TRect rtDownload;
|
|
String strNew;
|
|
strNew.sprintf( L"最新版本:%d.%d.%d.%d",
|
|
g_infoSoftwareUpdate.version.majorVersion,
|
|
g_infoSoftwareUpdate.version.minorVersion,
|
|
g_infoSoftwareUpdate.version.modifyVersion,
|
|
g_infoSoftwareUpdate.version.buildVersion );
|
|
|
|
if( g_infoSoftwareUpdate.version.majorVersion==0 )
|
|
strNew += L" 测试版";
|
|
else
|
|
strNew += L" 正式版";
|
|
|
|
m_lbNewVer->Caption = strNew.c_str();
|
|
|
|
int wMaj, wMin, wMod, wBld;
|
|
sscanf( g_strCurrentVersion, "%d.%d.%d.%d", &wMaj, &wMin, &wMod, &wBld );
|
|
string strCurrent = "当前版本:";
|
|
strCurrent += g_strCurrentVersion;
|
|
|
|
if( wMaj==0 )
|
|
strCurrent += " 测试版";
|
|
else
|
|
strCurrent += " 正式版";
|
|
|
|
m_lbCurrentVer->Caption = strCurrent.c_str();
|
|
|
|
string sDescribe = UTF8ToMBCS( g_infoSoftwareUpdate.strDescribe );
|
|
String strResource = sDescribe.c_str();
|
|
String strTemp;
|
|
int ibg = 1;
|
|
int i = 1;
|
|
for( i = 1; i < strResource.Length(); i++){
|
|
if(strResource[i]=='\n'){
|
|
if(i!=ibg){
|
|
strTemp = strResource.SubString(ibg,i-ibg);
|
|
m_lbUpdateMsg->Items->Add(strTemp);
|
|
}else{
|
|
strTemp = "\n" ;
|
|
m_lbUpdateMsg->Items->Add(strTemp);
|
|
}
|
|
ibg = i+1;
|
|
}
|
|
}
|
|
|
|
if(i > ibg){
|
|
strTemp = strResource.SubString(ibg,i-ibg+1);
|
|
m_lbUpdateMsg->Items->Add(strTemp);
|
|
}
|
|
|
|
if( g_bUpdateMandatory ){
|
|
m_lbDownloadMsg->Font->Color = clRed;
|
|
m_lbDownloadMsg->Caption = "当前版本下,用户将无法进行登录\n账号和全曲操作,建议升级到最新\n版本。" ;
|
|
}
|
|
else{
|
|
m_lbDownloadMsg->Font->Color = clBlack;
|
|
m_lbDownloadMsg->Top += 5;
|
|
m_lbDownloadMsg->Caption = "新的版本已发布,建议立即更新。" ;
|
|
|
|
}
|
|
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
void __fastcall TUpdateForm::m_lbDownloadMouseEnter(TObject *Sender)
|
|
{
|
|
Screen->Cursor = crHandPoint;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TUpdateForm::m_lbDownloadMouseLeave(TObject *Sender)
|
|
{
|
|
Screen->Cursor = crDefault;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TUpdateForm::m_lbDownloadClick(TObject *Sender)
|
|
{
|
|
char strURL[256];
|
|
f_CS_GetWebPageURL( URL_SOFTWARE, strURL );
|
|
strcat( strURL, "?id=2&os=pc" );
|
|
|
|
ShellExecute(Handle,NULL, ((String)strURL).c_str(), NULL,NULL,SW_SHOWNORMAL);
|
|
Close();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TUpdateForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
|
|
{
|
|
switch( Key ){
|
|
case VK_RETURN:
|
|
return m_lbDownloadClick(NULL);
|
|
break;
|
|
|
|
case VK_ESCAPE:
|
|
ModalResult = mrCancel;
|
|
break;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|