Author Topic: Form Dialog TopMost  (Read 1039 times)

Phrog30

  • Guest
Form Dialog TopMost
« on: April 10, 2017, 10:03:12 PM »
I have a question about forms that are on top of other forms, I call them popups.  I want the form to stay on top, but I haven't had good results with using topmost because then it might hide other things like messagebox and other windows apps.  So, I tried the following code:

Code: [Select]
Me.Owner = ActiveForm
        Me.CenterToParent()

This works fine but then if you change a form it "stays" with the previous form.  Two questions, one, is there a better way? Two, if not, how can I detect the activeform has changed and then tell the popup to "look" at this new form?

By the way, I don't want show dialog as I want to be able to do other things.

James

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Form Dialog TopMost
« Reply #1 on: April 11, 2017, 08:03:30 AM »
James,

Archie may have a simpler way to do what you want, but for me I would raise and event when the new form opened, and catch it in the popup form(s).
Code: [Select]
'In the forms you want to "Look" at, declare an event
Public event frmOneShowing

'In form Load raise the event
RaiseEvent frmOneShowing

'In the Popup form
'Declare an object reference withevents to the form
private withevents myfrmOne as frmOne

'Create the routine to handle the event
Private Sub frmOne_frmOneShowing handles frmOne.frmOneShowing

'your code here to center it.

end sub



Rich