您的位置: 文章中心 -> 电脑&应用 -> 设计之路 ->
 

DIY一个Flash浏览器

日期:2007-6-3 22:31:19  作者:佚名  来源:本站原创

■ DIY一个Flash浏览器

————————————————以下为程序代码—————————————


procedure TFormFlashC.ShellTreeViewAddFolder(Sender: TObject;
  AFolder: TShellFolder; var CanAdd: Boolean);
begin
  if not AFolder.IsFolder then
    if UpperCase(ExtractFileExt(AFolder.PathName)) <> '.SWF' then
      CanAdd := False;
end;   

————————————————————————————————————

procedure TFormFlashC.ShellTreeViewChange(Sender: TObject; Node: TTreeNode);
begin
  if not ShellTreeView.SelectedFolder.IsFolder then
    if UpperCase(ExtractFileExt(ShellTreeView.SelectedFolder.PathName)) = '.SWF' then
    begin
      ShockwaveFlash.BGColor := '-1';
      ShockwaveFlash.Movie := ShellTreeView.SelectedFolder.PathName;
    end;
end;


————————————————————————————————————

procedure TFormFlashC.FormResize(Sender: TObject);
begin
  ActiveControl := nil;
  ActiveControl := ShockwaveFlash;
end;   


procedure TFormFlashC.ToolButtonCaptureClick(Sender: TObject);
var
  FilePathName: string;
  Bitmap: TBitmap;
  i: integer;
begin
  FilePathName := ShellTreeView.SelectedFolder.PathName;
  Bitmap := TBitmap.Create;
  try
    Bitmap.Width := ShockwaveFlash.Width;
    Bitmap.Height := ShockwaveFlash.Height;
    ShockwaveFlash.PaintTo(Bitmap.Canvas.Handle, 0, 0);
    i := 0;
    while (FileExists(FilePathName + IntToStr(i) + '.bmp')) do
      Inc(i);
    Bitmap.SaveToFile(FilePathName + IntToStr(i) + '.bmp');
  finally
    Bitmap.Free;
  end;
end;


————————————————————————————————————

procedure TFormFlashC.ShellTreeViewChange(Sender: TObject; Node: TTreeNode);
begin
  if not ShellTreeView.SelectedFolder.IsFolder then
    if UpperCase(ExtractFileExt(ShellTreeView.SelectedFolder.PathName)) = '.SWF' then
    begin
      ShockwaveFlash.BGColor := '-1';
      ShockwaveFlash.Movie := ShellTreeView.SelectedFolder.PathName;
      ToolButtonCapture.Enabled := True;
    end
    else
      ToolButtonCapture.Enabled := False;
end;

————————————————————————————————————

procedure TFormFlashC.ToolButtonExitClick(Sender: TObject);
begin
  Close;
end;

————————————————————————————————————

procedure TFormFlashC.WMSysCommand(var Msg: TWMSysCommand);
begin
  if (Msg.CmdType = SC_MAXIMIZE) then
  begin
    SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and not WS_CAPTION);
    ShellTreeView.Visible := False;
    ToolBar.Visible := False;
    Splitter.Visible := False;
    self.WindowState := wsMaximized;
  end
  else
    DefaultHandler(Msg);
end;


————————————————————————————————————

procedure TFormFlashC.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if Key = 27 then
  begin
    SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) or WS_CAPTION);
    Splitter.Visible := True;
    ShellTreeView.Visible := True;
    ToolBar.Visible := True;
    self.WindowState := wsNormal;
  end
end;

∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!)

[]