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 


Form label "Tag" setting problem.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Wed Jan 26, 2022 10:01 am    Post subject: Form label "Tag" setting problem. Reply with quote

I've had this problem before because I fixed it by assigning a "Height" value.
Now I don't know how long the next word is, so instead of presetting the height, I want "Tag" to determine the height.

This is the working code:

Code:
if form then form.destroy() form = nil end
form = createForm()
form.Popupmode = 0;
form.Position = poDesktopCenter
form.Width = 220
form.Height = 240

local wrd1="aaaaaaaaa ssssssssssss ddddddd fffffffffff ghgggggggggg hhhhhhhhhhh jjjjjjjjjjjj xxxxxxxxxxxxx sssssssssssssss ffffffffffffffff ggggggggggggg hhhhhhhhhhhhhhhhhh"

l1=createLabel(form)
l1.AutoSize=false
l1.Alignment="taCenter"
l1.Left=10
l1.Top=30
l1.Width=200
l1.Height=75
l1.caption=wrd1
l1.Font.Size=11
l1.OptimalFill=true
l1.Tag=190
l1.visible=true
l1.WordWrap=true

print(l1.Height) --75


But I want it to be like this:

Code:
if form then form.destroy() form = nil end
form = createForm()
form.Popupmode = 0;
form.Position = poDesktopCenter
form.Width = 220
form.Height = 240

local wrd1="aaaaaaaaa ssssssssssss ddddddd fffffffffff ghgggggggggg hhhhhhhhhhh jjjjjjjjjjjj xxxxxxxxxxxxx sssssssssssssss ffffffffffffffff ggggggggggggg hhhhhhhhhhhhhhhhhh"

l1=createLabel(form)
l1.AutoSize= false
l1.Alignment="taCenter"
l1.Left=10
l1.Top=30
l1.Width=200
--l1.Height=75
--l1.OptimalFill=true
l1.caption=wrd1
l1.Tag=190
l1.Font.Size=11
l1.visible=true
l1.WordWrap=true

print(l1.Height .. " - " .. l1.Width) -- 1 - 200


Is there a solution for this?
Back to top
View user's profile Send private message
Skyrimfus
Cheater
Reputation: 1

Joined: 17 Mar 2016
Posts: 42

PostPosted: Wed Jan 26, 2022 10:28 am    Post subject: Reply with quote

The "Tag" property has nothing to do with the width/height of the label. Read:https://docs.microsoft.com/en-us/office/vba/api/access.label.tag
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Wed Jan 26, 2022 11:02 am    Post subject: Reply with quote

Skyrimfus is partially right, the link is not correct in this instance. Cheat Engine was created using a mix of languages, including Pascal and as such, the tag property is there to discern the differences between two similar objects when dealing with events so that the caller knows which object to handle when queried.
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Wed Jan 26, 2022 12:19 pm    Post subject: Reply with quote

If you only have suggestions for solutions, I think you should join the thread.
Although it is not a frequently requested issue, I give the following solution example until a different solution comes out:

Code:
if form then form.destroy() form = nil end
form = createForm()
form.Popupmode = 0;
form.Position = poDesktopCenter
form.Width = 220
form.Height = 240

local wrd1="aaaaaaaaa ssssssssssss ddddddd fffffff ffff ghgggg gggggg hhhhhh hhhhh jjjjjjj jjjjj xxxxxxx xxxxxx sssssss ssssssss fffffffff fffffff gggggggg ggggg hhhhhh hhhhhh hhhhhh"

l1=createLabel(form)
l1.Alignment="taCenter"
l1.Left=10
l1.Top=30
l1.Width=200
l1.Font.Size=10

local lineWord=""
local lineWord1=""
local lines=1
local wrd3=0

for w in wrd1:gmatch("%S+") do --print(w) end
aa=tonumber(#w) * 10
wrd3=tonumber(wrd3) + aa
lineWord = lineWord .. w .. " "
print(wrd3 )
if tonumber(wrd3)>200 then
lineWord1 = lineWord1 .. lineWord .. "\n"
lines=tonumber(lines) + 1
print(lineWord1 .. " - " .. wrd3)
lineWord=""
wrd3=0
end
end
lineWord1 = lineWord1 .. lineWord
lines=tonumber(lines) * 17
l1.AutoSize=false
l1.caption=wrd1
l1.Width=200
l1.Height=tonumber(lines)
l1.caption=lineWord1

print(l1.Height .. " - " .. l1.Width)


It is still open to shorter samples. Wink
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