Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Label doesn't show up as expected on CEForm

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Master Cheater
Reputation: 1

Joined: 17 Feb 2016
Posts: 490

PostPosted: Mon Jul 31, 2017 7:38 am    Post subject: Label doesn't show up as expected on CEForm Reply with quote

Code:

     local myform = createForm(false)
     myform.Caption = "Please wait"
     myform.BorderStyle = 'bsDialog'
     myform.AutoSize = true
     myform.Position = 'poScreenCenter'
     myform.FormStyle = 'fsStayonTop'

     local mylabel = createLabel(myform)
     mylabel.Caption = "Initializing。。。"
     mylabel.BorderSpacing.Around = 20

     local font=mylabel.Font
     font.Size = 12
     font.Color = 0x0000ff
     myform.show()
     .....do something else
     myform.destroy()
     


I want to create a form with a label and close the form after some other operations (I don't want to use a timer because the time consumed by those operations is uncertain), but the label never showed up. Moreover,

Code:

     local myform = createForm(false)
     myform.Caption = "Please wait"
     myform.BorderStyle = 'bsDialog'
     myform.AutoSize = true
     myform.Position = 'poScreenCenter'
     myform.FormStyle = 'fsStayonTop'

     local mylabel = createLabel(myform)
     mylabel.Caption = "Initializing。。。"
     mylabel.BorderSpacing.Around = 20

     local font=mylabel.Font
     font.Size = 12
     font.Color = 0x0000ff
     myform.show()
     sleep(5000) <-----------
     


I did some test with this piece of code, the label only showed up after "sleep(5000)", but I want it to show before the sleep function.

So what's the problem?

Thanks.

_________________
**************

A simple example is better then ten links. Very Happy
Back to top
View user's profile Send private message
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 51

Joined: 06 Jul 2014
Posts: 1745
Location: Arcadian Suburbia

PostPosted: Mon Jul 31, 2017 9:53 am    Post subject: Reply with quote

The thread executing the Lua code is the same thread responsible for the GUI. Either let the thread process new messages before doing the work, or do the work asynchronously.
Code:
...
myform.show()
processMessages()
-- do stuff
myform.destroy()

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dr.Disrespect
Master Cheater
Reputation: 1

Joined: 17 Feb 2016
Posts: 490

PostPosted: Mon Jul 31, 2017 10:24 am    Post subject: Reply with quote

ParkourPenguin wrote:
The thread executing the Lua code is the same thread responsible for the GUI. Either let the thread process new messages before doing the work, or do the work asynchronously.
Code:
...
myform.show()
processMessages()
-- do stuff
myform.destroy()


Thanks, Penguin. It works perfectly now.

BTW, I tried to use the thread class to fix the problem, but it didn't work. I might have done something wrong.

_________________
**************

A simple example is better then ten links. Very Happy
Back to top
View user's profile Send private message
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 51

Joined: 06 Jul 2014
Posts: 1745
Location: Arcadian Suburbia

PostPosted: Mon Jul 31, 2017 11:24 am    Post subject: Reply with quote

Code:
...
myform.show()
createThread(function(t)
  -- do stuff
  t.synchronize(function(t) myform.destroy() end)
end)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dr.Disrespect
Master Cheater
Reputation: 1

Joined: 17 Feb 2016
Posts: 490

PostPosted: Tue Aug 01, 2017 10:14 am    Post subject: Reply with quote

ParkourPenguin wrote:
Code:
...
myform.show()
createThread(function(t)
  -- do stuff
  t.synchronize(function(t) myform.destroy() end)
end)


Thanks again! Very Happy

_________________
**************

A simple example is better then ten links. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites