Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <windows.h>
- namespace SnippingTool {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- /// <summary>
- /// Сводка для Form1
- /// </summary>
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- //
- //TODO: добавьте код конструктора
- //
- }
- protected:
- /// <summary>
- /// Освободить все используемые ресурсы.
- /// </summary>
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- protected:
- protected:
- protected:
- protected:
- private:
- /// <summary>
- /// Требуется переменная конструктора.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Обязательный метод для поддержки конструктора - не изменяйте
- /// содержимое данного метода при помощи редактора кода.
- /// </summary>
- void InitializeComponent(void)
- {
- this->SuspendLayout();
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
- this->ClientSize = System::Drawing::Size(277, 261);
- this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::SizableToolWindow;
- this->KeyPreview = true;
- this->Name = L"Form1";
- this->Text = L"Form1";
- this->TransparencyKey = System::Drawing::Color::Transparent;
- this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
- this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint);
- this->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::Form1_KeyUp);
- this->Resize += gcnew System::EventHandler(this, &Form1::Form1_Resize);
- this->ResumeLayout(false);
- }
- #pragma endregion
- private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
- }
- private: System::Void Form1_Paint(System::Object^ sender,
- System::Windows::Forms::PaintEventArgs^ e)
- {
- // Событие перерисовки экранной формы:
- //this->ClientSize = System::Drawing::Size(240, 200);
- // Устанавливаем вершины треугольника:
- System::Drawing::Rectangle workingRectangle = Screen::PrimaryScreen->WorkingArea;
- this->Text = "Press Alt + Prt Sc for make screenshot";
- Point p1 = Point(workingRectangle.Height + workingRectangle.Width, 0);
- Point p2 = Point(0, 0);
- Point p3 = Point(0, workingRectangle.Height + workingRectangle.Width);
- Point p4 = Point(workingRectangle.Height + workingRectangle.Width, workingRectangle.Height + workingRectangle.Width);
- // Инициализируем массив точек:
- array<Point> ^ Точки = { p1, p2, p3, p4 };
- // Рисуем закрашенный цветом ControlDark многоугольник:
- e->Graphics->FillPolygon(gcnew SolidBrush(
- SystemColors::ControlDark), Точки);
- // Задаем цвет, который будет выглядеть прозрачным:
- this->TransparencyKey = SystemColors::ControlDark;
- }
- private: System::Void Form1_Resize(System::Object^ sender, System::EventArgs^ e) {
- Refresh();
- }
- private: System::Void Form1_KeyUp(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) {
- if (e->KeyCode == Keys::PrintScreen) {
- //СОБСТВЕННО ЗДЕСЬ (иЛИ НЕ ЗДЕСЬ) ДОЛЖЕН БЫТЬ КОД СОЗДАНИЯ Bitmap'a прямоугольника
- System::Threading::Thread::Sleep(1000);
- Close();
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement