139 lines
3.5 KiB
C++
139 lines
3.5 KiB
C++
//---------------------------------------------------------------------------
|
|
#include <vcl.h>
|
|
#pragma hdrstop
|
|
|
|
#include "GlobalUnit.h"
|
|
#include "VerifyThreadUnit.h";
|
|
#include "VerifyFormUnit.h"
|
|
|
|
#define OPERATION_MM_SAVE 1
|
|
#define OPERATION_MM_LOAD 2
|
|
#define OPERATION_PROJ_LOAD 3
|
|
#define OPERATION_PROJ_SAVE 4
|
|
|
|
//---------------------------------------------------------------------------
|
|
#pragma package(smart_init)
|
|
#pragma link "PNGButton"
|
|
#pragma resource "*.dfm"
|
|
TVerifyForm *VerifyForm;
|
|
|
|
//---------------------------------------------------------------------------
|
|
__fastcall TVerifyForm::TVerifyForm(TComponent* Owner)
|
|
: TForm(Owner)
|
|
{
|
|
m_lblCaption->Font->Color = RGB(60,43,23);
|
|
m_nMaxPos = m_pbProgress->Width;
|
|
m_nPos = 0;
|
|
|
|
m_bmpTileLeft = new TBitmap();
|
|
m_bmpTileLeft->LoadFromResourceName(int(HInstance), L"ProgressLeft");
|
|
m_bmpTileRight = new TBitmap();
|
|
m_bmpTileRight->LoadFromResourceName(int(HInstance), L"ProgressRight");
|
|
|
|
m_nTileWidth = m_bmpTileLeft->Width;
|
|
m_nTileHeight = m_bmpTileLeft->Height;
|
|
|
|
m_nNextMinPos = 0;
|
|
m_nNextMaxPos = m_nMaxPos;
|
|
|
|
m_pThread = new TVerifyThread( true, this );
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
__fastcall TVerifyForm::~TVerifyForm()
|
|
{
|
|
if( m_pThread )
|
|
delete m_pThread;
|
|
|
|
if( m_bmpTileLeft )
|
|
delete m_bmpTileLeft;
|
|
|
|
if( m_bmpTileRight )
|
|
delete m_bmpTileRight;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TVerifyForm::WMNCHitTest(TWMNCHitTest &Msg)
|
|
{
|
|
TForm::Dispatch(&Msg);
|
|
|
|
if( Msg.Result==HTCLIENT && Msg.YPos<Top+24 )
|
|
Msg.Result = HTCAPTION;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TVerifyForm::ProgressPaint(TObject *Sender)
|
|
{
|
|
int x = 0;
|
|
//×ó²àƽÆÌ
|
|
if( m_nPos>0 ){
|
|
for( int i=0; i<m_nPos/m_nTileWidth+1; i++ ){
|
|
m_pbProgress->Canvas->Draw( x+m_nTileWidth*i, 0, m_bmpTileLeft );
|
|
}
|
|
x += m_nTileWidth;
|
|
}
|
|
|
|
//ÓÒ²àÆ½ÆÌ
|
|
x = m_nPos;
|
|
if( m_nPos<m_nMaxPos ){
|
|
for( int i=0; i<(m_nMaxPos-m_nPos)/m_nTileWidth+1; i++ ){
|
|
m_pbProgress->Canvas->Draw( x+m_nTileWidth*i, 0, m_bmpTileRight );
|
|
}
|
|
x += m_nTileWidth;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TVerifyForm::UMOperateFailed(TMessage &Message)
|
|
{
|
|
m_pThread->Terminate();
|
|
ModalResult = Message.WParam;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TVerifyForm::UMOperatePercent(TMessage &Message)
|
|
{
|
|
TRect rcRedraw( m_nPos, 0, m_nMaxPos, m_nTileHeight );
|
|
m_nPos = m_nNextMinPos + Message.WParam * (m_nNextMaxPos - m_nNextMinPos) / 100;
|
|
|
|
rcRedraw.right = m_nPos;
|
|
|
|
// m_pbProgress->Invalidate();
|
|
InvalidateRect( m_panelProgress->Handle, &rcRedraw, false );
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TVerifyForm::UMOperateComplete(TMessage &Message)
|
|
{
|
|
m_pThread->Terminate();
|
|
ModalResult = mrOk;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TVerifyForm::FormCreate(TObject *Sender)
|
|
{
|
|
//»æÖÆÔ²½Ç´°Ìå
|
|
HRGN hRgn = CreateRoundRectRgn( 0, 0, Width+1, Height+2, 20, 20 );
|
|
SetWindowRgn( Handle, hRgn, false );
|
|
DeleteObject( hRgn );
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TVerifyForm::Operation()
|
|
{
|
|
switch( m_iOperation ){
|
|
case OPERATION_MM_SAVE:
|
|
break;
|
|
|
|
case OPERATION_PROJ_SAVE:
|
|
|
|
break;
|
|
|
|
case OPERATION_PROJ_LOAD:
|
|
|
|
break;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|