📄 unit_frmmain.pas
字号:
begin
Action := CanOne;
end;
procedure TFrmMain.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if WindowState <> wsNormal then Exit;
if Button = mbleft then
begin
m_bMouseDown := TRUE;
m_nOldMouseX := x;
m_nOldMouseY := y;
end;
end;
procedure TFrmMain.btExitClick(Sender: TObject);
begin
btStop.Click;
Application.Terminate;
end;
procedure TFrmMain.Label_HomePageClick(Sender: TObject);
begin
ShellExecute(GetDesktopWindow, 'open', Pchar(Label_HomePage.Caption), nil, nil, 0);
end;
procedure TFrmMain.btAboutClick(Sender: TObject);
begin
Application.MessageBox(Msg_About, MainForm_BtAbout, MB_ICONINFORMATION + MB_OK);
end;
procedure TFrmMain.ApplicationEvents1Exception(Sender: TObject;
E: Exception);
begin
//
end;
procedure TFrmMain.btVcdClick(Sender: TObject);
type
TMyCd_Rom = record
cNo: array[1..23] of char;
iCount: smallint;
end;
PMyCd_Rom = ^TMyCd_Rom;
procedure GetCdRomNo(Cd_Rom: PMyCd_Rom);
var drive: char;
cdromID: integer;
begin
Cd_Rom^.iCount := 0;
for drive := 'd' to 'z' do
begin
cdromID := GetDriveType(pchar(drive + ':\'));
if cdromID = 5 then
begin
Cd_Rom^.iCount := Cd_Rom.iCount + 1;
Cd_Rom^.cNo[Cd_Rom.iCount] := Drive;
end;
end;
end;
var
MyCd_Rom: PMyCd_Rom;
i: smallint;
bHaveVcdFile: Boolean;
begin
new(MyCd_Rom);
GetCdRomNo(MyCd_Rom);
if MyCd_Rom^.iCount = 0 then
begin
Application.MessageBox(Msg_CDROM_NotFound, Pchar(Application.Title), MB_ICONINFORMATION + MB_OK);
Dispose(MyCd_Rom);
Exit;
end;
bHaveVcdFile := False;
for i := 1 to MyCd_Rom.iCount do
begin
if DirectoryExists(MyCd_Rom.cNo[i] + ':\MPEGAV') then
begin
bHaveVcdFile := True;
Break;
end;
end;
if not (bHaveVcdFile) then
begin
Application.MessageBox(Msg_CDROM_NotFile, Pchar(Application.Title), MB_ICONINFORMATION + MB_OK);
Dispose(MyCd_Rom);
Exit;
end;
OpenDialog1.InitialDir := MyCd_Rom.cNo[i] + ':\MPEGAV';
Dispose(MyCd_Rom);
btFile.Click;
end;
procedure TFrmMain.btFullClick(Sender: TObject);
begin
if btFull.Down then
FrmVideo.FullScreen.Click
else
FrmVideo.WindowScreen.Click;
end;
procedure TFrmMain.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if WindowState <> wsNormal then Exit;
if Button = mbleft then
begin
m_bMouseDown := FALSE;
if (m_bHLinked or m_bVLinked) then m_bCombined := TRUE;
end;
end;
procedure TFrmMain.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
MoveX, MoveY: integer;
rectPane, rectTv: TRect;
begin
if (m_bMouseDown) then
begin
if not (m_bCombined) then //如果没有拼合在一起
begin
/////////////////////////////
/////////先移动自己的窗口
//////////////////////////////
MoveX := x - m_nOldMouseX;
MoveY := y - m_nOldMouseY;
if (m_bHLinked) then
if (abs(MoveX) <= WSPAN) then MoveX := 0 else m_bHLinked := FALSE;
if (m_bVLinked) then
if (abs(MoveY) <= WSPAN) then MoveY := 0 else m_bVLinked := FALSE;
GetWindowRect(Handle, rectPane);
rectPane.left := rectPane.left + MoveX;
rectPane.right := rectPane.right + MoveX;
rectPane.top := rectPane.top + MoveY;
rectPane.bottom := rectPane.bottom + MoveY;
MoveWindow(Handle, rectPane.Left, rectPane.Top, Self.Width, Self.Height, True);
/////////////////////////////////////
//再判断是否相吸
////////////////////////////////////
GetWindowRect(Handle, rectPane);
GetWindowRect(FrmVideo.Handle, rectTv);
MoveX := 0;
MoveY := 0;
////////////////////////////////////////
//先判断上,下边
if (rectPane.top - WSPAN <= rectTv.bottom) and (rectPane.top >= rectTv.bottom) then //判断上边
begin
MoveY := rectTv.bottom - rectPane.top;
m_bVLinked := TRUE;
end
else if (rectPane.bottom + WSPAN >= rectTv.top) and (rectPane.bottom <= rectTv.top) then //判断下边
begin
MoveY := rectTv.top - rectPane.bottom;
m_bVLinked := TRUE;
end;
if (m_bVLinked) then
begin
GetWindowRect(Handle, rectPane);
rectPane.top := rectPane.top + MoveY;
rectPane.bottom := rectPane.bottom + MoveY;
MoveWindow(Handle, rectPane.Left, rectPane.Top, Self.Width, Self.Height, True);
end;
GetWindowRect(Handle, rectPane);
GetWindowRect(FrmVideo.Handle, rectTv);
MoveX := 0;
MoveY := 0;
//////////////////////////////////////////
//再判断左,右边
if ((rectPane.top >= rectTv.top) and (rectPane.top <= rectTv.bottom)) or ((rectPane.bottom >= rectTv.top) and (rectPane.bottom <= rectTv.bottom)) then
begin
if (rectPane.left - WSPAN <= rectTv.right) and (rectPane.left >= rectTv.right) then //判断左边
begin
MoveX := rectTv.right - rectPane.left;
m_bHLinked := TRUE;
end
else if (rectPane.right + WSPAN >= rectTv.left) and (rectPane.right <= rectTv.left) then //判断右边
begin
MoveX := rectTv.left - rectPane.right;
m_bHLinked := TRUE;
end;
end;
if (m_bHLinked) then
begin
GetWindowRect(Handle, rectPane);
rectPane.left := rectPane.left + MoveX;
rectPane.right := rectPane.right + MoveX;
MoveWindow(Handle, rectPane.Left, rectPane.Top, Self.Width, Self.Height, True);
end;
/////////////////////////////////////////////////
//如果有一边吸在一起
if (m_bVLinked) then
begin
if (abs(rectPane.left - rectTv.left) <= WSPAN) then
begin
m_bHLinked := TRUE;
GetWindowRect(Handle, rectPane);
MoveX := rectTv.left - rectPane.left;
rectPane.left := rectPane.left + MoveX;
rectPane.right := rectPane.right + MoveX;
MoveWindow(Handle, rectPane.Left, rectPane.Top, Self.Width, Self.Height, True);
end
else if (abs(rectPane.right - rectTv.right) <= WSPAN) then
begin
m_bHLinked := TRUE;
GetWindowRect(Handle, rectPane);
MoveX := rectTv.right - rectPane.right;
rectPane.left := rectPane.left + MoveX;
rectPane.right := rectPane.right + MoveX;
MoveWindow(Handle, rectPane.Left, rectPane.Top, Self.Width, Self.Height, True);
end;
end
else if (m_bHLinked) then
begin
if (abs(rectPane.top - rectTv.top) <= WSPAN) then
begin
m_bVLinked := TRUE;
GetWindowRect(Handle, rectPane);
MoveY := rectTv.top - rectPane.top;
rectPane.top := rectPane.top + MoveY;
rectPane.bottom := rectPane.bottom + MoveY;
MoveWindow(Handle, rectPane.Left, rectPane.Top, Self.Width, Self.Height, True);
end
else if (abs(rectPane.bottom - rectTv.bottom) <= WSPAN) then
begin
m_bVLinked := TRUE;
GetWindowRect(Handle, rectPane);
MoveY := rectTv.bottom - rectPane.bottom;
rectPane.top := rectPane.top + MoveY;
rectPane.bottom := rectPane.bottom + MoveY;
MoveWindow(Handle, rectPane.Left, rectPane.Top, Self.Width, Self.Height, True);
end;
end;
end
else //如果拼合在一起在
begin
MoveX := x - m_nOldMouseX;
MoveY := y - m_nOldMouseY;
GetWindowRect(Handle, rectPane);
GetWindowRect(FrmVideo.Handle, rectTv);
rectPane.left := rectPane.left + MoveX;
rectPane.right := rectPane.right + MoveX;
rectPane.top := rectPane.top + MoveY;
rectPane.bottom := rectPane.bottom + MoveY;
rectTv.left := rectTv.left + MoveX;
rectTv.right := rectTv.right + MoveX;
rectTv.top := rectTv.top + MoveY;
rectTv.bottom := rectTv.bottom + MoveY;
MoveWindow(Handle, rectPane.Left, rectPane.Top, Self.Width, Self.Height, True);
MoveWindow(FrmVideo.Handle, rectTv.Left, rectTv.Top, FrmVideo.Width, FrmVideo.Height, True);
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -