Object Persistance and Focus 
Author Message
 Object Persistance and Focus

I have modified a form object to contain many new methods and procedures.
This code will not be compiled into an OLE server, instead it will be
inserted into team members' programs.

Anyway;  When the object(form) is shown I don't want control to be passed
back to the calling program.  The user will use the form to make some
selections from a grid and will press a command button to unload the
object.

By showing the form as vbModal I can get arrount this problem, as the form
will keep the focus until it is unloaded or hidden.  However I can see this
as a potential problem in the future when developing other classes.  How
can the object hold the focus until it is ready to allow the calling
program to proceed?

Form object example:

   frmPMSearch.Username = "x"
   frmPMSearch.Password  = "x"

   frmPMSearch.Show  '****?? vbModal ??

   '***This is were I want the object to keep the focus until it is ready
to return to this program
   '***When I don't use vbModal the method executes and the following lines
are immediately
   '***  executed.  These properties aren't set until the form has been
used!!
   '***Is vbModal my only solution????

   iObjectID = frmPMSearch.PMObjectID
   sName = frmPMSearch.PMName
   sDescription = frmPMSearch.PMDescription
   etc......

=========================
Rob Rae

=========================



Sun, 21 Feb 1999 03:00:00 GMT  
 Object Persistance and Focus

: By showing the form as vbModal I can get arrount this problem, as the form
: will keep the focus until it is unloaded or hidden.  However I can see this
: as a potential problem in the future when developing other classes.  How
: can the object hold the focus until it is ready to allow the calling
: program to proceed?

: Is vbModal my only solution????

Here's what I do.  It's a simple idea that Jens Balchen suggested to me.
Make the form be the only one in your application that is enabled (i.e.,
Me.Enabled = True).  If no other forms are enabled, they cannot take the
focus.  Then, before unloading the form, enable and SetFocus to whichever
form should logically receive the focus next.  (You might Hide first, and
then unload after changing the focus, just to make the transition happen
more smoothly.)



Sun, 21 Feb 1999 03:00:00 GMT  
 Object Persistance and Focus

Quote:

> I have modified a form object to contain many new methods and procedures.
> This code will not be compiled into an OLE server, instead it will be
> inserted into team members' programs.

> Anyway;  When the object(form) is shown I don't want control to be passed
> back to the calling program.  The user will use the form to make some
> selections from a grid and will press a command button to unload the
> object.

> By showing the form as vbModal I can get arrount this problem, as the form
> will keep the focus until it is unloaded or hidden.  However I can see this
> as a potential problem in the future when developing other classes.  How
> can the object hold the focus until it is ready to allow the calling
> program to proceed?

The Form_Deactivate event fires after the form looses focus.  You might
set a module level flag to indicate the readyness of the form
unload procedure

Form_load()
        NotReadyToUnload=1

Form_DeActivate()
   If NotReadyToUnload Then
        MsgBox "Select something stupid!"
        Me.Setfocus
   End IF

Command1_Click() 'The Unload button you mentioned
        NotReadyToUnload = 0
        Unload Me

I used a message box, because using this process will cause the main form
to momentarily get activated, thus producing an undesireable flash.  The
messagebox was merely a distraction to focus user attention to the message
box instead of where he thought he was going (the previous form).

This method is available using native VB code, Perhaps there is a windows
message you can hook into to get notification that the form is about to
loose focus, I didnt check.



Sun, 21 Feb 1999 03:00:00 GMT  
 Object Persistance and Focus

Regaurding previous post using the Deactivate event.

Please note that as programmers, we have to supply code for every
level of user, and for all types of user action.  This includes
everything from a cat batting around and playfully clicking the
mouse button, to the family parakeet landing on, and pecking at the
keyboard (Dancing dog, gorilla, what have you).

We literally have to assume that some user, in the life of the product
is going to attempt every kind of possible input scenario.  While this
adds to the programming task, I have always thought it amusing if the
computer could identify and differentiate between the new user causing
an error in an honest attempt, and the experienced user who makes a
absent minded mistake!

For this reason you saw (in the past) notification messages flaming the
user for errant input.  

DO NOT INCLUDE THESE IN YOUR OWN PROGRAMS, unless you really want to
get user feedback at any cost!

A word to the wise is sufficient!



Sun, 21 Feb 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Persistance of objects

2. Object Persistance/Serialization

3. Problem with Persistance of object type between apps

4. Object persistance

5. PublicNotCreatable object collection persistance

6. Object property persistance

7. Object persistance without the PropBag?

8. Object Persistance to DB

9. someone please explain object persistance

10. Object persistance

11. Focus, Focus, Who's getting the Focus

12. Return name of Object with Focus

 

 
Powered by phpBB® Forum Software