zoukankan      html  css  js  c++  java
  • 窗体包括标题作为一个位图复制到剪贴板

    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,Clipbrd;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      Format: Word;
      Data: Cardinal;
      APalette: HPALETTE;
    begin
      {TBitmap.SaveToClipboardFormat 函数的三个参数都是接受数据用的, 按要求类型定义即可}
      GetFormImage.SaveToClipboardFormat(Format, Data, APalette);
      {放入剪切板}
      Clipboard.SetAsHandle(Format, Data);
    
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      dc: HDC;
      bmp: TBitmap;
      Format : Word;
      Bitmap : TBitMap;
      Data: THandle;
      Palette: HPALETTE;
    begin
      dc := GetDC(0);
      if dc <> 0 then
      begin
        bmp := TBitmap.Create();
        bmp.Width := Width;
        bmp.Height := Height;
    
        BitBlt(bmp.Canvas.Handle, 0, 0, Width, Height, dc, Left, Top, SRCCOPY);
    
        bmp.SaveToClipboardFormat(Format, Data, Palette);
        Clipboard.SetAsHandle(Format, Data);
    
    
        bmp.Free();
        ReleaseDC(0, dc);
      end;
    end;

    参考:http://www.cnblogs.com/key-ok/p/3380436.html

  • 相关阅读:
    1104.整除问题
    1101.表达式求值(难)
    1102.最小子面积矩阵
    1095.2的幂次方
    1094.String matching
    1093.WERTYU
    1096.日期差值
    1092.Fibonacci
    车站解题程序
    阶乘之和解题程序
  • 原文地址:https://www.cnblogs.com/findumars/p/4748717.html
Copyright © 2011-2022 走看看