Can I retrieve a variable in another window, in a desktop application?
Thanks for your help.
Yes you can by explicitly referencing it.
windowA.stringProperty = āHelloā
In windowB, a button with the Press Event:
Var strOtherWinVar As String
strOtherWinVar = windowA.stringProperty
MessageBox(strOtherWinVar)
When you say Variable, I presume you mean property of the window. If so then as long as it is Public you are able to access it so long as you have a reference to the instance of the window. You cannot say:
Var IntegerValue as Integer = Window1.MyProperty
Where Window1 is the class of the Window as it would not know which copy of the Window you are referring to. However, code such as:
Var oMyWindow as New Window1
Var IntegerValue as Integer = oMyWindow.MyProperty
Would work, as oMyWindow holds an instance to a given copy of the Window1 class.
ok thanks Iāll give it a try!
Shā¦ It display that window !
How do I do that without displaying that window ?
Set its Visible property to False in the IDE.
Is the window set to āImplicitInstance = trueā
If you are referring to the name of a type of window, rather than the variable holding an instance of the window, then Xojo will make a new window automatically and show it
I was reacting on theā¦ lack of reaction of the OP (18 hours after his thanksā¦).
A closed window has no properties. However, as others have said, hiding the window will still allow you to access its properties. You can use:
oWindow.Hide
As well as visible=false.
As long as you maintain a reference to the window (not an implicit instance) you can still access its properties. The controls will be destroyed and no longer accessible, but any properties will remain. It may seem like a trivial distinction, but it can be very useful.
oWindow.Close
var s as string
s = oWindow.TextField1.Text // no longer available
s = oWindow.SomeProperty // valid
The properties remain until the last reference to the window goes away.
An even finer distinction. Computed properties that rely on underlying controls will not work either.
Hereās what I want to do
Duplicate canvas1 in Window2 (with a canvas independent of the first)
How do I do it? Thanks for your help.
I found it!
for example
Window2.Canvas1.Backdrop=p2
I donāt get it! Ifā¦ Thenā¦Else. doesnāt work!
the Canvas2 remains invisible even if the condition is true!
For Each file As FolderItem In picFolder.Children
Try
nb4=nb4+1
Label6.Text=nb4.ToStringIf file.Name.Left(4)=Format(DateTime.Now.Hour,"00") + Format(DateTime.Now.Minute,"00") then Listbox1.RemoveAllRows Listbox1.AddRowAt(0,file.Name) Var p6 As Picture = ProportionalScale(Picture.Open(file),Canvas2.Width,Canvas2.Height) Canvas2.visible=True Canvas2.Backdrop=p6 livePicture=Picture.Open(file) else Canvas2.visible=False End If
Catch e As IOException
End TryNext
No, the canvas becomes visible if the last processed file doesnt match the condition, EVEN IF a previous one did match.
Not really sure what you are trying to do, but also if ANY matches, you empty the listbox.
That doesnt seem right either.
Try this:
Var p6 As Picture
Canvas2.visible=False
//start invisible. Becomes visible if even ONE file is found.
For Each file As FolderItem In picFolder.Children
Try
nb4=nb4+1
Label6.Text=nb4.ToString
If file.Name.Left(4)=Format(DateTime.Now.Hour,"00") + Format(DateTime.Now.Minute,"00") then
Listbox1.AddRowAt(0,file.Name) //adds the names of all such matching files
p6 = ProportionalScale(Picture.Open(file),Canvas2.Width,Canvas2.Height)
Canvas2.visible=True
Canvas2.Backdrop=p6
livePicture=Picture.Open(file)
//not sure why you open it again here..
// could you use livepicture instead of p6 in the lines above?
End If
Catch e As IOException
End Try
Next
Thank you very much now it works
The solution is meant to be placed on the item that solved the problem, not a random message that it now working The idea is that others with the same or similar problem can look at the solution to help them.
Sorry, thatās been rectified!