This site is for P2P development and test software ONLY!

Adding own tabs

Show additional client-based info in an own tab. In this example a new tab showing the modversion
is added to QueueListCtrl.cpp. You can use it for any other ListCtrl aswell, you just have to adapt
the column number defined at the end of the file.


Open QueueListCtrl.cpp:

Right after the #include "" block at the beginning add the following line:
[php]#define COL_MODVER (10) // pp show ModString[/php]
In QueueListCTRL there are already 9 existing columns. If you edit another ListCtrl you have to change the
counter to the first free number. You can check this in the following code part - add the last line at the end:
[php]
void CQueueListCtrl::Init()
{
[...]
InsertColumn(6,GetResString(IDS_LASTSEEN),LVCFMT_LEFT,110,6);
InsertColumn(7,GetResString(IDS_ENTERQUEUE),LVCFMT_LEFT,110,7);
InsertColumn(8,GetResString(IDS_BANNED),LVCFMT_LEFT,60,8);
InsertColumn(9,GetResString(IDS_UPSTATUS),LVCFMT_LEFT,100,9);

// pp
InsertColumn(COL_MODVER, GetResString(IDS_CD_CSOFT), LVCFMT_LEFT, 100, COL_MODVER); // pp show modstring
[/php]

Now we localize the tab name to your language:
[php]
void CQueueListCtrl::Localize()
{
CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
HDITEM hdi;
hdi.mask = HDI_TEXT;

if(pHeaderCtrl->GetItemCount() != 0) {
CString strRes;

[...]

strRes = GetResString(IDS_UPSTATUS);
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(9, &hdi);
strRes.ReleaseBuffer();

// pp show modstring
strRes = GetResString(IDS_CD_CSOFT);
strRes.Remove(_T(':'));
hdi.pszText = strRes.GetBuffer();
pHeaderCtrl->SetItem(COL_MODVER, &hdi);
strRes.ReleaseBuffer();
// pp end
}
}
[/php]

Now for what will be shown in the column. You can show nearly anything here. The content of sBuffer
will your output, if you want to shown something else you have to edit it, just remember to return it
formatted as string:
[php]
void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
[...]

case 9:
if( client->GetUpPartCount()){
cur_rec.bottom--;
cur_rec.top++;
client->DrawUpStatusBar(dc,&cur_rec,false,thePrefs.UseFlatBar());
cur_rec.bottom++;
cur_rec.top--;
}
break;

// pp show modstring
case COL_MODVER:
Sbuffer = client->DbgGetFullClientSoftVer();
if (Sbuffer.IsEmpty())
Sbuffer = GetResString(IDS_UNKNOWN);
break;
// pp end

[...]
[/php]

Finally the sorting. Emule does not support sorting of stringsm so we have to add an additional later:
[php]
int CQueueListCtrl::SortProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
[...]

case 9:
iResult=item1->GetUpPartCount() - item2->GetUpPartCount();
break;
case 109:
iResult=item2->GetUpPartCount() - item1->GetUpPartCount();
break;

// pp show modstring
case COL_MODVER:
iResult=Mod_Version_Sort_by_String(item1,item2);
break;
case COL_MODVER+100:
iResult=Mod_Version_Sort_by_String(item2,item1);
break;
// pp end

[...]
[/php]

Now for the string sorting. This has to be added to OtherFunctions.cpp/.p

At the end of OtherFunctions.cpp add this function (from Pawcio mod):
[php]
// pp show modstring
int Mod_Version_Sort_by_String(const CUpDownClient* client1, const CUpDownClient* client2){
if(client1->GetClientSoft() == client2->GetClientSoft()){
if(client2->GetVersion() == client1->GetVersion() &&
client1->GetClientSoft() == SO_EMULE)
return _tcscmp(client2->GetClientModVer(), client1->GetClientModVer());
else
return client2->GetVersion() - client1->GetVersion();
}
else
return client1->GetClientSoft() - client2->GetClientSoft();
}
[/php]

Finally, define the function at the end of OtherFunctions.h:
[php]
// pp show modstring
int Mod_Version_Sort_by_String(const CUpDownClient* client1, const CUpDownClient* client2);
[/php]

0 comments:

发表评论