📄 controls.cpp
字号:
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#using <mscorlib.dll>
#using <System.DLL>
#using <System.Windows.Forms.DLL>
#using <System.Drawing.DLL>
#include <tchar.h>
using namespace System;
using namespace System::Windows::Forms;
using namespace System::Drawing;
__gc class MyFormClass : public Form {
protected:
Button *button;
TextBox *textbox;
ListBox *listbox;
StatusBar *statusbar;
StatusBarPanel *panel;
public:
void AddControls() {
Width = 400;
Height = 275;
textbox = new TextBox;
textbox->Text = "";
textbox->Left = 25;
textbox->Top = 5;
textbox->Width = 100;
button = new Button;
button->Text = "Click!";
button->Left = 25;
button->Top = 60;
button->Width = 75;
button->Click += new EventHandler(
this, MyFormClass::Click);
listbox = new ListBox;
listbox->Left = 150;
listbox->Top = 5;
listbox->Width = 200;
listbox->Height = 200;
String *InitialList[] = {"red", "orange",
"yellow", "green", "blue",
"indigo", "violet"};
listbox->Items->AddRange(InitialList);
statusbar = new StatusBar;
panel = new StatusBarPanel;
panel->BorderStyle = StatusBarPanelBorderStyle::Sunken;
panel->AutoSize = StatusBarPanelAutoSize::Spring;
statusbar->Panels->Add(panel);
statusbar->ShowPanels = true;
panel->Text = "Ready";
Control* controls[] = {textbox, button,
listbox, statusbar};
this->Controls->AddRange(controls);
}
void Click(Object* sender, EventArgs* e)
{
String *str = textbox->Text;
listbox->Items->Add(str);
panel->Text = String::Concat(S"Added ",str);
}
};
// This is the entry point for this application
int _tmain(void)
{
MyFormClass *MyForm = new MyFormClass();
MyForm->AddControls();
MyForm->ShowDialog();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -