This works really well to make the user form topmost. I think .NET has a property to do this making things a lot easier. Is there a way to make this topmost to the application I am connecting to? I tried to use findwindow and setparent. Here is what I have in the code:
'user form Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Sub UserForm_Activate() Dim h As Long 'find windows handle of user form h = FindWindow(vbNullString, Me.Caption) 'set form as a child to parent google SetParent h, hWndGoogle End Sub 'main script module Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Dim hWndGoogle As Long Sub Main() Shell_ http://www.google.com/ 'find windows handle of google hWndGoogle = FindWindow(vbNullString, "Google - Windows Internet Explorer") End Sub From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thom C. Blackwell Sent: Monday, April 14, 2008 4:41 PM To: [email protected] Subject: RE: [Talk] findwindow and setparent functions Greetings, Seen this done before - here's some code I just tried that worked: 'Paste me into the Form in the Declarations Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2 Private Const SWP_NOMOVE = &H2 Private Const SWP_NOSIZE = &H1 Private Const SWP_NOACTIVATE = &H10 Private Const SWP_SHOWWINDOW = &H40 Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE Private Declare Function SetWindowPos Lib "user32" _ (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _ ByVal x As Long, ByVal y As Long, _ ByVal cx As Long, ByVal cy As Long, _ ByVal wFlags As Long) As Long 'Form load is the likely place to call this, but it could be done anywhere.. Private Sub Form_Load() Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) End Sub ------------------------------------------------------------ Just in case someone asks about doing this with a user form in VBA... this links to an example in the script library - its moderately more difficult to do in the VBA environment because you don't have me.Hwnd like you do in a VB form. http://www.bostonworkstation.com/customer_center/script_center/script_de tails.aspx?id=206&cat=21 Regards, Thom Thom C. Blackwell Product Manager Boston Software Systems (866) 653-5105 ex 807 www.bossoft.com <http://www.bossoft.com/> Sign up for my weekly webinar! <http://www.bostonworkstation.com/customer_center/special_events.aspx> LEGAL NOTICE Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately, then delete this message and empty from your trash. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hayes, Daniel Sent: Monday, April 14, 2008 4:28 PM To: [email protected] Subject: [Talk] findwindow and setparent functions Does anyone have any experience using the findwindow and setparent functions in VB6? I have a modeless user form. I want the form to float on top of a web application. The functionality I want is similar to the 'solution explorer' or 'properties' windows in visual studio. The form will always stay on top of just the parent. Any help is appreciated. Danny Hayes Level III Engineer Streamline Health ________________________________ Spam <http://192.168.20.55/canit/b.php?i=1206448&m=81dd0ce3c7a5&c=s> Not spam <http://192.168.20.55/canit/b.php?i=1206448&m=81dd0ce3c7a5&c=n> Forget previous vote <http://192.168.20.55/canit/b.php?i=1206448&m=81dd0ce3c7a5&c=f> -------------------------------------------------------------------- The information contained in this e-mail message is intended by Streamline Health for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and protected from disclosure under applicable law. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you received this email in error, please notify us immediately by replying to the message and deleting it from your computer.
