Home » Category » Microsoft Visual Basic

Microsoft Visual Basic: Z-Order (owner form and ActiveX EXE)

104| Tue, 04 Dec 2007 07:47:00 GMT| clarkgriswald| Comments (7)
I created an Active EXE which is an asynchronous progress indicator. Now I need the form that is part of the ActiveX EXE to be "on top" of ONLY the owner form, which can be set, passed in, etc. I do NOT want it to be "TOP MOST" because then switching between applications will still have my progress EXE on top of the other applications, which is no good.

So my question is essentially is it possible to have an AcitveX EXE have one owner form that it will always stay "on top" of, but no other?

I was playing with the SetWindowPos API, but could not seem to get the desired effect.

Keywords & Tags: z-order, owner, form, activex, exe, microsoft, visual basic, vb

URL: http://www.programmerbase.com/visual-basic/560829/
 
«« Prev - Next »» 7 helpful answers below.
You can place the form within the OwnerForm using SetParent (http://www.allapi.net/apilist/SetParent.shtml) API

bushmobile | Tue, 04 Dec 2007 22:12:00 GMT |

I tried that, but my progress EXE shows up then the disappears.

clarkgriswald | Tue, 04 Dec 2007 22:13:00 GMT |

Are you setting the position of the window after using SetParent?

bushmobile | Tue, 04 Dec 2007 22:14:00 GMT |

Ok, that was the issue, but i still can't seem to get the progress to appear "centered" in the owner. What should the StartUpPosition be for the form inside my ActiveX EXE?

Here is my snippet:

' Make progress form stay on top of owner
lResult = SetParentForm(fProgress.hwnd, fOwner.hwnd)

' Show the progress dialog
fProgress.Show

' Center form on owner (if specified)
If Not (fOwner Is Nothing) Then
If fOwner.Visible Then
fProgress.Left = (fOwner.Width / 2) - (fProgress.Width / 2)
fProgress.Top = (fOwner.Height / 2) - (fProgress.Height / 2)
End If
End If

clarkgriswald | Tue, 04 Dec 2007 22:16:00 GMT |

Is the problem that it's not quite centered or it's not moving it at all?

If Not (fOwner Is Nothing) Then
If fOwner.Visible Then
With fProgress
.Move (fOwner.ScaleWidth - .Width) / 2, _
(fOwner.ScaleHeight - .Height) / 2
End With
End If
End If

bushmobile | Tue, 04 Dec 2007 22:17:00 GMT |

Got it! Thank you very much!

clarkgriswald | Tue, 04 Dec 2007 22:18:00 GMT |

Cool :thumb:

Don't forget to mark this thread resolved.

bushmobile | Tue, 04 Dec 2007 22:19:00 GMT |

Microsoft Visual Basic Hot Answers

Microsoft Visual Basic New questions

Microsoft Visual Basic Related Categories