|
C++ Builder로 만들어 봤습니다.
<dfm 파일>
object Form1: TForm1
Left = 442
Top = 233
Width = 247
Height = 190
Caption = '100 까지 합구하기'
Color = clBtnFace
Constraints.MaxHeight = 190
Constraints.MaxWidth = 247
Constraints.MinHeight = 190
Constraints.MinWidth = 247
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 10
Top = 10
Width = 131
Height = 13
AutoSize = False
Caption = '현재 더해질려는 숫자'
end
object Label2: TLabel
Left = 10
Top = 40
Width = 131
Height = 13
AutoSize = False
Caption = '지금까지의 합'
end
object Bevel1: TBevel
Left = 5
Top = 60
Width = 226
Height = 6
Shape = bsBottomLine
end
object Label3: TLabel
Left = 10
Top = 75
Width = 131
Height = 13
AutoSize = False
Caption = '결 과'
end
object Bevel2: TBevel
Left = 0
Top = 5
Width = 236
Height = 101
end
object CGauge1: TCGauge
Left = 0
Top = 110
Width = 236
Height = 21
end
object StaticText1: TStaticText
Left = 150
Top = 7
Width = 71
Height = 19
AutoSize = False
TabOrder = 0
end
object StaticText2: TStaticText
Left = 150
Top = 37
Width = 71
Height = 19
AutoSize = False
TabOrder = 1
end
object StaticText3: TStaticText
Left = 150
Top = 72
Width = 71
Height = 19
AutoSize = False
TabOrder = 2
end
object Button1: TButton
Left = 0
Top = 135
Width = 236
Height = 25
Caption = '100까지의 합을 구해봅시다.'
TabOrder = 3
OnClick = Button1Click
end
object Timer1: TTimer
Enabled = False
Interval = 500
OnTimer = Timer1Timer
Left = 195
Top = 25
end
end
<헤드 파일>
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "CGAUGES.h"
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TTimer *Timer1;
TLabel *Label1;
TStaticText *StaticText1;
TLabel *Label2;
TStaticText *StaticText2;
TBevel *Bevel1;
TLabel *Label3;
TStaticText *StaticText3;
TBevel *Bevel2;
TCGauge *CGauge1;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Timer1Timer(TObject *Sender);
private: // User declarations
int nCount;
int nResult;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
<cpp 파일>
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CGAUGES"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
nCount = 0;
nResult = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if(nCount <= 100){
nResult += nCount;
CGauge1->Progress = nCount;
StaticText1->Caption = IntToStr(nCount);
StaticText2->Caption = IntToStr(nResult);
nCount++;
}
StaticText3->Caption = IntToStr(nResult);
}
//---------------------------------------------------------------------------
|