📄 graphbmp.cpp
字号:
//---------------------------------------------------------------------------
#pragma hdrstop
#include "GraphBmp.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
__fastcall TMainData::TMainData()
{
m_szFileName = ExtractFileDir(Application->ExeName) + "\\config.dat";
m_pMainBmp = new Graphics::TBitmap();
m_pLastBmp = new Graphics::TBitmap();
m_pSetupBmp = new Graphics::TBitmap();
m_pMinBmp = new Graphics::TBitmap();
m_pCloseBmp = new Graphics::TBitmap();
m_pPointBmp = new Graphics::TBitmap();
m_pQQBmp = new Graphics::TBitmap();
m_pMainBmp->LoadFromResourceName((int)HInstance,"IDR_01_MAINBMP");
m_pSetupBmp->LoadFromResourceName((int)HInstance,"IDR_02_SETUPBMP");
m_pMinBmp->LoadFromResourceName((int)HInstance,"IDR_03_MINBMP");
m_pCloseBmp->LoadFromResourceName((int)HInstance,"IDR_04_CLOSEBMP");
m_pPointBmp->LoadFromResourceName((int)HInstance,"IDR_05_POINTBMP");
m_pQQBmp->LoadFromResourceName((int)HInstance,"IDR_06_QQBMP");
/*
m_pPointBmp->Transparent = true;
m_pPointBmp->TransparentColor = m_pPointBmp->Canvas->Pixels[0][0];
BYTE bRed = GetRValue(m_pPointBmp->TransparentColor);
BYTE bGreen = GetGValue(m_pPointBmp->TransparentColor);
BYTE bBlue = GetBValue(m_pPointBmp->TransparentColor);
DWORD dwColor = PALETTERGB(255,0,255);
*/
m_iHeight = m_pMainBmp->Height;
m_iNoteNo = 0;
ReadConfigFile();
m_wBitmapIndex = 0;
m_bShowHide = false;
}
__fastcall TMainData::~TMainData()
{
delete m_pMainBmp;
delete m_pLastBmp;
delete m_pSetupBmp;
delete m_pMinBmp;
delete m_pCloseBmp;
delete m_pPointBmp;
DestroyBitmapList();
}
int __fastcall TMainData::ReadConfigFile(void)
{
//TODO: Add your source code here
if(!FileExists(m_szFileName))
{
m_pBackColor = clTeal;
m_pFontColor = clWhite;
m_iRate = 1;
m_bBigFont = true;
WriteConfigFile();
return 1;
}
TIniFile *pIniFile;
pIniFile = new TIniFile(m_szFileName);
m_pBackColor = (TColor)pIniFile->ReadInteger("STROLLCOLOR","BACKGROUND",clTeal);
m_pFontColor = (TColor)pIniFile->ReadInteger("STROLLCOLOR","FONTCOLOR",clWhite);
m_iRate = pIniFile->ReadInteger("SYSTEM","STROLLRATE",1);
if(pIniFile->ReadInteger("SYSTEM","BIGFONT",1) > 0)
{
m_bBigFont = true;
}
else
{
m_bBigFont = false;
}
delete pIniFile;
return 1;
}
int __fastcall TMainData::WriteConfigFile(void)
{
//TODO: Add your source code here
TIniFile *pIniFile;
pIniFile = new TIniFile(m_szFileName);
//0==慢速 3==高速
pIniFile->WriteInteger("SYSTEM","STROLLRATE",m_iRate);
if(m_bBigFont)
{
pIniFile->WriteInteger("SYSTEM","BIGFONT",1);
}
else
{
pIniFile->WriteInteger("SYSTEM","BIGFONT",0);
}
pIniFile->WriteInteger("STROLLCOLOR","BACKGROUND",m_pBackColor);
pIniFile->WriteInteger("STROLLCOLOR","FONTCOLOR",m_pFontColor);
delete pIniFile;
return 1;
}
LPNOTEINFO __fastcall TMainData::GetNoteInfoByNo(int iNoteNo, int & iFind)
{
//TODO: Add your source code here
vecNoteInfoIt vNoteInfoIt;
iFind = -1;
if(m_vNoteInfo.size() <= 0)
{
return NULL;
}
vNoteInfoIt = find_if(m_vNoteInfo.begin(),m_vNoteInfo.end(),Find_NoteInfoByNo(iNoteNo));
if(vNoteInfoIt != m_vNoteInfo.end())
{
iFind = 1;
return vNoteInfoIt;
}
return NULL;
}
int __fastcall TMainData::AddNoteInfo(NOTEINFO NoteInfo)
{
//TODO: Add your source code here
NoteInfo.m_iNoteNo = m_iNoteNo++;
m_vNoteInfo.push_back(NoteInfo);
return 1;
}
int __fastcall TMainData::HideNoteInfoByNo(int iNoteNo,bool bFlag)
{
//TODO: Add your source code here
vecNoteInfoIt vNoteInfoIt;
if(m_vNoteInfo.size() <= 0)
{
return -1;
}
vNoteInfoIt = find_if(m_vNoteInfo.begin(),m_vNoteInfo.end(),Find_NoteInfoByNo(iNoteNo));
if(vNoteInfoIt != m_vNoteInfo.end())
{
(*vNoteInfoIt).m_bShow = !bFlag;
return 1;
}
return -1;
}
int __fastcall TMainData::UpdateNoteInfoByNo(int iNoteNo, String szMsg)
{
//TODO: Add your source code here
vecNoteInfoIt vNoteInfoIt;
if(m_vNoteInfo.size() <= 0)
{
return -1;
}
vNoteInfoIt = find_if(m_vNoteInfo.begin(),m_vNoteInfo.end(),Find_NoteInfoByNo(iNoteNo));
if(vNoteInfoIt != m_vNoteInfo.end())
{
(*vNoteInfoIt).m_szNote = szMsg;
return 1;
}
return -1;
}
void __fastcall TMainData::DestroyBitmapList(void)
{
//TODO: Add your source code here
LPBitmapListIt pBitmapIt;
LPBITMAPVET pBitmap;
pBitmapIt = m_pBitmapList.begin();
for(;pBitmapIt != m_pBitmapList.end();pBitmapIt++)
{
pBitmap = (*pBitmapIt);
delete pBitmap;
}
m_pBitmapList.clear();
}
LPBITMAPVET __fastcall TMainData::GetAFreeBitmap(void)
{
//TODO: Add your source code here
LPBitmapListIt pBitmapIt;
LPBITMAPVET pBitmap;
pBitmapIt = m_pBitmapList.begin();
for(;pBitmapIt != m_pBitmapList.end();pBitmapIt++)
{
pBitmap = (*pBitmapIt);
if(pBitmap->m_bFree)
{
pBitmap->m_bFree = false;
return pBitmap;
}
}
pBitmap = new BITMAPVET();
if(pBitmap != NULL)
{
pBitmap->m_wBitmapIndex = m_wBitmapIndex++;
pBitmap->m_bFree = false;
m_pBitmapList.push_back(pBitmap);
return pBitmap;
}
return NULL;
}
void __fastcall TMainData::SetBitmapToFree(WORD wBitmapIndex)
{
//TODO: Add your source code here
LPBitmapListIt pBitmapIt;
LPBITMAPVET pBitmap;
pBitmapIt = find_if(m_pBitmapList.begin(),m_pBitmapList.end(), \
Find_BitmapByIndex(wBitmapIndex));
if(pBitmapIt != m_pBitmapList.end())
{
pBitmap = (*pBitmapIt);
pBitmap->InitData();
pBitmap->m_bFree = true;
}
}
LPNOTEINFO __fastcall TMainData::GetNextNote(int iNoteNo)
{
//TODO: Add your source code here
vecNoteInfoIt vNoteInfoIt;
if(m_vNoteInfo.size() <= 0)
{
return NULL;
}
vNoteInfoIt = find_if(m_vNoteInfo.begin(),m_vNoteInfo.end(),Find_NoteInfoByNo(iNoteNo));
if(vNoteInfoIt != m_vNoteInfo.end())
{
while(vNoteInfoIt != m_vNoteInfo.end())
{
vNoteInfoIt++;
if(vNoteInfoIt == m_vNoteInfo.end())
{
break;
}
else
if(m_bShowHide)
{
return vNoteInfoIt;
}
else
if((!m_bShowHide) && ((*vNoteInfoIt).m_bShow))
{
return vNoteInfoIt;
}
}
}
return GetFirstNote();
}
void __fastcall TMainData::SetAllBitmapFree(void)
{
//TODO: Add your source code here
LPBitmapListIt pBitmapIt;
LPBITMAPVET pBitmap;
pBitmapIt = m_pBitmapList.begin();
for(;pBitmapIt != m_pBitmapList.end();pBitmapIt++)
{
pBitmap = (*pBitmapIt);
pBitmap->InitData();
pBitmap->m_bFree = true;
}
}
#define BMPSIZE 13
int __fastcall tag_BitmapVet::DrawNoteText(TColor BackColor,TColor FontColor,int iFontSize,String szNote)
{
delete m_pBitmap;
m_pBitmap = new Graphics::TBitmap();
m_szNote = szNote;
m_pBitmap->Canvas->Brush->Color = BackColor;
m_pBitmap->Canvas->Font->Color = FontColor;
m_pBitmap->Canvas->Font->Size = iFontSize;
if(m_szNote.Length() <= 0)
{
m_szNote = "这是一个空消息";
}
SIZE TxtSize;
m_Rect.left = 0;
m_Rect.top = 0;
if(!::GetTextExtentPoint32(m_pBitmap->Canvas->Handle,m_szNote.c_str(),m_szNote.Length(),&TxtSize))
{
m_Rect.right = BMPSIZE + 5 + m_pBitmap->Canvas->TextWidth(m_szNote);
m_Rect.Bottom = m_pBitmap->Canvas->TextHeight(m_szNote);
}
else
{
m_Rect.right = BMPSIZE + 5 + TxtSize.cx;
m_Rect.Bottom = TxtSize.cy;
}
m_pBitmap->Width = m_Rect.right;
m_pBitmap->Height = m_Rect.Bottom;
m_pBitmap->Canvas->TextOutA(BMPSIZE + 5,0,m_szNote);
int iTmpTop;
if(m_pBitmap->Height > 16)
{
iTmpTop = (m_pBitmap->Height - 16) / 2;
}
else
{
iTmpTop = (16 - m_pBitmap->Height) / 2;
}
::DrawIconEx(m_pBitmap->Canvas->Handle,0,iTmpTop,Application->Icon->Handle,\
16,16,0,NULL,DI_NORMAL);
/*
if(m_pPointBmp != NULL)
{
int iTop;
if(m_pBitmap->Height > m_pPointBmp->Height)
{
iTop = (m_pBitmap->Height - m_pPointBmp->Height) / 2;
}
else
{
iTop = (m_pPointBmp->Height - m_pBitmap->Height) / 2;
}
::TransparentBlt(m_pBitmap->Canvas->Handle,2,iTop,BMPSIZE,BMPSIZE,m_pPointBmp->Canvas->Handle, \
0,0,m_pPointBmp->Width,m_pPointBmp->Height,m_pPointBmp->TransparentColor);
}
*/
return 1;
}
int __fastcall tag_BitmapVet::InitData()
{
m_szNote = "";
m_Rect.left = 0;
m_Rect.top = 0;
m_Rect.right = 0;
m_Rect.Bottom = 0;
m_bFree = true;
m_pBitmap->FreeImage();
m_iCopyLeft = -1;
return 1;
}
LPNOTEINFO __fastcall TMainData::GetFirstNote(void)
{
//TODO: Add your source code here
vecNoteInfoIt vNoteInfoIt;
if(m_vNoteInfo.size() <= 0)
{
return NULL;
}
vNoteInfoIt = m_vNoteInfo.begin();
while(vNoteInfoIt != m_vNoteInfo.end())
{
if(m_bShowHide)
{
return vNoteInfoIt;
}
else
if((!m_bShowHide) && ((*vNoteInfoIt).m_bShow))
{
return vNoteInfoIt;
}
vNoteInfoIt++;
}
return NULL;
}
int __fastcall TMainData::ClearNoteInfo(void)
{
//TODO: Add your source code here
m_vNoteInfo.clear();
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -