本文介绍了如何使用SetTimer,KillTimer函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual C ++,我在对话框中插入了三个按钮.当我仅单击一个按钮时,按钮会移动并更改其位置.为此,我使用了Movewindow功能,但问题是按钮在移动时我看不到他们的动作.我不知道如何以及在哪里使用settimer和killtimer,所以我可以查看他们的动作.这里是代码,我不知道如何使用代码标签,所以我将其粘贴在这里:


I am working with visual c++ and i have inserted three buttons on dialogue.When i click only one of the button the buttons move and change their position.For this purpose i have used Movewindow function but problem is that while buttons are moving i cannot see their movement.I donot know how and where to use settimer and killtimer so i can view their movement.Here is the code,i donot konw how to use code tag so i am pasting it here:


void CNadiaDlg::OnButton1()
{
Move();     //on button1 click call move function
   }


void CNadiaDlg::Move()
{
int x2;
srand(time(NULL));
x2=1+rand()%4;
if(x2==1)
{
m_butn1.MoveWindow(30,280,130,60,true);
Sleep(200);
m_butn2.MoveWindow(170,280,130,60,true);
Sleep(200);
m_butn3.MoveWindow(170,10,130,60,true);
Sleep(200);
m_butn2.MoveWindow(30,115,130,60,true);
Sleep(200);
m_butn1.MoveWindow(320,115,130,60,true);
Sleep(200);
m_butn3.MoveWindow(170,115,130,60,true);
}
else if(x2==2)
{
/////////////////////////////////////////////////////////////////////////////////
m_butn1.MoveWindow(30,280,130,60,true);
Sleep(200);
m_butn2.MoveWindow(170,280,130,60,true);
Sleep(200);
m_butn3.MoveWindow(170,10,130,60,true);
Sleep(200);
m_butn3.MoveWindow(30,115,130,60,true);
Sleep(200);
m_butn2.MoveWindow(320,115,130,60,true);
Sleep(200);
m_butn1.MoveWindow(170,115,130,60,true);
}
else if(x2==3)
{
/////////////////////////////////////////////////////////////////////////////////
m_butn1.MoveWindow(30,280,130,60,true);
Sleep(200);
m_butn2.MoveWindow(170,280,130,60,true);
Sleep(200);
m_butn3.MoveWindow(170,10,130,60,true);
Sleep(200);
m_butn1.MoveWindow(30,115,130,60,true);
Sleep(200);
m_butn2.MoveWindow(320,115,130,60,true);
Sleep(200);
m_butn3.MoveWindow(170,115,130,60,true);
}


按钮在随机移动,但是我看不到它们的移动.


Buttons are moving randomly but i cannot see their movement.

推荐答案




这篇关于如何使用SetTimer,KillTimer函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 16:54