史萊姆論壇
(
http://forum.slime.com.tw/)
-
程式語言討論區
(
http://forum.slime.com.tw/f76.html)
C++ Bulider的螢幕抓取程式
//Unit1.cpp
語法:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <clipbrd.hpp>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HDC DC;
WindowState = wsMinimized;
DC = GetDC(0);
Image1->Width=Screen->Width;
Image1->Height=Screen->Height;
BitBlt(Image1->Canvas->Handle, 0, 0, Screen->Width, Screen->Height, DC, 0, 0, SRCCOPY);
Image1->Refresh();
ReleaseDC(0, DC);
WindowState = wsNormal;
Button2->Enabled=true;
Button3->Enabled=true;}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Clipboard()->Assign(Image1->Picture->Bitmap);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if (SavePictureDialog1->Execute())
Image1->Picture->SaveToFile(SavePictureDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
PS:粗體部分需自行KeyIn
|
Unit1.dfm
==============
語法:
object Form1: TForm1
Left = 192
Top = 114
Width = 707
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Splitter1: TSplitter
Left = 589
Top = 0
Width = 3
Height = 446
Cursor = crHSplit
Align = alRight
end
object ScrollBox1: TScrollBox
Left = 0
Top = 0
Width = 589
Height = 446
Align = alClient
TabOrder = 0
object Image1: TImage
Left = 0
Top = 0
Width = 105
Height = 105
end
end
object Panel1: TPanel
Left = 592
Top = 0
Width = 107
Height = 446
Align = alRight
TabOrder = 1
object Button1: TButton
Left = 14
Top = 8
Width = 75
Height = 25
Caption = '抓取'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 14
Top = 56
Width = 75
Height = 25
Caption = '存剪貼簿'
Enabled = False
TabOrder = 1
OnClick = Button2Click
end
object Button3: TButton
Left = 14
Top = 88
Width = 75
Height = 25
Caption = '存檔'
Enabled = False
TabOrder = 2
OnClick = Button3Click
end
object Button4: TButton
Left = 16
Top = 128
Width = 75
Height = 25
Caption = '離開'
TabOrder = 3
OnClick = Button4Click
end
end
object SavePictureDialog1: TSavePictureDialog
DefaultExt = '.bmp'
Filter = 'Bitmaps (*.bmp)|*.bmp'
Left = 104
Top = 144
end
end
|
Unit1.h
語法:
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Dialogs.hpp>
#include <ExtDlgs.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TScrollBox *ScrollBox1;
TImage *Image1;
TPanel *Panel1;
TButton *Button1;
TButton *Button2;
TButton *Button3;
TSplitter *Splitter1;
TSavePictureDialog *SavePictureDialog1;
TButton *Button4;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
void __fastcall Button3Click(TObject *Sender);
void __fastcall Button4Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
|
所有時間均為台北時間。現在的時間是 12:13 AM。 |
|
Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2025, Jelsoft Enterprises Ltd.
『服務條款』
* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *