|
論壇說明 |
歡迎您來到『史萊姆論壇』 ^___^ 您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的! 請點擊這裡:『註冊成為我們的一份子!』 |
|
主題工具 | 顯示模式 |
2005-06-24, 12:32 PM | #1 |
版區管理員
|
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(); } //--------------------------------------------------------------------------- |
送花文章: 1530,
|
2005-06-24, 12:34 PM | #2 (permalink) |
版區管理員
|
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 |
送花文章: 1530,
|
2005-06-24, 12:36 PM | #3 (permalink) |
版區管理員
|
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 |
送花文章: 1530,
|