On Nov 22, 2006, at 9:45 AM, Sven E Olsson wrote:
Today I have try to Open and Close a Window as Hidden. Why? I need
this to "initialize" my Editor Window on startup, because the
first time I Open a Window+file it take very loooong time to do
that. (Just like all other Windows that is opening the first time,
take about 100% longer time to open than the second time)
(See also the thread (todays) Caching fonts for better performance
Here is problem no 1 (in the App Open Event):
//
Dim w as new TextWindow
w.visible = false
w.show
//
Well that's pretty simple as "w.show" will make the TextWindow
visible and frontmost.
The window is opened on the first line... and the second parameter
looks not to have an affect.
Take out the "w.show and it will be invisible And exist.
Also, If the Windows Property Visible= false, it has no affect when
I create the window on the fly!
Same reason; w.show makes it visible.
In RB it is impossible to do this:
//
Dim w as TextWindow
This simply defines w as a TextWindow. You haven't instantiated it
yet with a New.
w.Visible = False
w.myBoolean = true
w.Height = 200
w.width = 300
w.Visible = False
w.myBoolean = true
w.Height = 200
w.width = 300
w.Init (create the window using the parameters)
w.SHOW (Open/Show the Window using the parameters)
All these lines result in errors as the widow referred to by "w"
doesn't exist yet.
This won't work because "w" still refers to a non-existing window and
you are calling a method (init) in a window that doesn't exist yet.
w.SHOW (Open/Show the Window using the parameters)
Same problem. If you cast "w" to be an instance of a new window you
must create it by saying "w=New TextWindow".
Problem no 2:
I just put in the App Open Event: (The window property
Visible=false take now affect)
TextWindow.Show
TextWindow.Close
Well, in this code you use actually implicit instantiation to create
a global (singleton) instance of TextWindow. After line 1, you
immediately close it in line 2. Of course you won't see it and it
also is useless. It is invisible as it is not addressable anymore as
it is closed. TextWindow.Hide or an IDE setting of Visible=False
would still keep it accessible but not visible. It is still a Global
(implicit) instance, however, and a separate instance cannot be
created without casting w to be a New instance as you did in the
first code example.
But it look that when the window is closed, I get flicker in
compiled apps!
Any ideas, how to "Initialize a Window" ??
Well, first of all, you should delve into the two types of
instantiation of a window. It appears that, although you have worked
with Rb for many years, this might be an area that you might be
lacking some understanding in.
As far as initializing a window there are two ways. If you are
creating it by casting a variable such as "Dim w As New TextWindow"
you can use a Constuctor in a method in the window. If you wish an
implicit instance you can simply call a method in the window such as
"init" by saying TextWindow.init. You can even pass parameters to
both types of methods in the calling statement.
The main difference is wheter you wish more than one instance of the
window to exist at the same time. With implicit instantiation there
can only be one. Casting it to a variable will allow more than one.
I hope this helps.
Terry
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>