📄 sdtask.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "sdTask.h"
#include "FormMgr.h"
#include "Commfunction.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TsdTask::TsdTask(TClientComm *cc)
{
m_Forms=new TsdCollection;
m_FormPoints=new TStringList;
m_ClientComm=cc;
m_FormLib=-1;
m_Status=-1;
m_OpenCount=0;
m_Left=10;
m_Width=80;
m_Height=25;
m_Leader=15;
m_VStep=10;
}
TsdTask::~TsdTask()
{
TsdTask *p;
for(int i=0;i<m_Forms->Count();i++)
{
p=(TsdTask *)m_Forms->Item(i);
this->Assign(p);
//delete m_TForm;
m_TForm->Close();
}
delete m_Forms;
delete m_FormPoints;
}
void __fastcall TsdTask::AddForm(TForm * pForm)
{
AnsiString FormName;
try
{
m_TForm=pForm;
FormName=pForm->Name;
m_Status=0;
TsdTask *p=new TsdTask(m_ClientComm);
p->Panel=m_Panel;
p->Assign(this);
m_Forms->Add(p,FormName.UpperCase());
m_FormPoints->Add(AnsiString((int)pForm));
m_ClientComm->AddMsgForm(pForm);
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
void __fastcall TsdTask::DeleteForm(AnsiString FormName)
{
int index;
AnsiString FormKey;
TsdTask *p;
try
{
index=m_FormPoints->IndexOf(FormName);
if(index==-1)
return;
p=(TsdTask *)m_Forms->Item(index);
this->Assign(p);
FormKey=m_Forms->Key;
delete m_TForm;
this->Close(FormKey);
m_Forms->Delete(FormKey);
m_FormPoints->Delete(index);
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
void __fastcall TsdTask::Show(AnsiString FormName,AnsiString FormCode,AnsiString FormCaption,int FormLib,int FormRight)
{
TsdTask *p;
try
{
if(m_Forms->FindKey(FormName.UpperCase())==false)
{
try
{
StartWaitForm("正在初始化数据,请稍候...");
AddForm(g_sdModuleForm->NewModuleForm(FormCode,FormLib,FormRight));
}
__finally
{
EndWaitForm();
}
}
p=(TsdTask *)m_Forms->Value(FormName.UpperCase());
p->m_FormCaption=FormCaption;
p->m_FormLib=FormLib;
p->m_TForm->WindowState=wsNormal;
p->m_TForm->Tag=FormRight;
p->m_TForm->Show();
}
catch(Exception &e)
{
Application->ProcessMessages();
throw Exception(e.Message);
}
if(p->m_Status!=1)
{
m_OpenCount++;
p->m_Status=1;
p->m_SpeedButton=NULL;
p->m_SpeedButton=new TSpeedButton(m_Panel);
p->m_SpeedButton->Parent=m_Panel;
p->m_SpeedButton->Font->Name="宋体";
p->m_SpeedButton->Font->Size=9;
p->m_SpeedButton->Caption=p->m_FormCaption;
if(p->m_BtnPicName.IsEmpty()==false)
p->m_SpeedButton->Glyph->LoadFromFile(p->m_BtnPicName);
p->m_SpeedButton->Flat =true;
p->m_SpeedButton->Left=m_Left;
p->m_SpeedButton->Height=m_Height;
p->m_SpeedButton->Width=m_Width;
p->m_SpeedButton->Visible=false;
p->m_SpeedButton->OnClick=SpeedButtonClick;
p->m_SpeedButton->Tag=m_Forms->Index;
p->m_SpeedButton->Hint=m_Forms->Key;
ShowOnTaskBar();
}
}
void __fastcall TsdTask::ShowModal(AnsiString FormName,AnsiString FormCode,int FormLib,int FormRight)
{
//TODO: Add your source code here
}
void __fastcall TsdTask::Close(AnsiString FormName)
{
TsdTask *p=(TsdTask *)m_Forms->Value(FormName);
//this->Assign(p);
p->m_SpeedButton->Visible =false;
delete p->m_SpeedButton;
p->m_Status=0;
m_OpenCount--;
ShowOnTaskBar();
}
void __fastcall TsdTask::Assign(TsdTask * p)
{
this->m_Panel=p->m_Panel;
this->m_TForm=p->m_TForm;
this->m_SpeedButton=p->m_SpeedButton;
this->m_FormLib=p->m_FormLib;
this->m_FormCaption=p->m_FormCaption;
this->m_BtnPicName=p->m_BtnPicName;
this->m_Status=p->m_Status;
this->m_Left=p->m_Left;
this->m_Width=p->m_Width;
this->m_Height=p->m_Height;
this->m_Leader=p->m_Leader;
this->m_VStep=p->m_VStep;
}
void __fastcall TsdTask::ShowOnTaskBar()
{
int m_Count;
m_Count=0;
for(int i=0;i<m_Forms->Count();i++)
{
TsdTask *p=(TsdTask *)m_Forms->Item(i);
this->Assign(p);
if(m_Status==1)
{
//m_SpeedButton->Top=m_Leader+(m_Height+m_VStep)*m_Count;
//m_SpeedButton->Top=m_Leader;
m_SpeedButton->Top=0;
m_SpeedButton->Left=m_Width*m_Count+50;
m_SpeedButton->Visible=true;
m_Count++;
}
}
}
void __fastcall TsdTask::SpeedButtonClick(TObject * Sender)
{
TSpeedButton *s=dynamic_cast<TSpeedButton *>(Sender);
TsdTask *p=(TsdTask *)m_Forms->Value(s->Hint);
p->m_TForm->WindowState=wsNormal;
p->m_TForm->BringToFront();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -