📄 mmwinfo.pas
字号:
if (pi <> Nil) then
begin
pStr := GlobalAllocPtr(GHND, Length(InfoTextMemo.Text)+1);
if (pStr <> Nil) then
begin
{$IFDEF WIN32}
StrCopy(pStr, PChar(InfoTextMemo.Text));
{$ELSE}
StrPCopy(pStr, InfoTextMemo.Text);
{$ENDIF}
riffModifyINFO(lpInfo, pi, CHUNK_MODIFIED, 0, pStr);
SetupINFOComboBox(INFOComboBox.ItemIndex);
end;
end
else ChunkInfoLabel.Caption := 'Can''t FIND ItemIndex';
end;
end;
{-- TMMRiffInfoEditorDlg ------------------------------------------------------}
procedure TMMRiffInfoEditorDlg.DescriptionEditKeyPress(Sender: TObject;
var Key: Char);
begin
if (Key = #13) then DescriptionEditExit(Sender);
end;
{-- TMMRiffInfoEditorDlg ------------------------------------------------------}
procedure TMMRiffInfoEditorDlg.DescriptionEditEnter(Sender: TObject);
begin
OKBtn.Default := False;
end;
{-- TMMRiffInfoEditorDlg ------------------------------------------------------}
procedure TMMRiffInfoEditorDlg.DescriptionEditExit(Sender: TObject);
var
pd: PDISP;
lpText: PChar;
begin
if (lpDisp <> nil) then
begin
pd := lpDisp^.pHead;
while pd <> nil do
begin
if (pd^.cfid = CF_TEXT) then break;
pd := pd^.pNext;
end;
lpText := GlobalAllocMem(Length(DescriptionEdit.Text)+1);
{$IFDEF WIN32}
StrCopy(lpText, Pchar(DescriptionEdit.Text));
{$ELSE}
StrPCopy(lpText, DescriptionEdit.Text);
{$ENDIF}
if (pd <> nil) then
begin
RiffModifyDISP(lpDisp, pd, CHUNK_MODIFIED, lpText);
end
else if (lpText^ <> #0) then
begin
pd := RiffCreateDISP(CHUNK_MODIFIED, CF_TEXT, nil, lpText);
RiffInsertDISP(lpDisp,pd);
end;
end;
if not DescriptionEdit.Focused then OKBtn.Default := True;
end;
{-- TMMRiffInfoEditorDlg ------------------------------------------------------}
procedure TMMRiffInfoEditorDlg.PictureBtnClick(Sender: TObject);
var
aPicture: TPicture;
aBitmap : TBitmap;
pd : PDISP;
lpDIB : PDIB;
begin
if PictureOpenDialog.Execute then
begin
{$IFDEF WIN32}
{$IFDEF TRIAL}
{$DEFINE _HACK1}
{$I MMHACK.INC}
{$ENDIF}
{$ENDIF}
aPicture := TPicture.Create;
try
aPicture.LoadFromFile(PictureOpenDialog.FileName);
if (lpDisp <> nil) then
with aPicture do
begin
aBitmap := TBitmap.Create;
try
if (Graphic is TBitmap) then
aBitmap.assign(Bitmap)
else
begin
aBitmap.Width := aPicture.Width;
aBitmap.Height := aPicture.Height;
aBitmap.Canvas.Brush.Color := Color;
aBitmap.Canvas.FillRect(Rect(0,0,aBitmap.Width,aBitmap.Height));
aBitmap.Canvas.Draw(0,0,Graphic);
end;
lpDIB := DIB_BitmapToDIB(aBitmap.Handle, aBitmap.Palette, BitsPerPixel, 1);
finally
aBitmap.Free;
end;
pd := lpDisp^.pHead;
while pd <> nil do
begin
if (pd^.cfid = CF_DIB) then break;
pd := pd^.pNext;
end;
if (pd <> nil) then
begin
RiffModifyDISP(lpDisp, pd, CHUNK_MODIFIED, PChar(lpDIB));
end
else
begin
pd := RiffCreateDISP(CHUNK_MODIFIED, CF_DIB, nil, PChar(lpDIB));
RiffInsertDISP(lpDisp, pd);
end;
SetupDISP;
end;
finally
aPicture.Free;
end;
end;
end;
{-- TMMRiffInfoEditorDlg ------------------------------------------------------}
procedure TMMRiffInfoEditorDlg.ClrBtnClick(Sender: TObject);
var
pd: PDISP;
begin
if (lpDisp <> nil) then
begin
pd := lpDisp^.pHead;
while (pd <> nil) do
begin
if (pd^.cfid = CF_DIB) then break;
pd := pd^.pNext;
end;
if (pd <> nil) then
begin
RiffModifyDISP(lpDisp, pd, CHUNK_MODIFIED, nil);
SetupDISP;
end;
end;
end;
{-- TMMRiffInfoEditorDlg ------------------------------------------------------}
procedure TMMRiffInfoEditorDlg.RevertBtnClick(Sender: TObject);
Var
pi: PInfoData;
pd: PDISP;
begin
if (lpDisp <> Nil) then
begin
{ reset all 'DISP' items to defaults read from file }
pd := lpDisp^.pHead;
while (pd <> Nil) do
begin
riffModifyDISP(lpDisp, pd, CHUNK_REVERT, Nil);
pd := pd^.pnext;
end;
SetupDISP;
end;
if (lpInfo <> Nil) then
begin
{ reset all 'INFO' items to defaults read from file }
pi := lpInfo^.pHead;
while (pi <> Nil) do
begin
riffModifyINFO(lpInfo, pi, CHUNK_REVERT, 0, Nil);
pi := pi^.pnext;
end;
SetupINFOComboBox(INFOComboBox.ItemIndex);
end;
end;
{-- TMMRiffInfoEditorDlg ------------------------------------------------------}
function TMMRiffInfoEditorDlg.InfoChanged: Boolean;
Var
pi: PInfoData;
pd: PDISP;
begin
Result := False;
if (lpDisp <> Nil) then
begin
{ go trough all the 'DISP' items and look if modified }
pd := lpDisp^.pHead;
while (pd <> Nil) do
begin
if (pd^.wFlags = CHUNK_MODIFIED) then
begin
{ yes modified data, exit }
Result := True;
exit;
end;
pd := pd^.pnext;
end;
end;
if (lpInfo <> Nil) then
begin
{ go trough all the 'INFO' items and look if modified }
pi := lpInfo^.pHead;
while (pi <> Nil) do
begin
if (pi^.wFlags = CHUNK_MODIFIED) then
begin
{ yes modified text, exit }
Result := True;
exit;
end;
pi := pi^.pnext;
end;
end;
end;
{== TMMRiffInfoEditor =========================================================}
constructor TMMRiffInfoEditor.Create(AOwner: TComponent);
begin
inherited create(AOwner);
FTitle := 'Riff-Info Editor';
FSource := nil;
ErrorCode := ComponentRegistered(InitCode, Self, ClassName);
if (ErrorCode <> 0) then RegisterFailed(InitCode, Self , ClassName);
end;
{-- TMMRiffInfoEditor ---------------------------------------------------------}
procedure TMMRiffInfoEditor.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FSource) then
FSource := Nil;
end;
{-- TMMRiffInfoEditor ---------------------------------------------------------}
function TMMRiffInfoEditor.Execute: Boolean;
var
Info: PInfoChunk;
Disp: PDispList;
begin
{ Returns true if OK Button pressed and WaveInfo is changed }
Result := False;
if assigned(FSource) then
begin
with TMMRiffInfoEditorDlg.Create(Application) do
try
Caption := FTitle;
GetParams(Info,Disp);
SetParams(Info,Disp);
Result := (ShowModal = mrOK) and InfoChanged;
finally
Free;
end;
end;
end;
{== TMMWaveInfoEditor =========================================================}
constructor TMMWaveInfoEditor.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Title := 'Wave-Info Editor';
ErrorCode := ComponentRegistered(InitCode, Self, ClassName);
if (ErrorCode <> 0) then RegisterFailed(InitCode, Self , ClassName);
end;
{-- TMMWaveInfoEditor ---------------------------------------------------------}
procedure TMMWaveInfoEditor.GetParams(var Info: PInfoChunk; var Disp: PDispList);
var
Wave: TMMWave;
begin
Info := nil;
Disp := nil;
if assigned(FSource) and (FSource is TMMCustomWaveFile) then
begin
Wave := (FSource as TMMCustomWaveFile).Wave;
if (Wave <> Nil) and not Wave.Empty then
begin
Info := Wave.PWaveIOInfo^.lpInfo;
Disp := Wave.PWaveIOInfo^.lpDisp;
end;
end;
end;
{-- TMMWaveInfoEditor ---------------------------------------------------------}
function TMMWaveInfoEditor.GetSource: TMMCustomWaveFile;
begin
Result := TMMCustomWaveFile(FSource);
end;
{-- TMMWaveInfoEditor ---------------------------------------------------------}
procedure TMMWaveInfoEditor.SetSource(aSource: TMMCustomWaveFile);
begin
if Longint(aSource) = Longint(Self) then exit;
if (aSource is TMMCustomWaveFile) or (aSource = Nil) then
begin
if (FSource <> aSource) then
begin
FSource := aSource;
end;
end;
{$IFDEF WIN32}
{$IFDEF TRIAL}
{$DEFINE _HACK3}
{$I MMHACK.INC}
{$ENDIF}
{$ENDIF}
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -