📄 main.cpp
字号:
}
Panel1->Visible = true;
break;
}
case 3: // 消息
{
static bool bShowListMsg = false;
if(!bShowListMsg)
{
TListItem *pItem;
ListView2->Items->BeginUpdate();
while(!Table2->Eof)
{
pItem = ListView2->Items->Add();
pItem->Caption = Table2->FieldByName("Message")->AsString;
pItem->SubItems->Add(Table2->FieldByName("Identify")->AsString);
pItem->SubItems->Add(Table2->FieldByName("Comment")->AsString);
Table2->Next();
}
ListView2->Items->EndUpdate();
bShowListMsg = true;
}
if(!ListView2->Selected)
ListView2->Items->Item[0]->Selected = true;
Panel2->Visible = true;
break;
}
case 4: // Error Code
{
Panel5->Visible = true;
break;
}
case 5:
{
if(ListBox1->Items->Count == 0)
{
while(!Table2->Eof)
{
ListBox1->Items->Add(Table2->FieldByName("ClassName")->AsString);
Table2->Next();
}
}
DBRichEdit1->DataField = "Comment";
ListBox1->ItemIndex = 0;
ListBox1Click(0);
Panel6->Visible = true;
break;
}
default:
{
break;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::TreeView1Change(TObject *Sender,
TTreeNode *Node)
{
switch(ComboBox1->ItemIndex)
{
case 2:
{
if(Node->Level == 1)
{
Table2->Filter = "FuncName='" + Node->Text + "'";
Table2->Filtered = true;
Memo1->Text = Table2->FieldByName("Comment")->AsString;
Edit1->Text = Node->Text;
}
break;
}
default: break;
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Edit1KeyPress(TObject *Sender, char &Key)
{
if(Key == VK_RETURN)
ButtonSearchClick(0);
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::ButtonSearchClick(TObject *Sender)
{
AnsiString strTmp = Edit1->Text.LowerCase().Trim();
if(!strTmp.Length()) // 输入为空
return;
TTreeNode *pGuard = TreeView1->Selected;
if(pGuard != NULL && pGuard->Text.LowerCase() == strTmp)
return;
if(pGuard == NULL)
pGuard = TreeView1->Items->Item[0];
else
pGuard = pGuard->GetNext();
while(pGuard)
{
if(pGuard->Level == 1)
{
if(pGuard->Text.LowerCase().Pos(strTmp))
{
pGuard->Selected = true;
break;
}
}
pGuard = pGuard->GetNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Edit2KeyPress(TObject *Sender, char &Key)
{
if(Key == VK_RETURN)
{
if(RadioButton1->Checked)
Edit2->Text = Edit2->Text.UpperCase();
ButtonSearchMsgClick(0);
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::ListView2SelectItem(TObject *Sender,
TListItem *Item, bool Selected)
{
if(Item)
{
Edit3->Text = Item->Caption;
Edit4->Text = Item->SubItems->Strings[0];
Memo2->Text = Item->SubItems->Strings[1];
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::RadioButton3Click(TObject *Sender)
{
if(Sender == RadioButton1)
Edit2->Text = "WM_";
else if(Sender == RadioButton2)
Edit2->Text = "$";
else
{
if(Edit2->Text == "WM_" || Edit2->Text == "$")
Edit2->Text = "";
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::ButtonAdMsgClick(TObject *Sender)
{
Panel3->Visible = !Panel3->Visible;
ButtonAdMsg->Caption = Panel3->Visible?"<<":">>";
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::ButtonSearchMsgMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if(RadioButton1->Checked)
Edit2->Text = Edit2->Text.UpperCase();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::ButtonSearchMsgClick(TObject *Sender)
{
if(Edit2->Text.Trim() == "")
return;
AnsiString strTmp = Edit2->Text;
TListItem *pItem = ListView2->Selected;
if(RadioButton1->Checked)
{
if(pItem && pItem->Caption == strTmp)
return;
for(int i=0;i<ListView2->Items->Count;i++)
{
pItem = ListView2->Items->Item[i];
if(pItem->Caption == strTmp)
{
pItem->Selected = true;
break;
}
}
}
else if(RadioButton2->Checked)
{
if(pItem && pItem->SubItems->Strings[0] == strTmp)
return;
for(int i=0;i<ListView2->Items->Count;i++)
{
pItem = ListView2->Items->Item[i];
if(pItem->SubItems->Strings[0] == strTmp)
{
pItem->Selected = true;
break;
}
}
}
else
{
int from = 0;
if(pItem)
from = pItem->Index + 1;
for(int i=from;i<ListView2->Items->Count;i++)
{
pItem = ListView2->Items->Item[i];
if(pItem->SubItems->Strings[1].Pos(strTmp))
{
pItem->Selected = true;
break;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Edit5Change(TObject *Sender)
{
int Code = Edit5->Text.ToIntDef(-1);
if(Code == -1)
Memo3->Text = "找不到该错误代码的错误信息!";
else
{
AnsiString Msg = FindErrorCode(Code);
if(Msg.IsEmpty())
Memo3->Text = "找不到该错误代码的错误信息!";
else
{
Memo3->Text = Msg;
if(Memo3->Lines->Count > 7)
Memo3->ScrollBars = ssVertical;
else
Memo3->ScrollBars = ssNone;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Edit5KeyPress(TObject *Sender, char &Key)
{
if(Key < 48 || Key > 57)
{
if(Key != 8) // BACKSPACE
Key = 0;
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TFormMain::FindErrorCode(DWORD dwCode)
{
LPVOID lpBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR)&lpBuf,
0,
NULL);
AnsiString str = AnsiString((char *)lpBuf);
LocalFree(lpBuf);
return str;
}
void __fastcall TFormMain::ButtonErrorListClick(TObject *Sender)
{
static bool bShowList = false;
if(!bShowList)
{
Gauge1->MaxValue = ERROR_CODE_COUNT;
Gauge1->Visible = true;
AnsiString str;
TListItem *pItem;
ListView3->Items->BeginUpdate();
for(int i=0;i<=ERROR_CODE_COUNT;i++)
{
str = FindErrorCode(i);
if(!str.IsEmpty())
{
pItem = ListView3->Items->Add();
pItem->Caption = AnsiString(i);
pItem->SubItems->Text = str;
}
Gauge1->Progress = i;
}
ListView3->Items->EndUpdate();
bShowList = true;
Gauge1->Visible = false;
}
ListView3->Visible = !ListView3->Visible;
ButtonErrorList->Caption = ListView3->Visible?"List<<":"List>>";
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::ListView3SelectItem(TObject *Sender,
TListItem *Item, bool Selected)
{
TListItem *pItem = ListView3->Selected;
if(pItem)
Edit5->Text = pItem->Caption;
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::ListBox1Click(TObject *Sender)
{
TLocateOptions Opts;
Table2->Locate("ClassName",ListBox1->Items->Strings[ListBox1->ItemIndex],Opts);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -