最小化窗口:
Application->Minimize();
关闭:
Close();
打开文件:
void __fastcall TConverterForm1::AddFileActExecute(TObject *Sender)
{
TTntOpenDialog *OpenDialog = new TTntOpenDialog(this);
OpenDialog->Filter = GetOpenDlgFilter().c_str();
OpenDialog->Title = L"Select Video File";
OpenDialog->Options << ofAllowMultiSelect;
vector<wstring> files;
if (OpenDialog->Execute())
{
for (int i = 0; i < OpenDialog->Files->Count; i++)
{
files.push_back(OpenDialog->Files->Strings[i].c_bstr());
}
}
delete OpenDialog;
AddFiles(files, true);
}
对TntLV的操作:
TntLVEditing onEditting:
void __fastcall TConverterForm1::TntLVEditing(TObject *Sender,
TListItem *Item, bool &AllowEdit)
{
//让编辑框可见
Item->MakeVisible(false);
TntLV->Scroll(TntLV->Width, 0);
Item->CancelEdit();
m_pEditingItem = Item;
int nCount = TntLV->Columns->Count;
int nX = -GetScrollPos(TntLV->Handle, SB_HORZ);
int nWidth = 0;
for (int nCol = 0; nCol < nCount; nX += nWidth, nCol++)
{
nWidth = ListView_GetColumnWidth(TntLV->Handle, nCol);
if (nCol == OUTPUT_NAME_COL)
break;
}
if (nX < 0)
{
nWidth += nX;
}
edtInPlace->Visible = true;
ActiveControl = edtInPlace;
TRect Rect = Item->DisplayRect(drBounds);
TPoint Pos;
Pos.x = nX;
Pos.y = Rect.Top;
MapWindowPoints(TntLV->Handle, Handle, (POINT*)&Pos, 1);
edtInPlace->SetBounds(Pos.x, Pos.y - 1, nWidth, Rect.Height() + 2);
edtInPlace->Text = Item->SubItems->Strings[OUTPUT_NAME_COL - 1];
edtInPlaceCurValidText = edtInPlace->Text;
}
TntLVInfoTip onInfoTip:
void __fastcall TConverterForm1::TntLVInfoTip(TObject *Sender,
TListItem *Item, AnsiString &InfoTip)
{
MuiItemInfo *info = (MuiItemInfo*)Item->Data;
InfoTip = WideString(info->strSourceName.c_str());
}
TntLVColumnDragged onColumnDragged:
void __fastcall TConverterForm1::TntLVColumnDragged(TObject *Sender)
{
edtInPlaceExit(NULL);
}
TntLVContextPopup OnContextPopup:
void __fastcall TConverterForm1::TntLVContextPopup(TObject *Sender,
TPoint &MousePos, bool &Handled)
{
TntLV->PopupMenu = (NULL != TntLV->Selected) ? PMItem : PMList;
}
TntLVSelectItem onSelectItem:
void __fastcall TConverterForm1::TntLVSelectItem(TObject *Sender,
TListItem *Item, bool Selected)
{
if (!Selected)
{
//需要直接调用,因为焦点切换会导致action无效
PreviewStopExecute(NULL);
}
else
{
MuiItemInfo *pNodeDt = GetNodeDataFocused();
UpdateTrimRange(TntLV->ItemFocused, pNodeDt);
}
}
修改扩展名:
bool TConverterForm1::Acceptable(const wstring& file)
{
//组合成*.ext模式
wstring ext = L"*";
wstring::size_type pos = file.rfind(L'.');
if (wstring::npos != pos)
{
ext += file.substr(pos);
}
return AcceptThisFormat(ext);
}
字符串插入:
wstring subfix = L"-";
subfix += WideString(i).c_bstr();
wstring n = name;
n.insert(n.rfind(L'.'), subfix);
同上:
wstring name = file.substr(file.rfind(L'//') + 1);
wstring dest = name;
wstring::size_type dpos = name.rfind(L'.');
if (wstring::npos != dpos)
{
dest = dest.substr(0, dpos);
}
dest += ps->FormatExt;
MakeUniqueItemName(dest);
MessageBox():
MessageBox(Handle, msg.c_str(), Application->Title.c_str(), MB_ICONINFORMATION|MB_OK);
Wstring 转换为 Char*:
int n = WideCharToMultiByte(CP_ACP, 0, pi->strOutputFileName.c_str(), -1, NULL, 0, 0, 0);
// char* pTXTFile = new char(pi->strOutputFileName.c_str());
char pTXTFile[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, pi->strOutputFileName.c_str(), -1, pTXTFile, n, 0, 0);
打开文件夹:
OpenUrl(edtOutputFolder->Text.c_bstr());