📄 main_u.pas
字号:
SG_VersionStringInfo.Cells[0,5]:='Original-Dateiname';
SG_VersionStringInfo.ColWidths[0]:=100;
SG_VersionStringInfo.ColWidths[1]:=300;
vi:=GetFileVersion(paramstr(0));
Caption:=Caption+' (V'+VersionToStr(vi)+')';
if (ParamStr(1)<>'') then
begin
if (uppercase(extractfileext(paramstr(1)))='.RC') then
LoadRC(ParamStr(1))
else
AddFile(ParamStr(1));
end;
DragAcceptfiles(Form_RFEMain.handle,true);
RC_LineOut:=MyLineOut;
findfirst(extractfilepath(paramstr(0))+lng_id+'*.lng',faAnyFile,sr);
repeat
if sr.Name<>'' then
CB_Language.Items.add(copy(sr.name,length(lng_id)+1,length(sr.name)-length(lng_id)-4));
until findnext(sr)<>0;
ini:=TIniFile.Create(extractFilePath(paramstr(0))+'rfe.ini');
Edit_Compiler.Text:=ini.ReadString('main','Compiler','');
lang:=ini.ReadString('main','Language','');
if lang<>'' then
CB_Language.ItemIndex:=CB_Language.Items.IndexOf(lang)
else
CB_Language.ItemIndex:=0;
ini.free;
LocalizeControls(Self);
loading:=false;
end;
procedure TForm_RFEMain.Btn_ReplaceVIClick(Sender: TObject);
var li:TListItem;
begin
li:=Listview1.FindCaption(0,'VERSIONINFO',false,false,false);
if not assigned(li) then
begin
li:=AddEntry('VERSIONINFO','VER','');
if not assigned(li) then
showmessage(format(LocalizeString('Msg_IDExists'),['VER']));
end;
li.SubItems[1]:=Memo1.Lines.Text;
end;
procedure TForm_RFEMain.SpinEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
const VK_OEM_PERIOD=$BE; //only for WinNT
begin
if (key=VK_OEM_PERIOD) or (key=ord('.')) then
begin
PostMessage(Handle, WM_NextDlgCtl, 0, 0);
end;
end;
procedure TForm_RFEMain.SpinEdit1Enter(Sender: TObject);
begin
(sender as TSpinedit).selstart:=0;
(sender as TSpinedit).sellength:=length(inttostr((sender as TSpinedit).value));
end;
function ParseVersionNumber(vStr:string):TVersionNumber;
var i,p:integer;
s:string;
begin
s:=vStr;
try
for i:=1 to 4 do
begin
p:=pos(',',s);
if p=0 then p:=length(s)+1;
result[i]:=strToInt(trim(copy(s,1,p-1)));
delete(s,1,p);
end;
except
showmessage(LocalizeString('Msg_ParseError'));
end;
end;
procedure TForm_RFEMain.SetLanguage(value:string);
var i,p:integer;
s:string;
begin
if copy(value,pos('x',value)+1,1)='0' then
delete(value,pos('x',value)+1,1);
i:=0;
while i < CB_Translation.Items.count do
begin
s:=CB_Translation.items.strings[i];
p:=pos(':',s);
if copy(s,p+1,length(s)-p)=value then
begin
CB_Translation.ItemIndex:=i;
i:=CB_Translation.items.count;
end;
inc(i);
end;
end;
procedure TForm_RFEMain.WMDropFiles(var msg : TWMDropFiles);
var
PFileName: Array [0 .. 255] of char;
i,count:integer;
begin
Count := DragQueryFile(Msg.Drop, $FFFFFFFF, nil, 0);
for i:=0 to count-1 do
begin
DragQueryFile(Msg.Drop, i, PFileName, 255);
if uppercase(extractfileext(pFilename))='.RC' then
LoadRC(PFileName)
else
begin
AddFile(PFileName);
Btn_AddClick(self);
end;
end;
DragFinish(Msg.Drop);
Msg.Result := 0;
end;
procedure TForm_RFEMain.ImportVersionInfo;
var i,p,p2:integer;
s,s2:string;
ba:TVersionNumber;
begin
for i:=0 to memo1.lines.count -1 do
begin
s:=trim(Memo1.lines.strings[i]);
p:=pos('\0',s);
if uppercase(copy(s,1,11))='FILEVERSION' then
begin
p2:=pos(' ',s);
ba:=ParseVersionNumber(copy(s,p2+1,length(s)-p2));
spinedit1.value:=ba[1];
spinedit2.value:=ba[2];
spinedit3.value:=ba[3];
spinedit4.value:=ba[4];
end else
if uppercase(copy(s,1,14))='PRODUCTVERSION' then
begin
p2:=pos(' ',s);
ba:=ParseVersionNumber(copy(s,p2+1,length(s)-p2));
spinedit5.value:=ba[1];
spinedit6.value:=ba[2];
spinedit7.value:=ba[3];
spinedit8.value:=ba[4];
end else
if uppercase(copy(s,8,11))= 'PRODUCTNAME' then SG_VersionStringInfo.Cells[1,0]:=trim(copy(s,23,p-23)) else
if uppercase(copy(s,8,11))= 'COMPANYNAME' then SG_VersionStringInfo.Cells[1,1]:=trim(copy(s,23,p-23)) else
if uppercase(copy(s,8,15))= 'FILEDESCRIPTION' then SG_VersionStringInfo.Cells[1,2]:=trim(copy(s,27,p-27)) else
if uppercase(copy(s,8,12))= 'INTERNALNAME' then SG_VersionStringInfo.Cells[1,3]:=trim(copy(s,24,p-24)) else
if uppercase(copy(s,8,14))= 'LEGALCOPYRIGHT' then SG_VersionStringInfo.Cells[1,4]:=trim(copy(s,26,p-26)) else
if uppercase(copy(s,8,16))= 'ORIGINALFILENAME' then SG_VersionStringInfo.Cells[1,5]:=trim(copy(s,28,p-28))else
if uppercase(copy(s,8,11))= 'TRANSLATION' then
begin
p:=pos(',',s)+1;
p2:=p;
while copy(s,p2,1)<>',' do inc(p2);
s2:=trim(copy(s,p,p2-p));
SetLanguage(s2);
end;
end;
end;
procedure TForm_RFEMain.FormDestroy(Sender: TObject);
var ini:TIniFile;
begin
ini:=TIniFile.Create(extractFilePath(paramstr(0))+'rfe.ini');
ini.WriteString('main','Compiler',Edit_Compiler.Text);
ini.WriteString('main','Language',CB_Language.Text);
ini.free;
end;
procedure TForm_RFEMain.Btn_ChooseCompilerClick(Sender: TObject);
begin
opendialog1.Filter:='BRCC32.exe|BRCC32.exe';
if opendialog1.Execute then
begin
edit_Compiler.Text:=opendialog1.FileName;
end;
end;
procedure TForm_RFEMain.Memo1Change(Sender: TObject);
begin
Btn_ReplaceVI.Enabled:=length(memo1.lines.Text)>0;
end;
procedure TForm_RFEMain.Btn_DelClick(Sender: TObject);
var i:integer;
begin
if Listview1.SelCount>0 then
begin
if messageDlg(LocalizeString('Ask_Delete'),mtconfirmation,[mbYes,mbNo],0)=mryes then
begin
for i:=listview1.items.Count-1 downto 0 do
begin
if listview1.Items[i].selected then
Listview1.Items.Delete(i);
end;
end;
end else showmessage(LocalizeString('Msg_NothingSelected'));
end;
procedure TForm_RFEMain.ListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key=27) or ((ssctrl in shift) and (key=ord('C'))) then
RC_LineIn('exit');
end;
procedure TForm_RFEMain.SB_UpdateClick(Sender: TObject);
var vi_new,vi_old:TVersionInfo;
begin
vi_new:=GetNewVersion;
vi_old:=GetFileVersion(ParamStr(0));
if compareVersions(vi_old,vi_new) then
begin
if messagedlg(//'die Version '+VersionToStr(vi_new)+' ist verf黦bar.'#13+
//'M鯿hten Sie die Projektseite 鰂fnen um die neue Version herunterzuladen?',
format(localizeString('Ask_VisitWebpage'),[VersionToStr(vi_new)]),
mtConfirmation,[mbYes,mbNo],0)=mrYes then
shellexecute(hInstance,'open','http://rfe.sourceforge.net','','',sw_show);
end else
showmessage(localizeString('Msg_NoNewVersion'));
end;
function TForm_RFEMain.preview(filename:string):boolean;
var ext:string;
jpg:TJPEGImage;
begin
result:=false;
ext:=uppercase(extractfileext(filename));
image1.visible:=false;
animate1.visible:=false;
button5.visible:=false;
Scrollbox1.Cursor:=crDefault;
if (ext='.ICO') or (ext='.BMP') then
begin
image1.Picture.LoadFromFile(filename);
image1.visible:=true;
result:=true;
end else if (ext='.CUR') or (ext='.ANI') then
begin
image1.Picture.Icon.Handle:=LoadCursorFromFile(pchar(filename));
Screen.Cursors[10]:=LoadCursorFromFile(pchar(filename));
Scrollbox1.Cursor:=10;
image1.visible:=true;
result:=true;
end else if (ext='.JPG') or (ext='.JPEG') then
begin
jpg:=TJPEGImage.create;
jpg.LoadFromFile(filename);
image1.Picture.Assign(jpg);
image1.visible:=true;
jpg.free;
result:=true;
end else if (ext='.WAV') then
begin
button5.hint:=filename;
button5.visible:=true;
result:=true;
end else if (ext='.AVI') then
begin
animate1.FileName:=filename;
animate1.Active:=true;
animate1.visible:=true;
result:=true;
end;
if result then
begin
memo1.Visible:=false;
panel1.Visible:=false;
pagecontrol1.ActivePage:=Tab_Preview;
end else
begin
//memo1.Visible:=true;
end;
end;
procedure TForm_RFEMain.ListView1Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
if change=ctState then
begin
if assigned(listview1.selected) then
begin
CB_Type.ItemIndex:=CB_Type.Items.IndexOf(listview1.selected.Caption);
Edit_Name.Text:= listview1.selected.SubItems[0];
Edit_Value.Text:=listview1.selected.SubItems[1];
if CB_Type.Items.IndexOf(listview1.selected.Caption)<7 then
preview(listview1.selected.SubItems[1]);
end;
end;
end;
procedure TForm_RFEMain.Button5Click(Sender: TObject);
begin
if button5.hint<>'' then
playsound(pchar(button5.hint),0,SND_ASYNC or SND_FILENAME)
else showmessage(localizestring('Msg_NoFile'));
end;
procedure TForm_RFEMain.CB_LanguageChange(Sender: TObject);
begin
if CB_Language.Items.IndexOf(CB_Language.Text)>0 then
begin
LocalizeControls(self);
end else if not loading then showmessage(localizeString('Msg_MustRestart'));
end;
procedure TForm_RFEMain.Btn_ImportVIClick(Sender: TObject);
var rpVersionInfo:TrpVersionInfo;
begin
opendialog1.Filter:='*.exe;*.dll|*.exe;*.dll';
if opendialog1.execute then
begin
rpVersionInfo:=TrpVersionInfo.create(opendialog1.filename);
Spinedit1.value:=rpVersionInfo.GetIntProductVersion.MainV;
Spinedit2.value:=rpVersionInfo.GetIntProductVersion.SubV;
Spinedit3.value:=rpVersionInfo.GetIntProductVersion.Release;
Spinedit4.value:=rpVersionInfo.GetIntProductVersion.Build;
Spinedit5.value:=rpVersionInfo.GetIntFileVersion.MainV;
Spinedit6.value:=rpVersionInfo.GetIntFileVersion.SubV;
Spinedit7.value:=rpVersionInfo.GetIntFileVersion.Release;
Spinedit8.value:=rpVersionInfo.GetIntFileVersion.Build;
SG_VersionStringInfo.Cells[1,0]:=rpVersionInfo.GetProductName;
SG_VersionStringInfo.Cells[1,1]:=rpVersionInfo.GetCompanyName;
SG_VersionStringInfo.Cells[1,2]:=rpVersionInfo.GetFileDescription;
SG_VersionStringInfo.Cells[1,3]:=rpVersionInfo.GetInternalName;
SG_VersionStringInfo.Cells[1,4]:=rpVersionInfo.GetLegalCopyright;
SG_VersionStringInfo.Cells[1,5]:=rpVersionInfo.GetOriginalFilename;
setLanguage('0x'+inttohex(rpVersionInfo.GetLangID,4));
end;
end;
procedure TForm_RFEMain.Btn_ModifyClick(Sender: TObject);
var li:TListItem;
begin
if assigned(Listview1.Selected) then
begin
li:=GetEntryByName(Edit_Name.Text);
if (li=nil) or (li=Listview1.Selected) then
begin
Listview1.Selected.Caption:=CB_Type.Text;
Listview1.Selected.SubItems[0]:=Edit_Name.Text;
Listview1.Selected.SubItems[1]:=Edit_Value.Text;
end else showmessage(Format(LocalizeString('Msg_IDExists'),[Edit_Name.Text]));
end else showmessage(LocalizeString('Msg_NothingSelected'));
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -