We help IT Professionals succeed at work.

Where am I? For the interested expert!

Sjef Bosman
Sjef Bosman asked
on
417 Views
Last Modified: 2013-12-18
Hi experts,

Continuing my quest for the frame/form/view I'm in, I have built the class below. I have a frameset with 3 frames, and I want to find out where the focus is. In a later stage I want to shift the focus away from the current frame depending on the name of the form or view in the frame.

An object is instantiated in a form as follows:

Global Declarations:
Dim obj As MoveFocus

PostOpen event:
Set obj= New MoveFocus("formorviewname")
Call obj.Activate

and in a Script Library or in the Declarations section as well:
Class SpxMoveFocus
      Private elapsedTimer As NotesTimer
      Private ws As NotesUIWorkspace
      Private vname As String
      
      Sub New(nm As String)
            Print "New"
            Set elapsedTimer = New NotesTimer(1)
            elapsedTimer.Enabled= False            
            vname= nm
      End Sub
      
      Sub Activate
            On Event Alarm From elapsedTimer Call TimerHandler
            elapsedTimer.Enabled= True
      End Sub
      
      Sub DeActivate
            elapsedTimer.Enabled= False      
      End Sub
      
      Sub Blur
            Print "Blur"
      End Sub
      
      Private Sub TimerHandler(Source As NotesTimer)
            Dim s As String
            Dim uidoc As NotesUIDocument
            Dim doc As NotesDocument
            Dim uiview As NotesUIView
            Dim view As NotesView
            
            On Error Goto onerror
            Set ws= New NotesUIWorkspace
            If ws Is Nothing Then
                  Call DeActivate
                  Exit Sub
            End If
            Set uidoc= ws.CurrentDocument
            Set uiview= ws.CurrentView
            If Not(uidoc Is Nothing) Then      
                  Print "uidoc"
                  Set doc= uidoc.Document
                  If Not(doc Is Nothing) Then
                        Print "doc"
                        If doc.HasItem("Form") Then
                              Print "form"
                              s= doc.Form(0)
                              Print "String: " s
                              If s=vname Then
                                    Call Blur
                              End If
                        End If
                  End If
            End If
            If Not(uiview Is Nothing) Then
                  Print "uiview"
                  Set view= uiview.View
                  If Not(view Is Nothing) Then
                        Print "view"
                        s= view.Name
                        Print "String: " s
                        If s=vname Then
                              Call Blur
                        End If
                  End If
            End If
exitsub:
            Exit Sub
            
onerror:
            Print "Error on line " & Erl & ": " & Error$
            Resume exitsub
            Call DeActivate
      End Sub
End Class

As you can see, the class is stuffed generously with Print-statements, to find out what's going wrong. It should check every second what's the active part on the screen. It does so, but after a short while Notes might hang, loop and hang, crash, you name it. The sequence is as follows:
- the frameset is opened
- a simple form is loaded in the upper-left corner, read-only, with the calls as described above
- at the lefthand side, an Outline is displayed
- the righthand frame contains a view initially
- so far so good...
- sometimes, when you move the mouse, it goes in a loop (flashing sandglass)
- sometimes, it shows me the name of the view several times, I click here and there, looping again!
- you can get out of the loop, typing Esc several times and Ctrl-Break, but you have to be patient...
- I also had the famous Red Box of Death, I didn't know it does still exist (R6)
- of course, I have the NSD files
- if you remove the If-statements about the view then everything is hunkydory
- the Class does not matter, I tried with function calls in the form, to no avail

Anybody with a good idea? Or shall I call it a bug? How to report this to "the proper authorities"??

The related question can be visited under http:/Q_20796876.html

Regards,
   Sjef

PS I don't know how to assign a difficulty to this question. I'm afraid it's a Notes bug, and there is no solution. Nevertheless, I'll make it 500 points :)
Comment
Watch Question

sJEF,
I thought of the same problem to get handle from one frame to another.

As per my thinking, its very difficult(may be not possible) to get a handle on the other frame and to know what he is doing in that frame.

May be, dynamically generated frames can achieve. But, still I am not convinced whether we can get it or not.

Even though I am not so advanced programmer like you, u can take my help at any time.

Another idea is to run any C API's? I am not sure about this also as I am not aware of API's.

But I will be interested if anyone can provide solution to Sjef query.

Best of luck Sjef.

Commented:
Sjef,

Proper authorities?

Print this page.  Fold carefully as small as possible.  Drop in commode.  Flush.

That ought to do it. Bwaahaahaaahaaaaahaaaa!
What Qwaletee is saying means "IT CANNOT BE DONE"

Am I right Qwaletee?


Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Author

Commented:
Madheeswar,

I strongly get the impression of Qwaletee's remarks that he has had some bad experiences with these "proper authorities". Same with me, I think is ridiculous that someone who means well with the platform has to pay first and then can hope for a solution, without being informed at all during the process about the progress. Business Partner programme? My foot!

I LOVE his comment though :)

Sjef
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Author

Commented:
Just to add to the fun, I managed to get this thing working, only without the view/uiview-stuff. This is buggy as hell! What's weird in my opinion is that you don't even have to get the Workspace afresh, the ws-object is normally in the "current" state. Except for the view/uiview properties, in combination with the NotesTimer. One possible source of the trouble (but Notes went RedBox anyhow): in the frames, lower level, forms are switched by setting the correct target-frame, closing it, and reopening the intended document or view in that target-frame. I can imagine that a NotesUIWorkspace ain't gonna like that!

