![]() |
|
論壇說明 |
歡迎您來到『史萊姆論壇』 ^___^ 您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的! 請點擊這裡:『註冊成為我們的一份子!』 |
![]() ![]() |
|
主題工具 | 顯示模式 |
![]() |
#1 |
版區管理員
![]() |
![]() Windows擷取畫面的按鈕SrtScr雖然方便,可惜沒有加入游標的功能
幸好現在有很多相當方便的工具可以達到 之前小王子也分享過利用BCB設計畫面擷取的程式,而且透過GetCursorInfo API指令將游標加入 可惜加入游標的方法只能用在全螢幕擷取,一旦要擷取特定視窗就沒轍了 不過今天小王子終於克服這個問題,同樣的分享程式碼給大家 擷取畫面的方法還真不少,下面的方法是監控剪貼簿,當然同樣是擷取全螢幕 只不過,擷取完後,會取得上層視窗的位置及大小,對應到剛剛擷取的畫面,就可取得想要的視窗啦 語法:
void __fastcall TForm1::Timer1Timer(TObject *Sender) { /*******************************************************************************************************************+ | CF_TEXT Text with a CR-LF combination at the end of each line. A null character identifies the end of the text. | | CF_BITMAP A Windows bitmap graphic. | | CF_METAFILEPICT A Windows metafile graphic. | | CF_PICTURE An object of type TPicture. | | CF_COMPONENT Any persistent object. | +*******************************************************************************************************************/ if(GetTickCount()-bt >= 60000) { Timer1->Enabled=false; ShowWindow(Application->Handle,SW_RESTORE); ShowWindow(Handle,SW_RESTORE); } p1=p; ::GetCursorPos(&p); if((p.x==p1.x)&&(p.y==p1.y)){ if(GetTickCount()-bt >= 180000) { //3分鐘內沒移動滑鼠 Close(); } } if(Clipboard()->HasFormat(CF_BITMAP)) { bt=GetTickCount(); Graphics::TBitmap *PictBmp=new Graphics::TBitmap; Graphics::TBitmap *TempBmp=new Graphics::TBitmap; TempBmp->Assign(Clipboard()); if(CheckBox1->Checked){ CURSORINFO ci; ci.cbSize=sizeof(CURSORINFO); GetCursorInfo(&ci); POINT pt; GetCursorPos(&pt); DrawIcon(TempBmp->Canvas->Handle, pt.x, pt.y, ci.hCursor); } if(CheckBox5->Checked){ HWND Wnd; Wnd=::GetForegroundWindow(); TRect R; GetWindowRect(Wnd, &R); // Caption=Format("(%d,%d)-(%d,%d) %dx%d",OPENARRAY(TVarRec,((int)R.left,(int)R.top,(int)R.right,(int)R.bottom,(int)(R.right - R.left),(int)(R.bottom - R.top)))); PictBmp->Width=R.right - R.left; PictBmp->Height=R.bottom - R.top; BitBlt(PictBmp->Canvas->Handle, 0, 0, R.right, R.bottom, TempBmp->Canvas->Handle, R.left, R.top, SRCCOPY); } else PictBmp->Assign(TempBmp); if(CheckBox3->Checked){ Clipboard()->Assign(PictBmp); } else { int i=ComboBox1->Text.ToInt(); if(!DirectoryExists(Edit1->Text)) ::CreateDirectory(Edit1->Text.c_str(),NULL); if(!CheckBox4->Checked) while (FileExists(Edit1->Text+"Picture ("+i+").bmp")) i++; PictBmp->SaveToFile(Edit1->Text+"Picture ("+i+").bmp"); UpDown1->Position=++i; delete TempBmp; delete PictBmp; } Clipboard()->Clear(); } } //--------------------------------------------------------------------------- |
__________________ 『唸金母心咒:嗡。金母。悉地。吽。』 持此咒者,可免一切瘟疫,一切瘟神抱頭四散。 魔術就是欣賞神奇的效果 如果魔術的秘密被破解了 那魔術就失去欣賞的價值 |
|
![]() |
送花文章: 1537,
![]() |
有 5 位會員向 魔術王子 送花:
|
![]() 感謝您發表一篇好文章 |
![]() |
#2 (permalink) |
版區管理員
![]() |
![]() https://drive.google.com/file/d/1mXt...ew?usp=sharing
分享一下程式 不過這是用BCB6.0設計的,新版BCB編譯可能會因為字元出錯,以後有機會再設計吧,有幾個地方說明一下 1.雙擊右下角圖示改變圖示開關監控 語法:
case WM_LBUTTONDBLCLK: Timer1->Enabled=!Timer1->Enabled; if(Timer1->Enabled) { Clipboard()->Clear(); ListView1->Tag=0; Clip2Bmp.hIcon=LoadIcon(HInstance,"Clip2Bmp1"); strcpy(Clip2Bmp.szTip,"監控中"); } else { Clip2Bmp.hIcon=LoadIcon(HInstance,"Clip2Bmp2"); strcpy(Clip2Bmp.szTip,"閒置中"); } Shell_NotifyIcon(NIM_MODIFY,&Clip2Bmp); // ShowWindow(Application->Handle,SW_RESTORE); // ShowWindow(Handle,SW_RESTORE); break; 語法:
void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose) { ShowWindow(Application->Handle,SW_HIDE); ShowWindow(Handle,SW_HIDE); CanClose=(Tag==1); } //--------------------------------------------------------------------------- 語法:
String WorkDir; BROWSEINFO bi; char WDir[MAX_PATH]; char FolderName[MAX_PATH]; LPITEMIDLIST ItemID; memset(&bi, 0, sizeof(BROWSEINFO)); memset(WDir, 0, MAX_PATH); bi.hwndOwner = Handle; bi.pszDisplayName = FolderName; bi.lpszTitle = "請選擇路徑"; ItemID = SHBrowseForFolder(&bi); SHGetPathFromIDList(ItemID, WDir); WorkDir = String(WDir); if(WorkDir!="") StatusBar1->SimpleText=WorkDir+"\\"; ScanFile(); 語法:
//--------------------------------------------------------------------------- #include <shlobj.h> //要放於 vcl.h 之前 #define NO_WIN32_LEAN_AND_MEAN #include <vcl.h> #include <Clipbrd.hpp> #pragma hdrstop |
![]() |
送花文章: 1537,
![]() |
![]() ![]() |
|
|
![]() |
||||
主題 | 主題作者 | 討論區 | 回覆 | 最後發表 |
個人評論 - 熱門話題 我也來"還願"一下 | cloudchine | 時事、科技、娛樂新聞話題討論區 | 7 | 2019-02-28 01:46 AM |
灌水 - 魔術"夾心的笑話"正宗的表演程式 | 魔術王子 | 生活話題、日常閒聊、喇勒唬爛灌水區 | 7 | 2018-12-16 05:19 PM |
還是XP的問題@@" | virtual | 軟體應用問題討論區 | 2 | 2002-12-06 07:07 PM |