Home » Community » Newbie corner » While loop, sleep
Re: While loop, sleep [message #60260 is a reply to message #60259] |
Thu, 26 October 2023 21:03   |
Oblivion
Messages: 1226 Registered: August 2007
|
Senior Contributor |
|
|
Ok, the following code works on win 10:
#include <CtrlLib/CtrlLib.h>
#include <windows.h>
using namespace Upp;
static bool sClose;
struct MyApp : TopWindow {
Button bt;
MyApp()
{
CenterScreen().SetRect(0, 0, 640, 480);
Add(bt.SetLabel("Click me!").HCenterPos().VCenterPos());
WhenClose << [=] { sClose = true; };
bt << [=] {
Point p;
GetCursorPos(p);
while(p.y-- > 0 && !sClose) {
ProcessEvents();
SetCursorPos(p.x, p.y);
Title("Cursor pos (y): " << AsString(p.y));
GuiSleep(20);
}
};
}
};
GUI_APP_MAIN
{
MyApp().Run();
}
Edit: Example refactored.
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Thu, 26 October 2023 21:27] Report message to a moderator
|
|
|
 |
|
While loop, sleep
|
 |
|
Re: While loop, sleep
By: koldo on Thu, 26 October 2023 09:03
|
 |
|
Re: While loop, sleep
By: Oblivion on Thu, 26 October 2023 11:44
|
 |
|
Re: While loop, sleep
|
 |
|
Re: While loop, sleep
By: Oblivion on Thu, 26 October 2023 17:44
|
 |
|
Re: While loop, sleep
|
 |
|
Re: While loop, sleep
By: Oblivion on Thu, 26 October 2023 21:03
|
 |
|
Re: While loop, sleep
|
 |
|
Re: While loop, sleep
By: zsolt on Fri, 27 October 2023 17:43
|
 |
|
Re: While loop, sleep
By: Klugier on Fri, 27 October 2023 21:50
|
 |
|
Re: While loop, sleep
|
 |
|
Re: While loop, sleep
By: Klugier on Sun, 29 October 2023 20:22
|
 |
|
Re: While loop, sleep
|
Goto Forum:
Current Time: Sat Aug 23 20:05:03 CEST 2025
Total time taken to generate the page: 0.03736 seconds
|