Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Oblivion is currently offline  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


[Updated on: Thu, 26 October 2023 21:27]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Java Script
Next Topic: How do I write string_view to Cout() without copying to a String?
Goto Forum:
  


Current Time: Sat Aug 23 20:05:03 CEST 2025

Total time taken to generate the page: 0.03736 seconds