相似函数: ScaleWindowExtEx、ScaleViewportExtEx


本例效果图:


代码文件:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls; type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  end; var
  Form1: TForm1; implementation {$R *.dfm} var
  cvs: TCanvas;
  x1,y1: Real;
  wx,wy,vx,vy: Integer;
  f: Boolean; procedure TForm1.FormCreate(Sender: TObject);
begin
  cvs := TCanvas.Create;
  cvs.Handle := GetDC(Handle);
  wx := ClientWidth;
  wy := ClientHeight;
  vx := wx;
  vy := wy;
end; procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  f := True;
  x1 := X;
  y1 := Y;
end; procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if not f then Exit;
  x1 := X / x1;
  y1 := Y / y1;   vx := Trunc(vx * x1);
  vy := Trunc(vy * y1);   Repaint;   x1 := X;
  y1 := Y;
end; procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  f := False;
end; procedure TForm1.FormPaint(Sender: TObject);
const
  pts: array[..] of TPoint = ((X:; Y:), (X:; Y:), (X:; Y:));
begin
  SetMapMode(cvs.Handle, MM_ANISOTROPIC);
  {只能在 MM_ISOTROPIC 或 MM_ANISOTROPIC 模式下使用下面两个函数}
  SetWindowExtEx(cvs.Handle, wx, wy, nil);
  SetViewportExtEx(cvs.Handle, vx, vy, nil);   cvs.Pen.Width := ;
  cvs.Pen.Color := clRed;
  cvs.Brush.Style := bsCross;
  cvs.Brush.Color := clSilver;
  cvs.Polygon(pts);
  cvs.Ellipse(, , , );
end; procedure TForm1.FormDestroy(Sender: TObject);
begin
  cvs.Free;
end; end.

窗体文件:


object Form1: TForm1
  Left =
  Top =
  Caption = 'Form1'
  ClientHeight =
  ClientWidth =
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poDesktopCenter
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  OnMouseDown = FormMouseDown
  OnMouseMove = FormMouseMove
  OnMouseUp = FormMouseUp
  OnPaint = FormPaint
  PixelsPerInch =
  TextHeight =
end http://www.cnblogs.com/del/archive/2008/06/02/1212382.html

放大缩小,只需要使用这2个函数:SetWindowExtEx、SetViewportExtEx的更多相关文章

  1. WPF布局之让你的控件随着窗口等比放大缩小,适应多分辨率满屏填充应用

    一直以来,我们设计windows应用程序,都是将控件的尺寸定好,无论窗体大小怎么变,都不会改变,这样的设计对于一般的应用程序来说是没有问题的,但是对于一些比较特殊的应用,比如有背景图片的,需要铺面整个 ...

  2. 自定义ImageView实现图片手势滑动,多点触摸放大缩小效果

    首先呢,还是一贯作风,我们先来看看众多应用中的示例:(这种效果是很常见的,可以说应用的必须品.)                搜狐客户端                               ...

  3. WebView 判断放大缩小操作

    using Android.App; using Android.Widget; using Android.OS; using Android.Content; using Android.Runt ...

  4. javascript仿新浪微博图片放大缩小及旋转效果

    javascript仿新浪微博图片放大缩小及旋转效果 经常看到新浪微博里有图片放大缩小旋转效果,感觉效果还不错,所以就想试着做一个类似的demo出来,至于旋转对于IE可以用滤镜来解决,标准的浏览器可以 ...

  5. GreenOpenPaint的实现(四)放大缩小处理滚动事件

    放大缩小看似简单,实际上还是比较复杂的.所以专门拿出来说明. 缩放这块,主要就是处理m_pDoc->m_scalefactor void CGreenOpenPaintView::OnButto ...

  6. 手把手教你打造ImageView支持手势放大缩小

    写在前面 最近有了新的任务,学习的时间比以前少了不少,Java回炉的文估计是得缓缓了,不过每周一篇尽量保质保量.最近感觉我文写的有点不好,因为我写东西除非必要,不然概念性的东西我基本上都是一笔带过…… ...

  7. ThreeJs 导入外部三维模型,并实现鼠标滚动放大缩小旋转效果

    let i = ; function init() { // create a scene, that will hold all our elements such as objects, came ...

  8. PhotoView实现图片随手势的放大缩小的效果

    项目需求:在listView的条目中如果有图片,点击条目,实现图片的放大,并且图片可以根据手势来控制图片放大缩小的比例.类似于微信朋友圈中查看好友发布的照片所实现的效果. 思路是这样的:当点击条目的时 ...

  9. 【开源】专业K线绘制[K线主副图、趋势图、成交量、滚动、放大缩小、MACD、KDJ等)

    这是一个iOS项目雅黑深邃的K线的绘制. 实现功能包括K线主副图.趋势图.成交量.滚动.放大缩小.MACD.KDJ,长按显示辅助线等功能 预览图 最后的最后,这是项目的开源地址:https://git ...

  10. 鼠标上下滑动总是放大缩小页面,按住ctrl+0

    鼠标上下滑动总是放大缩小页面,可能是ctrl键失灵了,幸好键盘有两个ctrl键,按住ctrl+0,页面就正常了,吓死宝宝了,~~~~(>_<)~~~~

随机推荐

  1. Python 在线笔试

    1. 循环输入输出交互 Python在线笔试琐碎 求两个整数 A+B 的和. while True: try: (n, m) = (int(x) for x in raw_input().split( ...

  2. iOS_01_什么是ios

    * ios是一款由苹果公司开发的操作系统(os是Operating Systen的简称),就像平时在电脑上用的Window XP.Window 7.都是操作系统. * 那什么是操作系统呢?操作系统其实 ...

  3. 嵌入式Linux学习笔记 NAND Flash控制器

    一.NAND Flash介绍和NAND Flash控制器的使用 NAND Flash在嵌入式系统中的作用,相当于PC上的硬盘 常见的Flash有NOR Flash和NAND Flash,NOR Fla ...

  4. WCF REST 基础教程

    概述 Representational State Transfer(REST)是Roy Fielding博士在2000年他的博士论文中提出来的一种软件架构风格. 因此REST是设计风格而不是标准,R ...

  5. ModSecurity防御暴力破解

    http://www.modsecurity.org/ ModSecurity防御暴力破解 在阅读本文前,先简单了解下什么是ModSecurity,ModSecurity是一个入侵探测与阻止的引擎.它 ...

  6. 读Effective Objective-C [提高OC代码质量总结笔记第一篇:熟悉OC]

    一.OC特性 OC 为 C 语言添加了面向对象特性,是其超集; OC 使用动态绑定的消息结构,也就是,在运行时才会检查对象类型; 接收一条消息后,究竟应执行何种代码,由运行期环境来决定,而非 编译器; ...

  7. 【23.39%】【codeforces 558C】Amr and Chemistry

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. Spring Boot+Mybatis+Pagehelper分页

    Spring Boot 集成MyBatis和Pagehelper分页插件 mybatis-spring-boot-starter依赖树如下: pom配置 <project xmlns=" ...

  9. php实现Bloom Filter

    Bloom Filter(BF) 是由Bloom在1970年提出的一种多哈希函数映射的高速查找算法,用于高速查找某个元素是否属于集合, 但不要求百分百的准确率. Bloom filter通经常使用于爬 ...

  10. html css div img垂直居中

    <head> <meta charset="UTF-8"> <meta name="Generator" content=&quo ...