Advertisement
ponchic

Untitled

Nov 3rd, 2015
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.89 KB | None | 0 0
  1. #pragma once
  2. #include <windows.h>
  3.  
  4. namespace SnippingTool {
  5.  
  6.     using namespace System;
  7.     using namespace System::ComponentModel;
  8.     using namespace System::Collections;
  9.     using namespace System::Windows::Forms;
  10.     using namespace System::Data;
  11.     using namespace System::Drawing;
  12.  
  13.     /// <summary>
  14.     /// Сводка для Form1
  15.     /// </summary>
  16.     public ref class Form1 : public System::Windows::Forms::Form
  17.     {
  18.     public:
  19.         Form1(void)
  20.         {
  21.             InitializeComponent();
  22.             //
  23.             //TODO: добавьте код конструктора
  24.             //
  25.         }
  26.  
  27.     protected:
  28.         /// <summary>
  29.         /// Освободить все используемые ресурсы.
  30.         /// </summary>
  31.         ~Form1()
  32.         {
  33.             if (components)
  34.             {
  35.                 delete components;
  36.             }
  37.         }
  38.  
  39.     protected:
  40.  
  41.     protected:
  42.  
  43.     protected:
  44.  
  45.     protected:
  46.  
  47.     private:
  48.         /// <summary>
  49.         /// Требуется переменная конструктора.
  50.         /// </summary>
  51.         System::ComponentModel::Container ^components;
  52.  
  53. #pragma region Windows Form Designer generated code
  54.         /// <summary>
  55.         /// Обязательный метод для поддержки конструктора - не изменяйте
  56.         /// содержимое данного метода при помощи редактора кода.
  57.         /// </summary>
  58.         void InitializeComponent(void)
  59.         {
  60.             this->SuspendLayout();
  61.             //
  62.             // Form1
  63.             //
  64.             this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  65.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  66.             this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
  67.             this->ClientSize = System::Drawing::Size(277, 261);
  68.             this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::SizableToolWindow;
  69.             this->KeyPreview = true;
  70.             this->Name = L"Form1";
  71.             this->Text = L"Form1";
  72.             this->TransparencyKey = System::Drawing::Color::Transparent;
  73.             this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
  74.             this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint);
  75.             this->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::Form1_KeyUp);
  76.             this->Resize += gcnew System::EventHandler(this, &Form1::Form1_Resize);
  77.             this->ResumeLayout(false);
  78.  
  79.         }
  80. #pragma endregion
  81.     private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {      
  82.              }
  83.     private: System::Void Form1_Paint(System::Object^  sender,
  84.                  System::Windows::Forms::PaintEventArgs^  e)
  85.              {
  86.                  // Событие перерисовки экранной формы:
  87.                  //this->ClientSize = System::Drawing::Size(240, 200);
  88.                  // Устанавливаем вершины треугольника:
  89.                  System::Drawing::Rectangle workingRectangle = Screen::PrimaryScreen->WorkingArea;
  90.                  
  91.                  this->Text = "Press Alt + Prt Sc for make screenshot";
  92.                  
  93.                  Point p1 = Point(workingRectangle.Height + workingRectangle.Width, 0);
  94.                  Point p2 = Point(0, 0);
  95.                  Point p3 = Point(0, workingRectangle.Height + workingRectangle.Width);
  96.                  Point p4 = Point(workingRectangle.Height + workingRectangle.Width, workingRectangle.Height + workingRectangle.Width);
  97.                  // Инициализируем массив точек:
  98.                  array<Point> ^ Точки = { p1, p2, p3, p4 };
  99.                  
  100.  
  101.                  // Рисуем закрашенный цветом ControlDark многоугольник:
  102.                  e->Graphics->FillPolygon(gcnew SolidBrush(
  103.                      SystemColors::ControlDark), Точки);
  104.                  // Задаем цвет, который будет выглядеть прозрачным:
  105.                  this->TransparencyKey = SystemColors::ControlDark;
  106.  
  107.  
  108.              }
  109.    
  110.     private: System::Void Form1_Resize(System::Object^  sender, System::EventArgs^  e) {
  111.                 Refresh();
  112.              }
  113.  
  114.                  
  115.  
  116.     private: System::Void Form1_KeyUp(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) {
  117. if (e->KeyCode == Keys::PrintScreen) {
  118.  
  119.     //СОБСТВЕННО ЗДЕСЬ (иЛИ НЕ ЗДЕСЬ) ДОЛЖЕН БЫТЬ КОД СОЗДАНИЯ Bitmap'a прямоугольника
  120.                      System::Threading::Thread::Sleep(1000);
  121.                      Close();
  122.  
  123.  
  124.                  }
  125.          
  126. }
  127.    
  128.    
  129. };
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement