模仿QQ截圖片

兩個picturebox,一個放圖片完整代碼如下using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Xml;
namespace Test
{public partial class Form1 : Form{private bool MouseIsDown = false;private int _x, _y;private Rectangle MouseRect = Rectangle.Empty;public Form1(){InitializeComponent();}private void ResizeToRectangle(Point p){DrawRectangle();MouseRect.Width = p.X - MouseRect.Left;MouseRect.Height = p.Y - MouseRect.Top;DrawRectangle();}private void DrawRectangle(){Rectangle rect = this.RectangleToScreen(MouseRect);ControlPaint.DrawReversibleFrame(rect, Color.White, FrameStyle.Dashed);}private void DrawStart(Point StartPoint){barkPictureBox.Capture = true;Cursor.Clip = this.RectangleToScreen(new Rectangle(0, 0, ClientSize.Width, ClientSize.Height));MouseRect = new Rectangle(StartPoint.X, StartPoint.Y, 0, 0);}private void button1_Click(object sender, EventArgs e){}void barkPictureBox_MouseUp(object sender, MouseEventArgs e){barkPictureBox.Capture = false;Cursor.Clip = Rectangle.Empty;MouseIsDown = false;DrawRectangle();if (MouseRect.X == 0 || MouseRect.Y == 0 || MouseRect.Width == 0 || MouseRect.Height == 0)  //如果區域有一個是0就返回
            {}else{///代碼
            }MouseRect = Rectangle.Empty;int sx = _x < e.X ? _x : e.X;int sy = _y < e.Y ? _y : e.Y;int w = Math.Abs(_x - e.X);int h = Math.Abs(_y - e.Y);Graphics g = Graphics.FromHwnd(pictureBox2.Handle);g.Clear(pictureBox2.BackColor);g.DrawImage(barkPictureBox.Image, new Rectangle(0, 0, w, h), sx, sy, w, h, GraphicsUnit.Pixel); }void barkPictureBox_MouseMove(object sender, MouseEventArgs e){if (MouseIsDown) ResizeToRectangle(new Point(e.X + barkPictureBox.Location.X, e.Y + barkPictureBox.Location.Y));}void barkPictureBox_MouseDown(object sender, MouseEventArgs e){_x = e.X;_y = e.Y;MouseIsDown = true;DrawStart(new Point(e.X + barkPictureBox.Location.X, e.Y + barkPictureBox.Location.Y));}private void Form1_Load(object sender, EventArgs e){barkPictureBox.MouseDown += new MouseEventHandler(barkPictureBox_MouseDown);barkPictureBox.MouseMove += new MouseEventHandler(barkPictureBox_MouseMove);barkPictureBox.MouseUp += new MouseEventHandler(barkPictureBox_MouseUp);}}
}

?

轉載于:https://www.cnblogs.com/gc2013/p/3696743.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/258692.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/258692.shtml
英文地址,請注明出處:http://en.pswp.cn/news/258692.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found錯誤的解決

轉載自&#xff1a;http://www.cnblogs.com/weinyzhou/p/4983306.html 升級cmake時&#xff0c;提示“Error when bootstrapping CMake:Problem while running initial CMake”&#xff0c;第二次運行./bootstrap時&#xff0c;直接的給出了錯誤原因&#xff1a; [rootloc…

Spring中Bean的定義繼承

以下內容引用自http://wiki.jikexueyuan.com/project/spring/bean-definition-inheritance.html&#xff1a; Bean定義繼承 bean定義可以包含很多的配置信息&#xff0c;包括構造函數的參數&#xff0c;屬性值&#xff0c;容器的具體信息例如初始化方法&#xff0c;靜態工廠方法…

python實時連接oracle_Python連接Oracle

Python連接Oracle當前環境&#xff1a;Linux Centos 71. 下載安裝包cx_Oracle由于我本地Python版本是2.7,所以選擇是2.7版本wget https://pypi.python.org/packages/e1/18/00987c6a9af9568ee87d1fcba877407684a3f1b87515e5eb82d5d5acb9ff/cx_Oracle-6.0rc1-py27-1.x86_64.rpm#m…

C語言字符串函數大全

轉載自http://www.360doc.com/content/08/0723/22/26860_1462024.shtml# C語言字符串函數大全 函數名: stpcpy 功能: 拷貝一個字符串到另一個 用法: char *stpcpy(char *destin, char *source); 程序例: #include<stdio.h> #include<string.h> int main(void) { ch…

Makefile中 -I -L -l區別

轉載自&#xff1a;http://blog.csdn.net/davion_zhang/article/details/41805641 我們用gcc編譯程序時&#xff0c;可能會用到“-I”&#xff08;大寫i&#xff09;&#xff0c;“-L”&#xff08;大寫l&#xff09;&#xff0c;“-l”&#xff08;小寫l&#xff09;等參數&am…

PLT redirection through shared object injection into a running process

PLT redirection through shared object injection into a running process

python電腦版軟件下載_Python for windows

