On Jan 12, 2007, at 10:54 PM, Paul Rehill wrote:

I think the workaround only applies if window.visible=false is set in
the IDE rather than code.  The sample project I added to Dennis's
report demonstrates this.

http://support.realsoftware.com/feedback/viewreport.php? reportid=hpeophtv

Terry and Joe, it would be great if you can look at this report,
download my project which has three four of code in it, verify it and
sign on.

Thanks for all replies

Paul

On 1/13/07, Paul Rehill <[EMAIL PROTECTED]> wrote:
Dennis

Further to my last email, your report is correct.  I had
Window1.Visible=True in Window1's open event which overides the
Window1.visible=False set in the IDE.  Hopefully this is a workaround
to my original project problem.

If the results of both your example and Dennis' example were a result of correct coding, I would then consider it a bug. However this is *not* the case as both of you have committed the same sin (error). You have both interrupted the execution of the Open event of the application with your Open code.

To understand why, you must first understand the difference between a Modal type (class) window and the commands .show and .showmodal.

Modal Type window:

This is a class of window than has the following attributes (among others):

1. The quit menuitem is disabled.
2. The ability to change the focus to any other window in your application by clicking on it is disabled.

[Window Name].Show:

1. Creates an implicit (Global) instance of the window if it doesn't already exist and makes it the frontmost window.
2. If it already exists it makes it visible and frontmost.
3. Continues with the execution of the rest of the event's or method's code.

[Window Name].ShowModal:

1. Creates an implicit (Global) instance of the window if it doesn't already exist and makes it the frontmost window.
2. If it already exists it makes it visible and frontmost.
3. *STOPS the execution of the event's or method's code until the window is closed or hidden.*

It does *not* create a modal type window. That is determined by it's Class (Frame property) in the IDE.

To explain further, I will explain what is happening in your code as Dennis' is a bit more complex but similar.

One difference between the two examples is that you have a Default Window: Window1 and Dennis doesn't. This really doesn't make much difference though.

Open event:

The first thing you must understand is that the code you place in event handlers is different on different platforms. You also have no exact idea where in the actual event your code executes. It may be at the beginning, somewhere in the middle or at the end of the actual event. To stop the execution at any point may or may not create spurious results.

This is your example:

Window1 is set in the IDE as Document type and visible=false.

Line 1: Window1.Visible=False

This does the following:

1. Window1: This looks for a Global instance of Window1. If one doesn't exist, it creates one. This will also be important when you get into casting windows but that will come later. In creating the instance, the window's open event executes as well as other things.

2. .Visible=False: This sets the visible property of the window to false (and disables keypresses to the window). It doesn't matter whether it is set to true or false in the IDE as you just reset it.

What you now have is an instance of Window1 that is implicit (Global) and is invisible. It exists (is non nil) and will not respond to keydown.

Line 2: Window1.ShowModal

This does the following:

It looks for a Global instance of Window1. Since it exists, it activates the window and sets it's visible property to true. It then stops the rest of the application's open event from executing which probably affects the ability of the window to trigger it's keydown event.

I cannot say exactly what exact routines are skipped as that is within the framework of Rb and subject to both change and different responses depending on the OS API's. Suffice it to say that the Open events should not be interrupted with Message dialogs or ShowModal.

You also say that the following code won't work:

Window1.Visible=False
Window1.Show

This is actually the correct code and *Not* what you have in your example.

Also 'MsgBox Chr(Asc(Key))' is exactly the same as 'MsgBox Key'. It will show the visible letters but not the invisibles like the arrow keys, Page up, page down, home, end, Return, enter presses. To see the ascii values of any of these keys you would use MsgBox str(Asc (Key)).

So why does Window1.Visible=True work? I cannot say exactly why but my guess is that by calling it in this manner, you have triggered something that enables the window.keydown before Rb would normally do it. When you interrupt the application's Open event, you have already enabled that ability. Some dot commands do not just set a single property as they are actually methods in themselves.

This is in no way comprehensive but does show where the two of you went wrong.

Contact me off list if you still need further explanation.

-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>

Reply via email to