Another problem: in the opened but read-only form, I tried to get the form's name using doc.Form(0). It doesn't work. Luckily, I have an additional field per form for other purposes that I can check, this field is present an can be read. Yeah, I know, maybe a Form-field, computed when composed, formula Form, would do. I had the additional field present anyway.

I really want to add view verification als well, but how?

Current code, to be instantiated using New MoveFocus("fieldname","fieldvalue"):

Option Public
Option Declare

Declare Sub keybd_event Lib "user32.dll" (Byval bVk As Byte, Byval bScan As Byte, Byval dwFlags As Long,Byval dwExtraInfo As Long)

Private Const FLG_KEYDOWN= 0
Private Const FLG_KEYUP= 2

Private Const KEY_F6 = &H75

Class MoveFocus
      Private elapsedTimer As NotesTimer
      Private ws As NotesUIWorkspace
      Private fname As String
      Private fvalue As String

      Sub New(fname As String, fvalue As String)
            Set elapsedTimer = New NotesTimer(1)
            elapsedTimer.Enabled= False
            Me.fname= fname
            Me.fvalue= fvalue
      End Sub

      Sub Activate
            On Event Alarm From elapsedTimer Call TimerHandler
            elapsedTimer.Enabled= True
      End Sub

      Sub DeActivate
            elapsedTimer.Enabled= False
      End Sub

      Sub Blur
            Call keybd_event(KEY_F6, 0, FLG_KEYDOWN, 0)
            Call keybd_event(KEY_F6, 0, FLG_KEYUP, 0)
      End Sub

      Private Sub TimerHandler(Source As NotesTimer)
            Dim s As String
            Dim uidoc As NotesUIDocument
            Dim uiview As NotesUIView

            On Error Goto onerror
            Set ws= New NotesUIWorkspace
            If ws Is Nothing Then
                  Call DeActivate
                  Exit Sub
            End If
            Set uidoc= ws.CurrentDocument
            Set uiview= ws.CurrentView
            If Not(uidoc Is Nothing) Then
                  If uidoc.FieldGetText(fname)=fvalue Then
                        Call Blur
                  End If
            End If
'            If Not(uiview Is Nothing) Then
'                  Print "uiview"
'                  Set view= uiview.View
'                  If Not(view Is Nothing) Then
'                        Print "view"
'                        s= view.Name
'                        Print "String: " s
'                        If s=vname Then
'                              Call Blur
'                        End If
'                  End If
'            End If
exitsub:
            Exit Sub

onerror:
'            Print "Error on line " & Erl & ": " & Error$
            Resume exitsub
      End Sub
End Class


Sjef
Sjef,
Is there any new thing happening?
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Author

Commented:
Hi Madheeswar,

Just back from my short holiday, so there were things happening but not related to this question.

I still wonder why the uidoc and doc keep on functioning, but the uiview somehow is invalid or illegal. The class above works for me, although I cannot find out what the current view is. Since I have only a single view active at any moment, I can work around this.

If you have a better suggestion how to solve this, please let me know. Anything! Or do I have to wait for R8?

Sjef
Sjef,

So u had a very good trip?


This is indeed very difficult and as per my thinking goes cannot be done.

Lets wait for any new releases (may be R8)

-Thanks and pls update on this status.

If you get this to work, then u will be the first person to do it as per I know.

BEST OF LUCK.

madheeswar
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Author

Commented:
Madheeswar,

We "had" to visit our folks back home, about 1000 kms up north. A birthday, several nice dinners and some good friends went by. It's good to be back home again, though. No traffic problems, and luckily no snow (a little is falling at this moment). So, yes, it was a good trip.

What shall I do with these 2 questions? They're not solved, that's for sure, or should I leave them open for the time being? I could ask qwaletee to invite some "proper authorities" to have a look here ;)

Thanks for the support!

Sjef
SJEF,
leave it for our discussions. If we have any doubts we can call and take help.

Instead of posting a new thread, we can stay focussed on this thread and discuss on big issues and allot points for encouragement.

What u say?

I think its time for Qwaletee to leave some comments.
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Author

Commented:
Well, just to inform you (see also the link above), users have complained about this piece of code. The client 6.5 crashes every 3 minutes. The answer that they should work a little bit slower to keep the client alive somewhat longer wasn't appreciated. To cut a short story long: I removed the code. The form is still there though, ready to receive focus.

Bright ideas are welcome!!

Sjef

Commented:
***sound of a bugle playing taps***
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Author

Commented:
"Fading light dims the sight..."

Now where am I? Reminds me of a twisty maze of little passages. Or was it a little maze of twisty passages? It may come as a shock to you all, but I'm not going to reward bonuses on this.

I give up. Aaaaaargh!
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Author

Commented:
You're right, my learned friend. Refund is okay with me, and as far as I'm concerned, it can be deleted: I got what I was looking for, i.e. there is no solution. The info here could have some practical use to someone who tries the same as I did, so I do see some use in PAQ/refund. If nobody complains within 4 days...
TheLearnedOne,
There is no need to delete this question. It is having useful discussions.

Thanks
Barry TiceBusiness Analyst
CERTIFIED EXPERT

Commented:
I request that this question not be deleted, even though I was not a direct participant in it. madheeswar put a link to this Q in one of my Q's that had some related issues in it, and going through other people's discussions on things like this broadens the whole community's knowledge.

(My 2 cents.)

-- b.r.t.
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.