我run時
程式里的timer1就直接開始了
我用
Form1->Hide();
Form2->Show();
切換視窗的,所以者么換到Form2后按下開啟鈕button才開始跑timer1
我在開始扭那打了
Timer1->Enabled = true;
uj5u.com熱心網友回復:
在設計模式下把timer1的Enable設成falseuj5u.com熱心網友回復:
//---------------------------------------------------------------------------#include <vcl.h>
#pragma hdrstop
#include "Unit4.h"
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
int x;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button1Click(TObject *Sender)
{
Form3->Hide();
Form4->Show();
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Timer2Timer(TObject *Sender)
{
Timer1->Enabled = false;
}
//---------------------------------------------------------------------------
int a1=0,a2=0,a3=0,a4=0,a5=0;
void __fastcall TForm3::Timer1Timer(TObject *Sender)
{
if (a1==1)
{
Image1->Top = Image1->Top;
}
else
Image1->Top = Image1->Top;
if (Image1->Top >=Height )
Image1->Top = 0;
if (a2==1)
{
Image2->Top = Image2->Top;
}
else
Image2->Top = Image2->Top;
if (Image2->Top >=Height )
Image2->Top = 0;
if (a3==1)
{
Image3->Top = Image3->Top;
}
else
Image3->Top = Image3->Top;
if (Image3->Top >=Height )
Image3->Top = 0;
if (a4==1)
{
Image4->Left = Image4->Left;
}
else
Image4->Left = Image4->Left;
if ( Image4->Left >= Width)
Image4->Left = 0;
if (a5==1)
{
Image5->Left = Image5->Left;
}
else
Image5->Left = Image5->Left;
if ( Image5->Left >= Width)
Image5->Left = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image1Click(TObject *Sender)
{
a1=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image2Click(TObject *Sender)
{
a2=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image3Click(TObject *Sender)
{
a3=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image4Click(TObject *Sender)
{
a4=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image5Click(TObject *Sender)
{
a5=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
跑不動
uj5u.com熱心網友回復:
//---------------------------------------------------------------------------#include <vcl.h>
#pragma hdrstop
#include "Unit5.h"
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
int x;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button2Click(TObject *Sender)
{
Form3->Hide();
Form5->Show();
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button1Click(TObject *Sender)
{
Timer1->Enabled = false;
Label3->Visible = false;
Button1->Visible = false;
Button2->Visible = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Timer2Timer(TObject *Sender)
{
Timer1->Enabled = false;
Button1->Visible = false;
Button2->Visible = true;
Label3->Visible = true;
Timer2->Enabled = false;
Image1->Visible = false;
Image2->Visible = false;
Image3->Visible = false;
Image4->Visible = false;
Image5->Visible = false;
}
//---------------------------------------------------------------------------
int a1=0,a2=0,a3=0,a4=0,a5=0;
void __fastcall TForm3::Timer1Timer(TObject *Sender)
{
if (a1==1)
{
Image1->Top = Image1->Top;
}
else
Image1->Top = Image1->Top;
if (Image1->Top >=Height )
Image1->Top = 0;
if (a2==1)
{
Image2->Top = Image2->Top;
}
else
Image2->Top = Image2->Top;
if (Image2->Top >=Height )
Image2->Top = 0;
if (a3==1)
{
Image3->Top = Image3->Top;
}
else
Image3->Top = Image3->Top;
if (Image3->Top >=Height )
Image3->Top = 0;
if (a4==1)
{
Image4->Left = Image4->Left;
}
else
Image4->Left = Image4->Left;
if ( Image4->Left >= Width)
Image4->Left = 0;
if (a5==1)
{
Image5->Left = Image5->Left;
}
else
Image5->Left = Image5->Left;
if ( Image5->Left >= Width)
Image5->Left = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image1Click(TObject *Sender)
{
a1=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image2Click(TObject *Sender)
{
a2=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image3Click(TObject *Sender)
{
a3=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image4Click(TObject *Sender)
{
a4=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Image5Click(TObject *Sender)
{
a5=0;
x+=10;
Label2->Caption=IntToStr(x);
}
//---------------------------------------------------------------------------
上面是跑得動的~但是這個的話就跑不動
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/119858.html
標籤:基礎類
上一篇:MFC歌詞的同步顯示
下一篇:teechart 屬性改不了
