타이머에서 모두 처리하지 않아도 됩니다.
움직임 감지 카운트용 변수(타임아웃용)를 선언한 후
마우스 이동 이벤트에서 움직임 감지 변수 초기화(0)
타이머에서 움직임 감지 변수 카운트하여 1초 이상 경과시 움직임 없음 처리하면 됩니다.
예)
// 헤더 파일
// 폼 맴버변수로 선언
class TForm1 : public TForm
{
public:
int TimeouttMouseMove;
};
// 소스 파일
// 생성자에 변수 초기화
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
TimeouttMouseMove = 0;
Timer1->Interval = 100; // 100ms 타이머 설정
Timer1->Enable = true; // 타이머 동작
}
// 타이머 이벤트
void __fastcall TFrom1::Timer1Timer(TObect *Sender)
{
if(TimeouttMouseMove >= 10) { // 10 * 100ms => 1초
Edit1->Text = "NO";
}
else {
TimeouttMouseMove++;
Edit1->Text = "AB";
}
}
// 마우스 이동 이벤트
void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
// 카운트 초기화
TimeouttMouseMove = 0;
}
|