Python是一門跨平臺的腳本語言,Python規定了一個Python語法規則,實現了Python語法的解釋程序就成為了Python的解釋器,我們用的比較多的是C版本的Python,也就是使用C語言實現的Python解釋器,除此之外還有使用Java實現的Jython和使用.NET實現的IronPython,這些實現可以使Python用…

Struts優缺點

跟Tomcat、Turbine等諸多Apache項目一樣&#xff0c;是開源軟件&#xff0c;這是它的一大優點。使開發者能更深入的了解其內部實現機制。 Struts開放源碼框架的創建是為了使開發者在構建基于Java Servlet和JavaServer Pages&#xff08;JSP&#xff09;技術的Web應用時更加容易…

由Google Protocol Buffer的小例子引起的g++編譯問題

問題 學習 Google Protocol Buffer 的使用和原理時&#xff0c;提供了一個小例子&#xff0c;講述了protobuf的使用方法。 假如已經有了如下文件&#xff1a; 其中writer.cpp如下&#xff1a;#include "lm.helloworld.pb.h" #include<iostream> #include<…

用python編寫表達式求值_用Python3實現表達式求值

Problem Description yizhen has no girlfriend due to his stupid brain that he even can’t solve a simple arithmetic roblem. Can you help him If you solve it and tell him the result, then he can find his lovers! So beautiful! Input The input一、題目描述請用 …

the first day

開博第一天&#xff0c;從此記錄我生活學習的點滴&#xff0c;加油轉載于:https://www.cnblogs.com/fkissx/p/3702132.html

驅動-問題解決

今天在網上買了一個二手的電腦&#xff0c;拿回來以后&#xff0c;發現有點問題&#xff0c;一個問題就是 1.usb插上U盤以后沒有反應 解決方法&#xff1a; 嘗試一、直接在網上下載了一個360驅動大師&#xff0c;更新了一下驅動&#xff0c;沒有解決 嘗試二、在網上下載了一個驅…

Swift 學習- 02 -- 基礎部分2

class NamedShape{ var numberOfSides: Int 0 var name: String init(name: String) { self.name name } func simpleDecription() -> String { return "A shape with \(numberOfSides) \(name) sides" } } // 除了儲存簡單的屬性之外,屬性可以有 getter 和 set…

R-CNN detection 運行問題及辦法

運行caffe官方提供的jupyter 的rcnn detection&#xff0c;總是出現各種問題。先將問題及方法匯集在此&#xff1a; 1. Selective Search 的安裝問題 按照官網&#xff0c;我下載了selective_search_ijcv_with_python&#xff0c;但是在我的linux matlab2017a上總是出現問題&…

python怎么用lambda和map函數_Python之lambda匿名函數及map和filter的用法

現有兩個元組((a),(b)),((c),(d))&#xff0c;請使用python中匿名函數生成列表[{a:c},{b:d}]t1 ((a), (c))t2 ((b), (d))print(list(map(lambda t: {t[0]: t[1]}, zip(t1, t2))))l lambda t1, t2: [{i: j} for i, j in zip(t1, t2)]print(l(t1, t2))map內置函數使用&#xf…

UVALive 5903 Piece it together(二分圖匹配)

給你一個n*m的矩陣&#xff0c;每個點為B或W或.。然后你有一種碎片。碎片可以旋轉&#xff0c;問可否用這種碎片精確覆蓋矩陣。N,M<500 WB 《碎片 W 題目一看&#xff0c;感覺是精確覆蓋&#xff08;最近被覆蓋洗腦了&#xff09;&#xff0c;但是仔細分析可以知道&#xf…

將undefault和null的數據轉換成bool類型的數據 使用!!

<script> var o{}; var anull; console.info(!!o.name); </script> 輸出false 此方法是將undefault和null的數據轉換成bool類型的數據. var model avalon.define({ $id: model, defaultvalue {},});<span ms-if"!!defaultvalue .cost" >測試</…

springcloud(五):熔斷監控Hystrix Dashboard和Turbine

Hystrix-dashboard是一款針對Hystrix進行實時監控的工具&#xff0c;通過Hystrix Dashboard我們可以在直觀地看到各Hystrix Command的請求響應時間, 請求成功率等數據。但是只使用Hystrix Dashboard的話, 你只能看到單個應用內的服務信息, 這明顯不夠. 我們需要一個工具能讓我們…

如何修改PKG_CONFIG_PATH環境變量

兩種情況&#xff0c;如果你只是想加上某庫的pkg&#xff0c;則選擇下面其一&#xff1a;export PKG_CONFIG_PATH/usr/lib/pkgconfig/ 或者 export PKG_CONFIG_LIBDIR/usr/lib/pkgconfig/ 如果你想覆蓋掉原來的pkg,選擇后者。因為&#xff1a;PKG_CONFIG_LIBDIR的優先級比 PKG_…

python跨包導入包_python引入跨模塊包

人生苦短&#xff0c;我學python。最近學習python&#xff0c;由于包的模塊分的比較多。所以要用到跨模塊引入 且調用中間的方法整體目錄結構如下。需求&#xff1a;在 API模塊 user.py 中 調用 plugin 模塊中 douyin_login 下的方法。貼一下最終解決方案&#xff1a;from plug…