C++ Builder XE4, 10.2 Tokyo > TPageControl + TFrame > TButton에서 페이지(TFrame) 추가
12931 단어 TPageControlcppBuilder
C++ Builder XE4
RAD Studio 10.2 Tokyo Update 2 (追記: 2018/01/05)
TPageControl에 TFrame 페이지를 추가하고 싶습니다.
구성
Unit2의 디자인은 이하.
참고
papy 님의 언어 게시판
h tp // w w. Papy. in / bs / lp / 200906/09060057. HTML
정보 감사입니다.
코드
Unit2.h
//---------------------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TFrame2 : public TFrame
{
__published: // IDE で管理されるコンポーネント
TLabel *Label1;
TTimer *Timer1;
void __fastcall Timer1Timer(TObject *Sender);
private: // ユーザー宣言
public: // ユーザー宣言
__fastcall TFrame2(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TFrame2 *Frame2;
//---------------------------------------------------------------------------
#endif
Unit2.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFrame2 *Frame2;
//---------------------------------------------------------------------------
__fastcall TFrame2::TFrame2(TComponent* Owner)
: TFrame(Owner)
{
Timer1->Enabled = false;
Timer1->Interval = 5000; // msec
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TFrame2::Timer1Timer(TObject *Sender)
{
String msg = Now().FormatString(L"yyyy/mm/dd hh:nn:ss");
OutputDebugString(msg.c_str());
}
//---------------------------------------------------------------------------
Unit1.h
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ComCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE で管理されるコンポーネント
TPageControl *PageControl1;
TButton *B_add;
TButton *B_delete;
void __fastcall B_addClick(TObject *Sender);
void __fastcall B_deleteClick(TObject *Sender);
private: // ユーザー宣言
public: // ユーザー宣言
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B_addClick(TObject *Sender)
{
int count = PageControl1->PageCount;
TTabSheet *pPage = new TTabSheet(PageControl1);
pPage->PageControl = PageControl1;
pPage->Caption = L"Page" + IntToStr(count);
pPage->Name = L"ts" + IntToStr(count);
TFrame2 *pFrame = new TFrame2(pPage);
pFrame->Parent = pPage;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B_deleteClick(TObject *Sender)
{
int count = PageControl1->PageCount;
if (count == 0) {
return;
}
delete PageControl1->Pages[count - 1];
}
//---------------------------------------------------------------------------
실행
페이지를 늘리면 디버그 출력이 늘어납니다.
デバッグ出力: 2017/11/01 19:00:18 プロセス Project1.exe (2240)
デバッグ出力: 2017/11/01 19:00:19 プロセス Project1.exe (2240)
デバッグ出力: 2017/11/01 19:00:20 プロセス Project1.exe (2240)
デバッグ出力: 2017/11/01 19:00:21 プロセス Project1.exe (2240)
デバッグ出力: 2017/11/01 19:00:21 プロセス Project1.exe (2240)
デバッグ出力: 2017/11/01 19:00:22 プロセス Project1.exe (2240)
デバッグ出力: 2017/11/01 19:00:22 プロセス Project1.exe (2240)
デバッグ出力: 2017/11/01 19:00:23 プロセス Project1.exe (2240)
デバッグ出力: 2017/11/01 19:00:23 プロセス Project1.exe (2240)
Reference
이 문제에 관하여(C++ Builder XE4, 10.2 Tokyo > TPageControl + TFrame > TButton에서 페이지(TFrame) 추가), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/7of9/items/9b83cfafec6c323fdef0텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)