?? form1.h
字號:
#pragma once
namespace Example
{
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 摘要
///
/// 警告: 如果您更改該類的名稱,則需要更改
/// 與該類所依賴的所有 .resx 文件關聯的托管資源編譯器工具的
/// “資源文件名”屬性。 否則,
/// 設計器將不能與此窗體關聯的
/// 本地化資源正確交互。
/// </summary>
public __gc class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::PictureBox * pictureBox1;
private: System::Windows::Forms::Button * button1;
private: System::Windows::Forms::Button * button2;
private: System::Windows::Forms::OpenFileDialog * openFileDialog1;
private:
/// <summary>
/// 必需的設計器變量。
/// </summary>
System::ComponentModel::Container * components;
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
void InitializeComponent(void)
{
System::Resources::ResourceManager * resources = new System::Resources::ResourceManager(__typeof(Example::Form1));
this->pictureBox1 = new System::Windows::Forms::PictureBox();
this->button1 = new System::Windows::Forms::Button();
this->button2 = new System::Windows::Forms::Button();
this->openFileDialog1 = new System::Windows::Forms::OpenFileDialog();
this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->pictureBox1->Image = (__try_cast<System::Drawing::Image * >(resources->GetObject(S"pictureBox1.Image")));
this->pictureBox1->Location = System::Drawing::Point(0, 0);
this->pictureBox1->Name = S"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(352, 184);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
//
// button1
//
this->button1->Location = System::Drawing::Point(48, 188);
this->button1->Name = S"button1";
this->button1->Size = System::Drawing::Size(96, 23);
this->button1->TabIndex = 1;
this->button1->Text = S"瀏覽圖像";
this->button1->Click += new System::EventHandler(this, button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(192, 188);
this->button2->Name = S"button2";
this->button2->Size = System::Drawing::Size(96, 23);
this->button2->TabIndex = 2;
this->button2->Text = S"縮放圖片";
this->button2->Click += new System::EventHandler(this, button2_Click);
//
// openFileDialog1
//
this->openFileDialog1->Filter = S"Image files (JPeg, Gif, Bmp, etc.)|*.jpg;*.jpeg;*.gif;*.bmp;*.tif; *.tiff; *.png|"
S" JPeg files (*.jpg;*.jpeg)|*.jpg;*.jpeg |GIF files (*.gif)|*.gif |BMP files (*.b"
S"mp)|*.bmp|Tiff files (*.tif;*.tiff)|*.tif;*.tiff|Png files (*.png)| *.png |All f"
S"iles (*.*)|*.*";
//
// Form1
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(344, 214);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->pictureBox1);
this->MaximizeBox = false;
this->Name = S"Form1";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = S"演示縮放顯示圖片";
this->ResumeLayout(false);
}
private: System::Void button2_Click(System::Object * sender, System::EventArgs * e)
{//縮放圖片
Graphics* g=this->pictureBox1->CreateGraphics();
g->Clear(Color::White);
//裝入圖片
Bitmap* MyImage=(Bitmap*)this->pictureBox1->Image;
for(float MyScale=1;MyScale<1.015;MyScale+=0.0001)
{
g->TranslateTransform(0, 0);
//在水平和垂直方向上同時擴大圖片
g->ScaleTransform(MyScale,MyScale);
g->DrawImage(MyImage,0,0);
System::Threading::Thread::Sleep(10);
}
}
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{//瀏覽圖像
if(this->openFileDialog1->ShowDialog()==DialogResult::OK)
{
Image* MyImage=System::Drawing::Image::FromFile(this->openFileDialog1->FileName);
this->pictureBox1->Image=MyImage;
}
}
};
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -