C++ Builder MEMO 2
* 指定したディレクトリ以下のファイル一覧をTStringListに入れる。
void ListFiles(AnsiString dirName){
int RC,p;
TSearchRec SearchRec;
AnsiString ss;
RC=FindFirst(dirName+"*.*",faAnyFile,SearchRec);
while(RC==0){
if(SearchRec.Name!=".."&&SearchRec.Name!="."){
ss=dirName+SearchRec.Name;
if((SearchRec.Attr&faDirectory)==0)li->Add(ss);
if((SearchRec.Attr&faDirectory)>0)ListFiles(ss+"\\");}
RC=FindNext(SearchRec);}
// finally
FindClose(SearchRec);
}
TStringList *li;
li=new TStringList();
ListFiles("directory")
copy and paste images
//copy
Clipboard()->Assign(Image1->Picture);
//paste
if(Clipboard()->HasFormat(CF_BITMAP))Image1->Picture->Bitmap->Assign(Clipboard());
add menu item
void __fastcall TForm1::AddMenuItem(AnsiString st,AnsiString st2,char a){
TMenuItem *NewItem=new TMenuItem(Form1);
NewItem->Caption=st;
NewItem->Hint=st2;
NewItem->Name="mn"+a;
NewItem->OnClick=mnClick;
NewItem->GroupIndex=1;
NewItem->RadioItem=true;
NewItem->ShortCut=ShortCut(a,TShiftState()<<ssCtrl);
File1->Add(NewItem);
}
void __fastcall TForm1::mnClick(TObject *Sender){
Edit1->Text=((TMenuItem*)Sender)->Caption;
Edit2->Text((TMenuItem*)Sender)->Hint;
((TMenuItem*)Sender)->Checked=true;
}
AddMenuItem(caption,hint,shortcut)
original cursor
#pragma resource "addicon.res"
Screen->Cursors[number]=LoadCursor((void*)HInstance,"resource name");
back