📄 scrollbar.cpp
字号:
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
// required dlls for WinForms
#using "System.dll"
#using "System.Windows.Forms.dll"
#using "System.Drawing.dll"
// required namespaces for WinForms
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using namespace System::Drawing;
using namespace System::Diagnostics;
__gc class WinForm: public Form
{
private:
Windows::Forms::VScrollBar* pVScrollBar;
Windows::Forms::LinkLabel * pLinkLabel;
Windows::Forms::NotifyIcon* pNotifyIcon1;
Windows::Forms::ContextMenu * pContextMenu;
MenuItem *pQuitItem;
public:
WinForm()
{
InitForm();
}
void ~WinForm()
{
// Form is being destroyed. Do any necessary clean-up here.
Form::Dispose();
}
void InitForm()
{
pVScrollBar=new Windows::Forms ::VScrollBar();
pVScrollBar->Size =Drawing::Size (30,ClientSize .Height );
pVScrollBar->Minimum =0;
pVScrollBar->Maximum =ClientSize .Height ;
pVScrollBar->SmallChange =ClientSize .Height/2000;
pVScrollBar->LargeChange =ClientSize .Height/20;
pVScrollBar->Dock =DockStyle::Right ;
pVScrollBar->Value=ClientSize .Height/2;
pVScrollBar->add_Scroll (new ScrollEventHandler(this,onVScroll));
pVScrollBar->add_ValueChanged (new EventHandler(this,onValueChange));
pLinkLabel=new Windows::Forms::LinkLabel ();
pLinkLabel->Text =S"欢迎你来信提出宝贵意见";
pLinkLabel->Location=Drawing::Point(16, 232);
pLinkLabel->Name =S"linkLabel1";
pLinkLabel->add_LinkClicked (new LinkLabelLinkClickedEventHandler (this,OnClick));
pNotifyIcon1=new Windows::Forms::NotifyIcon ();
pContextMenu=new Windows::Forms::ContextMenu();
pQuitItem = new MenuItem();
pQuitItem->Click+=new EventHandler(this,WinForm::QuitItem_Click);
//设置菜单单击事件
//WinForm为当前的窗体对象名称
pQuitItem->Text=L"退出〔&X〕";
pQuitItem->Shortcut =Shortcut::CtrlX;
pQuitItem->Checked = false;
pContextMenu->MenuItems->Add(pQuitItem);
ContextMenu=pContextMenu;
pNotifyIcon1->ContextMenu = pContextMenu;
pNotifyIcon1->Icon = new Drawing::Icon ("Icon1.ico");;
pNotifyIcon1->Text = "欢迎你使用本系统";
pNotifyIcon1->Visible = true;
//pNotifyIcon1->add_DoubleClick (new EventHandler(this,WinForm::QuitItem_Click));
Controls->Add (pLinkLabel);
Controls->Add (pVScrollBar);
// Setup controls here
}
void onVScroll(Object * pSender,ScrollEventArgs *pS)
{
}
void onValueChange(Object * pSender,EventArgs *pS)
{
}
void OnClick(Object * pSender,LinkLabelLinkClickedEventArgs *pS)
{
pLinkLabel->LinkVisited = true;
System::Diagnostics::Process* pProcess=new System::Diagnostics::Process();
pProcess->EnableRaisingEvents =false;
pProcess->Start("IExplore.exe", "http://www.microsoft.com");
}
void QuitItem_Click(Object *Sender,EventArgs *s)
{
Close();
}
};
void main()
{
// This line creates an instance of WinForm, and
// uses it as the Main Window of the application.
Application::Run(new WinForm());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -