Files
2026-06-13 00:10:11 +08:00

283 lines
7.8 KiB
C++

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "GlobalUnit.h"
#include "HelpFormUnit.h"
#include "MessageFormUnit.h"
#include "ProgressFormUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "PNGButton"
#pragma resource "*.dfm"
USEFORM("MessageFormUnit.cpp", MessageForm);
THelpForm *HelpForm;
//---------------------------------------------------------------------------
__fastcall THelpForm::THelpForm(TComponent* Owner)
: TBackgroundForm(Owner)
{
m_iPrevPageIndex = 0;
m_nUserNoticeNum = 0;
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::FormCreate(TObject *Sender)
{
SetTransparent( this );
m_arrTabs[TAB_QA] = m_btnQnA;
m_arrTabs[TAB_FB] = m_btnFeedback;
m_arrTabs[TAB_NT] = m_btnUserNT;
m_arrTabs[TAB_CN] = m_btnCoin;
//通知图片
m_pImgNoticeTip = new TPngImage();
m_pImgNoticeTip->LoadFromResourceName(int(HInstance), "ImgNoticeTip");
m_panelShow->SetTextFontSize(m_memMsg->Font->Size);
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::FormActivate(TObject *Sender)
{
if( Sender ){
return;
}
// m_lblUrl->Caption = g_strServerURL;
m_pbUserNoticeNum->Visible = (m_nUserNoticeNum>0);
m_memMsg->Enabled = !g_bUpdateMandatory;
m_panelShow->InitialVars();
m_panelShow->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::FormDeactivate(TObject *Sender)
{
if( Application->ActiveFormHandle!=Application->MainFormHandle ){
return;
}
m_panelShow->SaveFirstRow();
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::PrevStepClick(TObject *Sender)
{
PostMessage(Application->MainFormHandle, UM_JUMP_PAGE, WPARAM(m_iPrevPageIndex),LPARAM(0));
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::TabClick(TObject *Sender)
{
int mode = ((TButton*)Sender)->Tag;
SetPage( mode );
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::FormResize(TObject *Sender)
{
m_btnPrevStep->Top = Height - DPIY( 494 - 460 );
m_imgBreakH->Width = Width - DPIX(28);
m_panelShow->SetBounds( m_panelShow->Left,
m_panelShow->Top,
Width,
Height - DPIY(84) );
int hGap = DPIY(20);
m_memMsg->Width = m_panelShow->Width - DPIX(36);
m_btnSubmit->Left = m_panelShow->Width - DPIX(82);
m_lblGroupLabel->Top = m_panelShow->Height - hGap;
m_lblGroup->Top = m_panelShow->Height - hGap;
m_lblEmailLabel->Top = m_panelShow->Height - hGap;
m_lblVidio->Top = m_panelShow->Height - hGap;
m_lblUrlLabel->Top = m_panelShow->Height - hGap;
m_lblUrl->Top = m_panelShow->Height - hGap;
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::HelpClick(TObject *Sender)
{
PostMessage(Application->MainForm->Handle, UM_OPENMANUAL, 0, 0);
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::MoreClick(TObject *Sender)
{
PostMessage(Application->MainForm->Handle, UM_SHOWMORE, 0, 0);
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::MemoMsgClick(TObject *Sender)
{
if( m_bMemoHint ){
m_memMsg->Text = "";
m_memMsg->Font->Color = clBlack;
m_bMemoHint = false;
}
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::MemoMsgChange(TObject *Sender)
{
if( !m_bMemoHint && !m_memMsg->Text.Trim().IsEmpty() ){
m_btnSubmit->Enabled = true;
}
else{
m_btnSubmit->Enabled = false;
}
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::SubmitClick(TObject *Sender)
{
TProgressForm *frmProgress = new TProgressForm(NULL);
string msg = GBToUTF8(((AnsiString)m_memMsg->Text.Trim()).c_str()).c_str();
int ret = frmProgress->User_SubmitQuestin( msg.c_str() );
int eExtra = frmProgress->GetOpertaionResult();
delete frmProgress;
if( ret==mrOk ){
if( eExtra==0 ){
m_panelShow->AddFeedback( m_memMsg->Text.Trim().c_str() );
m_memMsg->Text = "";
}
else{
MessageForm->ShowMessage( "由于网络故障,信息提交失败。\n请稍后重试!",
MB_ICONERROR|MB_OK );
}
}
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::panelShowClick(TObject *Sender)
{
m_panelShow->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::AboutClick(TObject *Sender)
{
PostMessage(Application->MainForm->Handle, UM_SHOWABOUT, 0, 0);
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::UrlClick(TObject *Sender)
{
if( m_lblUrl->Caption.Length()>0 ){
ShellExecute(Handle,NULL, m_lblUrl->Caption.c_str(), NULL,NULL,SW_SHOWNORMAL);
}
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::SetNoticeNum( int num, int iType )
{
if( iType==1 && m_nUserNoticeNum!=num ){
m_nUserNoticeNum = num;
m_pbUserNoticeNum->Visible = (num>0);
if( num>0 ){
m_pbUserNoticeNum->Invalidate();
}
if( m_arrTabs[TAB_NT]->Down ){
m_lblMsgNum->Caption = m_nUserNoticeNum;
m_lblMsgHead->Visible = (num>0);
m_lblMsgMiddle->Visible = (num>0);
m_lblMsgNum->Visible = (num>0);
m_lblMsgURL->Visible = (num>0);
m_lblMsgTail->Visible = (num>0);
m_panelShow->InitialVars();
}
}
}
//---------------------------------------------------------------------------
int __fastcall THelpForm::GetNoticeNum( int iType )
{
if( iType!=0 )
return m_nUserNoticeNum;
return 0;
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::SetPage( int iPage )
{
for( int i=0; i<4; i++ ){
if( i==iPage ){
m_arrTabs[i]->Down = true;
}
else{
m_arrTabs[i]->Down = false;
}
}
if( iPage==2 ){
m_lblMsgNum->Caption = m_nUserNoticeNum;
}
else if( iPage==1 && ( m_memMsg->Text.IsEmpty()
|| m_memMsg->Font->Color==clGray )){
m_bMemoHint = true;
m_memMsg->Text = "请在此处输入您的问题";
m_memMsg->Font->Color = clGray;
}
m_lblMsgHead->Visible = (iPage==2 && m_nUserNoticeNum>0);
m_lblMsgMiddle->Visible = (iPage==2 && m_nUserNoticeNum>0);
m_lblMsgNum->Visible = (iPage==2 && m_nUserNoticeNum>0);
m_lblMsgURL->Visible = (iPage==2 && m_nUserNoticeNum>0);
m_lblMsgTail->Visible = (iPage==2 && m_nUserNoticeNum>0);
m_btnSubmit->Visible = (iPage==1);
m_memMsg->Visible = (iPage==1);
m_panelShow->SetMode( iPage );
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::MsgURLClick(TObject *Sender)
{
char strURL[256];
f_CS_GetWebPageURL( URL_USERNOTICE, strURL );
ShellExecute(Handle, NULL, ((String)strURL).c_str(), NULL, NULL, SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::NoticeNumPaint(TObject *Sender)
{
TPaintBox* pPB = (TPaintBox*)Sender;
String strText = m_nUserNoticeNum;
pPB->Canvas->Draw(0, 0, m_pImgNoticeTip);
pPB->Canvas->Brush->Style = bsClear;
pPB->Canvas->Font->Color = clWhite;
int txtWidth = pPB->Canvas->TextWidth( strText );
int txtHeight = pPB->Canvas->TextHeight( strText );
pPB->Canvas->TextOut( (pPB->Width - txtWidth)/2.0+0.5,
(pPB->Height -txtHeight)/2.0,
strText );
}
//---------------------------------------------------------------------------
void __fastcall THelpForm::VidioClick(TObject *Sender)
{
ShellExecute(Handle,NULL, L"http://player.youku.com/player.php/sid/XNDM5MTgxOTQ0/v.swf",
NULL,NULL,SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------