⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 f_chword.cpp

📁 一个移动通信用SMPP协议写的.非常经典!
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "f_chword.h"
#include "Main.h"
#include <stdio.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tn_chword *n_chword;
//---------------------------------------------------------------------------
__fastcall Tn_chword::Tn_chword(TComponent* Owner)
    : TForm(Owner)
{
    iNum=0;
}
//---------------------------------------------------------------------------

void __fastcall Tn_chword::ToolButton1Click(TObject *Sender)
{
    AnsiString InputString=InputBox("添加", "请输入聊天内容:       ", "");
    if(InputString!="")
    {
        TListItem *ListItem;
        ListItem=ListView2->Items->Add();
        ListItem->Caption =ListView2->Items->Count;
        ListItem->SubItems->Add(InputString);
        ListItem->ImageIndex=9;
        ListItem->StateIndex=10;
        StatusBar1->Panels->Items[1]->Text="共有记录"+IntToStr(ListView2->Items->Count)+"条";
    }    
}
//---------------------------------------------------------------------------

void __fastcall Tn_chword::ToolButton2Click(TObject *Sender)
{
    ListView2->Selected->Delete();
    StatusBar1->Panels->Items[1]->Text="共有记录"+IntToStr(ListView2->Items->Count)+"条";
    iNum--;    
}
//---------------------------------------------------------------------------

void __fastcall Tn_chword::ToolButton5Click(TObject *Sender)
{
    AnsiString InputString=InputBox("修改", "请输入修改后的内容:       ", ListView2->Selected->SubItems->Strings[0]);
    ListView2->Selected->SubItems->Strings[0]=InputString;    
}
//---------------------------------------------------------------------------

void __fastcall Tn_chword::ToolButton7Click(TObject *Sender)
{
    FILE *fp;
    fp=fopen("常用语.txt","w");
    for(int i=0;i<ListView2->Items->Count;i++)
    {
        ListView2->Items->Item[i]->Selected=true;
        fprintf(fp,"%s\n",ListView2->Selected->SubItems->Strings[0].c_str());
    }
    fclose(fp);
    Close();    
}
//---------------------------------------------------------------------------

void __fastcall Tn_chword::FormShow(TObject *Sender)
{
    char strTmp[1000];
    int i=0;
    FILE *fp;
    if((fp=fopen("常用语.txt","r"))==NULL)
        return;
    ListView2->Items->Clear();
    while(!feof(fp))
    {
        memset(strTmp,0,sizeof(strTmp));
        fscanf(fp,"%s",&strTmp);
        if(AnsiString(strTmp)!="")
        {
            TListItem *ListItem;
            ListItem=ListView2->Items->Add();
            ListItem->Caption =++i;
            ListItem->SubItems->Add(AnsiString(strTmp));
            ListItem->ImageIndex=9;
            ListItem->StateIndex=10;
        }
    }
    fclose(fp);
    StatusBar1->Panels->Items[1]->Text="共有记录"+IntToStr(ListView2->Items->Count)+"条";    
}
//---------------------------------------------------------------------------

void __fastcall Tn_chword::ListView2SelectItem(TObject *Sender,
      TListItem *Item, bool Selected)
{
    if(Selected)
    {
         ToolButton2->Enabled=true;
         ToolButton5->Enabled=true;
         D1->Enabled=true;
         M1->Enabled=true;
    }
    else
    {
         ToolButton2->Enabled=false;
         ToolButton5->Enabled=false;
         D1->Enabled=false;
         M1->Enabled=false;
    }    
}
//---------------------------------------------------------------------------

void __fastcall Tn_chword::ListView2DblClick(TObject *Sender)
{
    if(ListView2->Selected)
    {
        MainForm->Edit1->Text=ListView2->Selected->SubItems->Strings[0];
        Close();
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -