程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> 一個拼圖工具的制作思路

一個拼圖工具的制作思路

編輯:Delphi

  功能簡介:

  1、雙擊左窗口可打開源圖像;

  2、框選左窗口可把圖像選取復制到右窗口;

  3、剪取的圖塊可以移動, 可配合 Ctrl 單選或多選, 可用 Delete 刪除選擇的圖塊;

  4、雙擊右窗口可保存拼好的圖像.

  功能實現:

  1、MoveImage 主要完成 "圖塊" 的功能;

  2、ImageBox 主要完成源圖像及選取功能;

  3、其他有主模塊 Unit1 完成.

  窗體:

object Form1: TForm1 
 Left = 0  
 Top = 0  
 Caption = 'Form1'  
 ClIEntHeight = 350  
 ClIEntWidth = 671 
 Color = clBtnFace 
 Font.Charset = DEFAULT_CHARSET 
 Font.Color = clWindowText 
 Font.Height = -11 
 Font.Name = 'Tahoma' 
 Font.Style = [] 
 OldCreateOrder = False 
 OnCreate = FormCreate 
 OnDestroy = FormDestroy 
 OnKeyUp = FormKeyUp 
 PixelsPerInch = 96 
 TextHeight = 13 
 object Splitter1: TSplitter 
  Left = 361 
  Top = 0 
  Height = 350 
  ExplicitLeft = 272 
  ExplicitTop = 128 
  ExplicitHeight = 100 
 end 
 object ScrollBox1: TScrollBox 
  Left = 0 
  Top = 0 
  Width = 361 
  Height = 350 
  Align = alLeft 
  TabOrder = 0 
  OnClick = ScrollBox1Click 
  OnDblClick = ScrollBox1DblClick 
  ExplicitHeight = 328 
  object Image1: TImage 
   Left = 3 
   Top = 3 
   Width = 25 
   Height = 25 
   OnMouseEnter = Image1MouseEnter 
  end 
 end 
end 

 Unit1:

unit Unit1; 
 
interface 
 
uses 
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
 Dialogs, ExtCtrls, ExtDlgs, MoveImage, ImageBox; 
 
type 
 TForm1 = class(TForm) 
  ScrollBox1: TScrollBox; 
  Splitter1: TSplitter; 
  Image1: TImage; 
  procedure FormCreate(Sender: TObject); 
  procedure FormDestroy(Sender: TObject); 
  procedure Image1MouseEnter(Sender: TObject); 
  procedure ScrollBox1Click(Sender: TObject); 
  procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 
  procedure ScrollBox1DblClick(Sender: TObject); 
 end; 
 
var 
 Form1: TForm1; 
 ImageBox1: TImageBox; 
 
implementation 
 
{$R *.dfm} 
 
procedure TForm1.FormCreate(Sender: TObject); 
begin 
 ImageBox1 := TImageBox.Create(Self); 
 with ImageBox1 do begin 
  Parent := Self; 
  Align := alClIEnt; 
  OutImage := Image1; 
 end; 
 ScrollBox1.Color := clWhite; 
 ScrollBox1.DoubleBuffered := True; 
 KeyPrevIEw := True; 
 List := TList.Create; 
end; 
 
procedure TForm1.FormDestroy(Sender: TObject); 
var 
 i: Integer; 
begin 
 for i := 0 to List.Count - 1 do TMoveImage(List[i]).Free; 
 List.Free; 
end; 
 
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 
var 
 i: Integer; 
begin 
 if Key = VK_DELETE then for i := List.Count - 1 downto 0 do 
 if TMoveImage(List[i]).Selected then 
  begin 
   TMoveImage(List[i]).Free; 
   List.Delete(i); 
  end; 
end; 
 
procedure TForm1.Image1MouseEnter(Sender: TObject); 
var 
 mi: TMoveImage; 
begin 
 Image1.Visible := False; 
 mi := TMoveImage.Create(ScrollBox1); 
 with mi do begin 
  Parent := ScrollBox1; 
  Left := Image1.Left; 
  Top := Image1.Top; 
  Width := Image1.Width; 
  Height := Image1.Height; 
  Picture.Bi

[1] [2] [3] [4] 下一頁

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved